Skip to content

Commit

Permalink
999999999_54872.py (#2): bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed Jun 30, 2022
1 parent 81c03b1 commit 369ca99
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 49 deletions.
24 changes: 19 additions & 5 deletions officina/999999999/0/999999999_54872.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,16 @@ def make_args(self, hxl_output=True):
nargs='?'
)

parser.add_argument(
'--real-infile-path',
help='(Quick workaround for edge cases) in case infile becomes'
'ambigous on shell scripting, use this to force real source path',
dest='real_infile',
nargs='?',
default=None,
required=False,
)

# parser.add_argument(
# '--methodus',
# help='Modo de operação.',
Expand Down Expand Up @@ -451,12 +461,16 @@ def execute_cli(self, pyargs, stdin=STDIN, stdout=sys.stdout,
stderr=sys.stderr):
# self.pyargs = pyargs

if stdin.isatty():
_infile = pyargs.infile
if pyargs.real_infile is not None:
_infile = pyargs.real_infile
_stdin = False
else:
_infile = None
_stdin = True
if stdin.isatty():
_infile = pyargs.infile
_stdin = False
else:
_infile = None
_stdin = True

resultatum_separato = pyargs.resultatum_separato
fontem_separato = pyargs.fontem_separato
Expand All @@ -472,7 +486,7 @@ def execute_cli(self, pyargs, stdin=STDIN, stdout=sys.stdout,
'_temp_no1_to_no1_shortnames']:
# if pyargs.objectivum_formato = '_temp_no1_to_no1_shortnames':

if _stdin:
if _stdin and not _infile:
raise NotImplementedError('{0} not with stdin'.format(
pyargs.objectivum_formato))

Expand Down
89 changes: 48 additions & 41 deletions officina/999999999/1603_45_16.lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ bootstrap_1603_45_16__all() {
fi

bootstrap_1603_45_16__item_no1 "$numerordinatio_praefixo" "$unm49" "$v_iso3" "$v_iso2" "$cod_ab_level_max" "1" "0"
bootstrap_1603_45_16__item_rdf "$numerordinatio_praefixo" "$unm49" "$v_iso3" "$v_iso2" "$cod_ab_level_max" "1" "0"
bootstrap_1603_45_16__item_bcp47 "$numerordinatio_praefixo" "${unm49}" "$v_iso3" "$v_iso2" "$cod_ab_level_max" "1" "0" "5"
bootstrap_1603_45_16__item_rdf "$numerordinatio_praefixo" "$unm49" "$v_iso3" "$v_iso2" "$cod_ab_level_max" "1" "0" "5"

# printf "\t%40s\n" "${tty_red} DEBUG: [Sleep 5 (@TODO disable me later)] ${tty_normal}"
# sleep 5
printf "\t%40s\n" "${tty_red} DEBUG: [Sleep 5 (@TODO disable me later)] ${tty_normal}"
sleep 5
done
} <"${opus_temporibus_temporarium}"

Expand Down Expand Up @@ -460,7 +461,7 @@ bootstrap_1603_45_16__item_bcp47() {
set -x
"${ROOTDIR}/999999999/0/999999999_54872.py" \
--objectivum-formato=_temp_no1_to_no1_shortnames \
"${objectivum_archivum_no1}" >"${opus_temporibus_temporarium}"
--real-infile-path="${objectivum_archivum_no1}" >"${opus_temporibus_temporarium}"

# Temporary fix: remove some generated tags with error: +ix_error
# Somewhat temporary: remove non-merget alts: +ix_alt1|+ix_alt12|+ix_alt13
Expand All @@ -476,7 +477,7 @@ bootstrap_1603_45_16__item_bcp47() {

"${ROOTDIR}/999999999/0/999999999_54872.py" \
--objectivum-formato=_temp_data_hxl_to_bcp47 \
"${opus_temporibus_temporarium_2}" >"${opus_temporibus_temporarium}"
--real-infile-path="${opus_temporibus_temporarium_2}" >"${opus_temporibus_temporarium}"

frictionless validate "${opus_temporibus_temporarium}"

Expand Down Expand Up @@ -521,6 +522,7 @@ bootstrap_1603_45_16__item_bcp47() {
# cod_ab_level_max
# est_temporarium_fontem
# est_temporarium_objectivum
# rdf_ontologia_ordinibus (Tip: "5" if prefix 1603_45_16, "4" if 1603_16)
#
# Outputs:
# Convert files
Expand All @@ -533,6 +535,7 @@ bootstrap_1603_45_16__item_rdf() {
cod_ab_level_max="${5}"
est_temporarium_fontem="${6:-"1"}"
est_temporarium_objectivum="${7:-"0"}"
rdf_ontologia_ordinibus="${8:-"5"}"

if [ "$est_temporarium_fontem" -eq "1" ]; then
_basim_fontem="${ROOTDIR}/999999"
Expand All @@ -554,7 +557,8 @@ bootstrap_1603_45_16__item_rdf() {
# objectivum_archivum_basi="${_basim_objectivum}/1603/45/16/${unm49}"
objectivum_archivum_basi="${_basim_objectivum}/${__group_path}/${unm49}"
# opus_temporibus_temporarium="${ROOTDIR}/999999/0/${unm49}~lvl.tsv"
opus_temporibus_temporarium="${DESTDIR}/999999/0/${unm49}.ttl"
opus_temporibus_temporarium="${DESTDIR}/999999/0/${unm49}~1.ttl"
opus_temporibus_temporarium_2="${DESTDIR}/999999/0/${unm49}~2.ttl"

printf "\t%40s\n" "${tty_blue}${FUNCNAME[0]} STARTED [$numerordinatio_praefixo] [$unm49] [$iso3661p1a3] [$pcode_praefixo]${tty_normal}"

Expand Down Expand Up @@ -585,6 +589,7 @@ bootstrap_1603_45_16__item_rdf() {
objectivum_archivum_no1="${objectivum_archivum_basi_lvl}/${numerordinatio_praefixo}_${unm49}_${cod_level}.no1.tm.hxl.csv"

objectivum_archivum_no1_owl_ttl="${objectivum_archivum_basi_lvl}/${numerordinatio_praefixo}_${unm49}_${cod_level}.no1.owl.ttl"
objectivum_archivum_no1_skos_ttl="${objectivum_archivum_basi_lvl}/${numerordinatio_praefixo}_${unm49}_${cod_level}.no1.skos.ttl"

# set -x
# rm "$objectivum_archivum_no1" || true
Expand All @@ -599,38 +604,24 @@ bootstrap_1603_45_16__item_rdf() {

rdf_trivio=$((5000 + cod_level))

# set -x
# "${ROOTDIR}/999999999/0/999999999_54872.py" \
# --objectivum-formato=_temp_no1 \
# --rdf-trivio="${rdf_trivio}" \
# "${objectivum_archivum_no1}" |
# rapper --quiet --input=turtle --output=turtle /dev/fd/0 \
# > "${objectivum_archivum_no1_owl_ttl}"
# set +x
set -x
## Computational-like RDF serialization, "OWL version" --------------------

# "${ROOTDIR}/999999999/0/999999999_7200235.py" \
# --methodus=xlsx_ad_no1 \
# --numerordinatio-praefixo="$numerordinatio_praefixo" \
# --ordines="$cod_level" \
# --pcode-praefix="$pcode_praefixo" \
# --unm49="$unm49" \
# "$fontem_archivum" >"${objectivum_archivum_no1}"
# "${ROOTDIR}/999999999/0/999999999_54872.py" \
# --objectivum-formato=_temp_no1 \
# --rdf-trivio="${rdf_trivio}" \
# "${objectivum_archivum_no1}"
# @TODO fix generation of invalid format if
# --rdf-sine-spatia-nominalibus=skos,devnull is enabled

# @
# "${ROOTDIR}/999999999/0/999999999_54872.py" \
# --objectivum-formato=_temp_no1 \
# --numerordinatio-cum-antecessoribus \
# --rdf-sine-spatia-nominalibus=skos,devnull \
# --rdf-ontologia-ordinibus="${rdf_ontologia_ordinibus}" \
# --rdf-trivio="${rdf_trivio}" \
# "${objectivum_archivum_no1}" >"${opus_temporibus_temporarium}"
# <"${objectivum_archivum_no1}" >"${opus_temporibus_temporarium}"

"${ROOTDIR}/999999999/0/999999999_54872.py" \
--objectivum-formato=_temp_no1 \
--numerordinatio-cum-antecessoribus \
--rdf-ontologia-ordinibus="5" \
--rdf-sine-spatia-nominalibus=devnull \
--rdf-ontologia-ordinibus="${rdf_ontologia_ordinibus}" \
--rdf-trivio="${rdf_trivio}" \
<"${objectivum_archivum_no1}" >"${opus_temporibus_temporarium}"

Expand All @@ -639,23 +630,39 @@ bootstrap_1603_45_16__item_rdf() {
>"${objectivum_archivum_no1_owl_ttl}"

riot --validate "${objectivum_archivum_no1_owl_ttl}"
set +x

echo "OWL TTL: [${objectivum_archivum_no1_owl_ttl}]"
## Linguistic-like RDF serialization, "SKOS version" ----------------------
# @TODO fix invalid generation if disabling OWL with
# --rdf-sine-spatia-nominalibus=owl

# sleep 10
# "${ROOTDIR}/999999999/0/999999999_54872.py" \
# --objectivum-formato=_temp_no1 \
# --numerordinatio-cum-antecessoribus \
# --rdf-sine-spatia-nominalibus=owl,obo,p,geo,devnull \
# --rdf-ontologia-ordinibus="${rdf_ontologia_ordinibus}" \
# --rdf-trivio="${rdf_trivio}" \
# <"${objectivum_archivum_no1}" >"${opus_temporibus_temporarium_2}"

# set -x
# "${ROOTDIR}/999999999/0/999999999_7200235.py" \
# --methodus=xlsx_ad_no1 \
# --numerordinatio-praefixo="$numerordinatio_praefixo" \
# --ordines="$cod_level" \
# --pcode-praefix="$pcode_praefixo" \
# --unm49="$unm49" \
# "$fontem_archivum" >"${objectivum_archivum_no1}"
# set +x
"${ROOTDIR}/999999999/0/999999999_54872.py" \
--objectivum-formato=_temp_no1 \
--numerordinatio-cum-antecessoribus \
--rdf-sine-spatia-nominalibus=obo,p,geo,devnull \
--rdf-ontologia-ordinibus="${rdf_ontologia_ordinibus}" \
--rdf-trivio="${rdf_trivio}" \
<"${objectivum_archivum_no1}" >"${opus_temporibus_temporarium_2}"

rapper --quiet --input=turtle --output=turtle \
"${opus_temporibus_temporarium_2}" \
>"${objectivum_archivum_no1_skos_ttl}"

riot --validate "${objectivum_archivum_no1_skos_ttl}"
set +x

echo "OWL TTL: [${objectivum_archivum_no1_owl_ttl}]"
echo "SKOS TTL: [${objectivum_archivum_no1_skos_ttl}]"

rm "$opus_temporibus_temporarium"
rm "$opus_temporibus_temporarium_2"

done

Expand Down
6 changes: 3 additions & 3 deletions officina/999999999/1603_45_16.sh
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ __temp_download_external_cod_data() {
# echo "all"

## DEBUG: re-enable later if this line still commented
# bootstrap_1603_45_16__all "1603_45_16"
bootstrap_1603_45_16__all "1603_45_16"

# bootstrap_1603_45_16__item_no1 "1603_45_16" "24" "AGO" "AO" "1" "1" "0"
# bootstrap_1603_45_16__item_rdf "1603_45_16" "24" "AGO" "AO" "3" "1" "0"
Expand All @@ -391,11 +391,11 @@ __temp_download_external_cod_data() {
# bootstrap_1603_45_16__item_no1 "1603_45_16" "$unm49" "$v_iso3" "$v_iso2" "$cod_ab_level_max" "1" "0"
# bootstrap_1603_45_16__item_bcp47 "1603_45_16" "${unm49}" "$v_iso3" "$v_iso2" "$cod_ab_level_max" "1" "0" "4"

# exit 0
exit 0

# exit 0

# bootstrap_1603_45_16__all "1603_45_16"
bootstrap_1603_45_16__all "1603_45_16"
# bootstrap_999999_1603_45_16_neo ""
# bootstrap_999999_1603_45_16_neo "BRA"
# bootstrap_999999_1603_45_16_neo "MOZ"
Expand Down

0 comments on commit 369ca99

Please sign in to comment.