-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from sentier-dev/ci
Add script to generate output files
- Loading branch information
Showing
6 changed files
with
794 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env bash | ||
# This script generates all output data from the input files in this repository. | ||
# | ||
# If executed without arguments, it downloads the required external files and | ||
# executes all generators: | ||
# | ||
# $ scripts/generate.sh | ||
# | ||
# The `fetch` and `generate` sub-commands can be used to execute individual | ||
# stages: | ||
# | ||
# $ scripts/generate.sh fetch | ||
# $ scripts/generate.sh generate nace | ||
set -euo pipefail | ||
|
||
GENERATORS=( | ||
qudt | ||
combined_nomenclature | ||
envo | ||
model_terms | ||
open_energy_ontology | ||
custom_products | ||
) | ||
|
||
declare -A GENERATOR_ARGS | ||
GENERATOR_ARGS=( | ||
[combined_nomenclature]=sentier_vocab/CN_2024.rdf | ||
) | ||
|
||
main() { | ||
[[ "$#" -eq 0 ]] && set -- all | ||
local cmd=$1; shift | ||
case "$cmd" in | ||
all) fetch; generate;; | ||
fetch) fetch "$@";; | ||
generate) generate "$@";; | ||
*) usage;; | ||
esac | ||
} | ||
|
||
usage() { | ||
echo >&2 <<EOF | ||
Usage: $0 [CMD [ARG...]] | ||
Commands: | ||
[all] | ||
fetch | ||
generate [MODULE...] | ||
EOF | ||
return 1 | ||
} | ||
|
||
fetch() { | ||
[[ "$#" -eq 0 ]] || usage | ||
echo == CN_2024.rdf.zip == | ||
curl \ | ||
--silent --show-error \ | ||
--cookie-jar cookies.txt --output /dev/null \ | ||
--data 'email=public%40showvoc.eu&password=showvoc' \ | ||
'https://showvoc.op.europa.eu/semanticturkey/it.uniroma2.art.semanticturkey/st-core-services/Auth/login' | ||
curl \ | ||
--cookie cookies.txt --output CN_2024.rdf.zip \ | ||
'https://showvoc.op.europa.eu/semanticturkey/it.uniroma2.art.semanticturkey/st-core-services/Download/getFile?fileName=CN_2024.rdf.zip&ctx_project=ESTAT_Combined_Nomenclature%2C_2024_(CN_2024)' | ||
unzip -u CN_2024.rdf.zip | ||
} | ||
|
||
generate() { | ||
[[ "$#" -eq 0 ]] && set -- "${GENERATORS[@]}" | ||
local x | ||
for x; do | ||
echo "== $x ==" | ||
python -m "sentier_vocab.$x" ${GENERATOR_ARGS[$x]-} | ||
done | ||
} | ||
|
||
main "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.