#!/bin/bash # demo.sh - Process demonstration for WMO. # Copyright (C) 2021 Pierre Choffet # # This program is free software: you can redistribute it and/or modify # it under the terms of version 3 of the GNU General Public License as published # by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . set -euo pipefail function usage { cat << "EOF" Import OSCAR station metadata to Wikidata USAGE: intro.sh EOF } function intro { cat >&2 << "EOF" .g8""8q. .M"""bgd .g8"""bgd db `7MM"""Mq. mm .dP' `YM. ,MI "Y .dP' `M ;MM: MM `MM. MM dM' `MM `MMb. dM' ` ,V^MM. MM ,M9 mmMMmm ,pW"Wq. MM MM `YMMNq. MM ,M `MM MMmmdM9 MM 6W' `Wb MM. ,MP . `MM MM. AbmmmqMA MM YM. MM 8M M8 `Mb. ,dP' Mb dM `Mb. ,' A' VML MM `Mb. MM YA. ,A9 `"bmmd"' P"Ybmmd" `"bmmmd'.AMA. .AMMA..JMML. .JMM. `Mbmo`Ybmd9' ,, ,, ,, `7MMF' A `7MF'db `7MM db `7MM mm `MA ,MA ,V MM MM MM VM: ,VVM: ,V `7MM MM ,MP'`7MM ,M""bMM ,6"Yb.mmMMmm ,6"Yb. MM. M' MM. M' MM MM ;Y MM ,AP MM 8) MM MM 8) MM `MM A' `MM A' MM MM;Mm MM 8MI MM ,pm9MM MM ,pm9MM :MM; :MM; MM MM `Mb. MM `Mb MM 8M MM MM 8M MM VF VF .JMML..JMML. YA..JMML.`Wbmd"MML.`Moo9^Yo.`Mbmo`Moo9^Yo. This tool has been written in 2021 as a one-time proof of concept to import Oscar station metadata into Wikidata. It's not meant to be used outside of this controlled environment as it would inevitably lead any careful user to insert duplicates and wrong information into the Wikimedia project. The full original code remains available here for educational purpose. For up to date code, see the repository at EOF } # Check user args if [ "$#" -ne 2 ] then usage exit elif [ ! -f "${1}" ] then echo "File \"${1}\" doesn't exist." >&2 exit fi intro exit 1 # Generate partial wdef file PARTIAL_WDEF_PATH="$(mktemp)" xmlstarlet tr xslts/isolate_station.xslt -s "wigos-id=${2}" "${1}" | xmlstarlet fo > "${PARTIAL_WDEF_PATH}" # Import it ./import.sh "${PARTIAL_WDEF_PATH}" elements.log rm "${PARTIAL_WDEF_PATH}" echo "Import done" >&2