diff --git a/officinam/999999999/0/1603_1.py b/officinam/999999999/0/1603_1.py index fb57c55..607e35c 100755 --- a/officinam/999999999/0/1603_1.py +++ b/officinam/999999999/0/1603_1.py @@ -138,6 +138,14 @@ --data-apothecae-ex='1603_45_1,1603_45_31' \ --data-apothecae-ad='apothecae.sqlite' + {0} --methodus='opus-temporibus' --ex-opere-temporibus='locale' \ +--quaero-ix_n1603ia='({{publicum}}>=9)' > 999999/0/apothecae-list.txt + {0} --methodus='data-apothecae' \ +--data-apothecae-ex-archivo='999999/0/apothecae-list.txt' \ +--data-apothecae-ad='apothecae.datapackage.json' + {0} --methodus='data-apothecae' \ +--data-apothecae-ex-archivo='999999/0/apothecae-list.txt' \ +--data-apothecae-ad='apothecae.sqlite' Dictionaria Numerordĭnātĭo (deprecated) . . . . . . . . . . . . . . . . . . . . {0} --methodus='deprecatum-dictionaria-numerordinatio' @@ -3582,11 +3590,13 @@ class LibrariaStatusQuo: # No 1603 prefix cdn_prefix: str = 'https://lsf-cdn.etica.ai/' + quaero_ix_n1603ia: str = None def __init__( self, codex: Type['Codex'], - ex_librario: str = '' + ex_librario: str = '', + # quaero_ix_n1603ia: str = None, ): # TODO: implement a way to not re-calculate the status quo (feature # required by crontab/crojob) @@ -3594,6 +3604,7 @@ def __init__( self.codex = codex self.ex_librario = ex_librario # self.status_in_markdown = status_in_markdown + # self.quaero_ix_n1603ia = quaero_ix_n1603ia self.initiari() @@ -3762,6 +3773,19 @@ def imprimere(self): else: return [yaml.dump(self.ex_codice(), allow_unicode=True)] + def imprimere_in_json(self): + if self.ex_librario and len(self.ex_librario) > 0: + # return [yaml.dump( + # self.status_librario_ex_codex(), allow_unicode=True)] + return [json.dumps( + self.status_librario_ex_codex(), + indent=2, ensure_ascii=False, sort_keys=False)] + else: + # return [yaml.dump(self.ex_codice(), allow_unicode=True)] + return [json.dumps( + self.ex_codice(), + indent=2, ensure_ascii=False, sort_keys=False)] + def imprimere_in_csvw(self) -> list: # https://github.com/w3c/csvw # https://www.w3.org/TR/tabular-data-primer/ @@ -3869,7 +3893,7 @@ def imprimere_in_datapackage_sqlite(self) -> list: def imprimere_in_markdown(self) -> list: if not self.ex_librario: raise NotImplementedError( - '--status-in-markdown requires --ex-librario') + '--status--quo-in-markdown requires --ex-librario') paginae = [] status = self.status_librario_ex_codex() paginae.append('# 1603 Librārium') @@ -4499,6 +4523,8 @@ def praeparatio_datapackage( sarcina['resources'].append(DataApothecae.quod_tabula('1603_1_51')) for codex in self.data_apothecae_ex: + if codex in ['1603_1_1', '1603_1_51']: + continue sarcina['resources'].append( DataApothecae.quod_tabula(codex)) @@ -5582,6 +5608,7 @@ class OpusTemporibus: opus: list = [] in_limitem: int = 0 in_ordinem: str = None + quaero_ix_n1603ia: str = None quaero_numerordinatio: list = [] def __init__( @@ -5884,18 +5911,6 @@ def make_args(self, hxl_output=True): default=None ) - commune.add_argument( - '--quaero-ix_n1603ia', - help='Query ix_n1603ia. Rudimentar && (AND) and || (OR). ' - 'Use var<1 to test 0 or undefined. ' - 'Query ix_n1603ia. Filter. Ex. "{publicum}>10 && {internale}<1"', - # metavar='', - dest='quaero_ix_n1603ia', - # const='', - # action='store_true', - nargs='?' - ) - # objectīvum, n, s, nominativus, en.wiktionary.org/wiki/objectivus # fōrmātō, n, s, dativus, https://en.wiktionary.org/wiki/formatus#Latin commune.add_argument( @@ -6112,8 +6127,28 @@ def make_args(self, hxl_output=True): ) status_quo.add_argument( - '--status-in-markdown', - help='Return status in Markdown (instead of YAML)', + '--status-quo-in-yaml', + help='Return status in YAML', + # metavar='', + dest='status_in_yaml', + # const=True, + action='store_true', + # nargs='?' + ) + + status_quo.add_argument( + '--status-quo-in-json', + help='Return status in JSON', + # metavar='', + dest='status_in_json', + # const=True, + action='store_true', + # nargs='?' + ) + + status_quo.add_argument( + '--status-quo-in-markdown', + help='Return status in Markdown', # metavar='', dest='status_in_markdown', # const=True, @@ -6122,7 +6157,7 @@ def make_args(self, hxl_output=True): ) status_quo.add_argument( - '--status-in-datapackage', + '--status-quo-in-datapackage', help='Return status in frictionless datapackage.json. ' 'With --ex-librario returns profile data-package-catalog. ' ' (low level of details)', @@ -6155,7 +6190,7 @@ def make_args(self, hxl_output=True): # "Requires --codex-de 1603_NN_NN" ) - # # ex opere temporibus + # ex opere temporibus opus_temporibus.add_argument( '--ex-opere-temporibus', help='ex opere temporibus. Out of work times (crontab)', @@ -6165,17 +6200,26 @@ def make_args(self, hxl_output=True): # action='store_true', nargs='?' ) - # opus_temporibus.add_argument( - # '--quaero-ix_n1603ia', - # help='Query ix_n1603ia. Rudimentar && (AND) and || (OR). ' - # 'Use var<1 to test 0 or undefined. ' - # 'Query ix_n1603ia. Filter. Ex. "{publicum}>10 && {internale}<1"', - # # metavar='', - # dest='quaero_ix_n1603ia', - # # const='', - # # action='store_true', - # nargs='?' - # ) + opus_temporibus.add_argument( + '--opus-temporibus-in-tsv', + help='Result in TSV (without headers); first column is Codex', + # metavar='', + dest='opus_temporibus_in_tsv', + # const='', + # action='store_true', + nargs='?' + ) + opus_temporibus.add_argument( + '--quaero-ix_n1603ia', + help='Query ix_n1603ia. Rudimentar && (AND) and || (OR). ' + 'Use var<1 to test 0 or undefined. ' + 'Query ix_n1603ia. Filter. Ex. "{publicum}>10 && {internale}<1"', + # metavar='', + dest='quaero_ix_n1603ia', + # const='', + # action='store_true', + nargs='?' + ) opus_temporibus.add_argument( '--quaero-numerordinatio', help='Query Numerordĭnātĭo. Additional filter list for focused ' @@ -6286,6 +6330,8 @@ def execute_cli(self, pyargs, stdin=STDIN, stdout=sys.stdout, if _lineam.startswith('#') or len(_lineam.strip()) == 0: continue lineam = _lineam.rstrip('\n') + if lineam.find("\t") > -1: + lineam = lineam.split("\t")[0] if lineam.find(',') > -1: lineam = lineam.split(',')[0] data_apothecae_ex.append(lineam) @@ -6340,32 +6386,30 @@ def execute_cli(self, pyargs, stdin=STDIN, stdout=sys.stdout, # objectivum_formato = objectivum_formato # else: - # if self.pyargs.status_quo: - formatum = 'asciidoctor' - if self.pyargs.ad_asciidoctor: - formatum = 'asciidoctor' - # if self.pyargs.ad_markdown: - # formatum = 'markdown' - codex = Codex( - # self.pyargs.codex_de, codex_de, objectivum_linguam=self.pyargs.objectivum_linguam, auxilium_linguam=self.pyargs.auxilium_linguam, - # formatum=formatum, - # codex_copertae=self.pyargs.codex_copertae ) libraria = LibrariaStatusQuo( codex, self.pyargs.ex_librario) - if self.pyargs.status_in_markdown: + if self.pyargs.status_in_yaml or \ + self.pyargs.objectivum_formato == 'yaml': + return self.output(libraria.imprimere()) + if self.pyargs.status_in_json or \ + self.pyargs.objectivum_formato == 'json': + return self.output(libraria.imprimere_in_json()) + if self.pyargs.status_in_markdown or \ + self.pyargs.objectivum_formato == 'markdown': return self.output(libraria.imprimere_in_markdown()) - if self.pyargs.status_in_datapackage: + if self.pyargs.status_in_datapackage or \ + self.pyargs.objectivum_formato == 'datapackage': return self.output(libraria.imprimere_in_datapackage()) - return self.output(libraria.imprimere()) + raise ValueError('--status-quo-[option] ?') # Cōdex ________________________________________________________________ # if self.pyargs.actionem_sparql: diff --git a/officinam/999999999/999999999.lib.sh b/officinam/999999999/999999999.lib.sh index bec8a2d..1283786 100644 --- a/officinam/999999999/999999999.lib.sh +++ b/officinam/999999999/999999999.lib.sh @@ -798,7 +798,7 @@ neo_codex_copertae_de_numerordinatio() { # "${ROOTDIR}/999999999/0/1603_1.py" --codex-de 1603_25_1 --codex-copertae "${ROOTDIR}/999999999/0/1603_1.py" \ - --methodus='codex' \ + --methodus='codex' \ --objectivum-linguam="$est_objectivum_linguam" \ --auxilium-linguam="$est_auxilium_linguam" \ --codex-de "$_nomen" \ @@ -2303,12 +2303,14 @@ temp_save_status() { "${ROOTDIR}/999999999/0/1603_1.py" \ --methodus='status-quo' \ - --codex-de "$_nomen" --status-quo \ + --status-quo-in-yaml \ + --codex-de "$_nomen" \ >"$status_archivum_codex" "${ROOTDIR}/999999999/0/1603_1.py" \ --methodus='status-quo' \ - --codex-de "$_nomen" --status-quo --status-in-datapackage \ + --status-quo-in-datapackage \ + --codex-de "$_nomen" --status-quo \ >"$datapackage_dictionaria" # echo "$status_archivum_librario status_archivum_librario " @@ -2316,7 +2318,8 @@ temp_save_status() { # set -x "${ROOTDIR}/999999999/0/1603_1.py" \ --methodus='status-quo' \ - --codex-de "$_nomen" --status-quo --ex-librario="$_ex_librario" \ + --status-quo-in-yaml \ + --codex-de "$_nomen" --ex-librario="$_ex_librario" \ >"$objectivum_archivum_temporarium" # set +x @@ -2325,8 +2328,8 @@ temp_save_status() { # set -x "${ROOTDIR}/999999999/0/1603_1.py" \ --methodus='status-quo' \ - --codex-de "$_nomen" --status-quo --ex-librario="$_ex_librario" \ - --status-in-datapackage \ + --status-quo-in-datapackage \ + --codex-de "$_nomen" --ex-librario="$_ex_librario" \ >"$datapackage_librario" # set +x @@ -2344,6 +2347,106 @@ temp_save_status() { } +####################################### +# Quick routine to frictionless validate datapackage from a librario +# +# Globals: +# ROOTDIR +# Arguments: +# numerordinatio +# Outputs: +# Convert files +####################################### +temp_validate_librario() { + ex_librario="$2" + + # _path=$(numerordinatio_neo_separatum "$numerordinatio" "/") + # _nomen=$(numerordinatio_neo_separatum "$numerordinatio" "_") + # _prefix=$(numerordinatio_neo_separatum "$numerordinatio" ":") + _ex_librario="$ex_librario" + + # status_archivum_codex="${ROOTDIR}/$_path/$_nomen.statum.yml" + # datapackage_dictionaria="${ROOTDIR}/$_path/datapackage.json" + # datapackage_librario="${ROOTDIR}/datapackage.json" + # status_archivum_librario="${ROOTDIR}/1603/1603.$_ex_librario.statum.yml" + # objectivum_archivum_temporarium="${ROOTDIR}/999999/0/1603+$_nomen.statum.yml" + opus_temporibus_temporarium="${ROOTDIR}/999999/0/1603.$_ex_librario.statum.tsv" + + # blue=$(tput setaf 4) + magenta=$(tput setaf 6) + normal=$(tput sgr0) + printf "\t%40s\n" "${magenta}${FUNCNAME[0]} [$_ex_librario]${normal}" + + # "${ROOTDIR}/999999999/0/1603_1.py" \ + # --methodus='opus-temporibus' \ + # --ex-opere-temporibus="$_ex_librario" \ + # --quaero-ix_n1603ia='({publicum}>=9)' \ + # --codex-de "$_nomen" --status-quo \ + # >"$opus_temporibus_temporarium" + + + while IFS=$'\t' read -r -a line; do + # echo "${line[0]}" + + _codex="${line[0]}" + _nomen=$(numerordinatio_codicem_transation_separator "$_codex" "_" "_") + _path=$(numerordinatio_codicem_transation_separator "$_codex" "/" "_") + _datapackage="$_path/datapackage.json" + + # actiones_completis_publicis "${line[0]}" + # echo "${line[0]}" "$_codex" "$_path" "$_nomen" + # echo " $_datapackage" + frictionless validate "$_datapackage" + # echo "$_codex" + # echo "${line[1]}" + # echo "${line[2]}" + done <"$opus_temporibus_temporarium" + +# ./999999999/0/1603_1.py --methodus='opus-temporibus' --ex-opere-temporibus='locale' --quaero-ix_n1603ia='({publicum}>=9)' > 999999/0/apothecae-list.txt + +# "${ROOTDIR}/999999999/0/1603_1.py" \ +# --methodus='status-quo' \ +# --codex-de "$_nomen" --status-quo \ +# >"$status_archivum_codex" + +# "${ROOTDIR}/999999999/0/1603_1.py" \ +# --methodus='status-quo' \ +# --codex-de "$_nomen" --status-quo --status-in-datapackage \ +# >"$datapackage_dictionaria" + +# # echo "$status_archivum_librario status_archivum_librario " + +# # set -x +# "${ROOTDIR}/999999999/0/1603_1.py" \ +# --methodus='status-quo' \ +# --codex-de "$_nomen" --status-quo --ex-librario="$_ex_librario" \ +# >"$objectivum_archivum_temporarium" +# # set +x + +# # We use statum.yml, not datapackage to know state of the library. That's why +# # we can overryde directly +# # set -x +# "${ROOTDIR}/999999999/0/1603_1.py" \ +# --methodus='status-quo' \ +# --codex-de "$_nomen" --status-quo --ex-librario="$_ex_librario" \ +# --status-in-datapackage \ +# >"$datapackage_librario" +# # set +x + +# # NOTE: this operation should be atomic. But for sake of portability, +# # we're using temporary file without flog or setlock or something. +# # Trying to use --status-quo --ex-librario +# # without temporary file will reset old information. That's why +# # we're using temp file +# if [ -f "$status_archivum_librario" ]; then +# rm "$status_archivum_librario" && +# mv "$objectivum_archivum_temporarium" "$status_archivum_librario" +# else +# mv "$objectivum_archivum_temporarium" "$status_archivum_librario" +# fi + +} + ####################################### # āctiōnēs complētīs locālī, complete actions (except download references and # publish online) @@ -2421,6 +2524,6 @@ deploy_0_9_markdown() { --codex-de 1603_1_1 \ --status-quo \ --ex-librario="cdn" \ - --status-in-markdown \ + --status-quo-in-markdown \ >"$objectivum_archivum" } diff --git a/officinam/999999999/999999_17.sh b/officinam/999999999/999999_17.sh index 62bac4f..877d03a 100755 --- a/officinam/999999999/999999_17.sh +++ b/officinam/999999999/999999_17.sh @@ -71,7 +71,7 @@ file_download_1603_xlsx "1" # actiones_completis_locali "1603_1_7" # actiones_completis_locali "1603_1_51" # actiones_completis_locali "1603_1_99" -# actiones_completis_locali "1603_1_2020" +# actiones_completis_locali "1603_25_1" # actiones_completis_locali "1603_44_86" # actiones_completis_locali "1603_45_31" # actiones_completis_locali "1603_63_101" @@ -82,13 +82,16 @@ file_download_1603_xlsx "1" #### Manual action, TEST locally, one per time, END ---------------------------- ## Full drill (remote, specific item) -# actiones_completis_publicis "1603_1_7" +actiones_completis_publicis "1603_25_1" # actiones_completis_publicis "1603_1_8000" # deploy_0_9_markdown ## Full drill (remote, randon publish few at time) -opus_temporibus_cdn -deploy_0_9_markdown +# opus_temporibus_cdn +# deploy_0_9_markdown + +# temp_validate_librario "locale" +temp_validate_librario "cdn" # @TODO: maybe check ssdiff (diff spreadsheets) to our uses.