From 16de6a189739df904f114dbe459e97fc3e9ce382 Mon Sep 17 00:00:00 2001 From: Emerson Rocha Date: Wed, 27 Apr 2022 22:42:11 -0300 Subject: [PATCH] 1603_1.py (#35): profile data-package-catalog --- officinam/999999999/0/1603_1.py | 57 ++++++++++++++++++++++++++++++--- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/officinam/999999999/0/1603_1.py b/officinam/999999999/0/1603_1.py index eb724dc..836e639 100755 --- a/officinam/999999999/0/1603_1.py +++ b/officinam/999999999/0/1603_1.py @@ -3706,13 +3706,59 @@ def imprimere(self): else: return [yaml.dump(self.ex_codice(), allow_unicode=True)] - def imprimere_in_datapackage(self): - return self.imprimere_in_markdown() + def imprimere_in_datapackage(self) -> list: + """imprimere_in_datapackage - def imprimere_in_markdown(self): + Trivia: + - datapackage, ---, https://specs.frictionlessdata.io/ + - sarcina, f, s, Nom., https://en.wiktionary.org/wiki/sarcina + + + Returns: + list: + """ + paginae = [] + if self.ex_librario: + sarcina = { + 'name': '1603', + 'profile': 'data-package-catalog', + 'resources': [] + } + status = self.status_librario_ex_codex() + items_sorted = status['librarium'].items() + items_sorted = sorted(items_sorted, key=sort_numerodinatio_clavem) + + for codex, item in items_sorted: + _path = numerordinatio_neo_separatum(codex, '/') + _nomen = numerordinatio_neo_separatum(codex, '_') + + sarcina['resources'].append({ + # 'profile': 'data-package-catalog', # To create sublevels + 'format': 'json', + 'name': _nomen, + 'path': _path + '/datapackage.json', + 'profile': 'tabular-data-package' + }) + else: + ex_codice = self.ex_codice() + sarcina = { + 'name': '1603', + 'profile': 'tabular-data-package', + '_TODO': ex_codice + } + + # raise NotImplementedError( + # '--status-in-markdown requires --ex-librario') + + paginae.append(json.dumps( + sarcina, indent=4, ensure_ascii=False, sort_keys=False)) + + return paginae + + def imprimere_in_markdown(self) -> list: if not self.ex_librario: raise NotImplementedError( - '--status-in-markdown requires --ex-librario="locale"') + '--status-in-markdown requires --ex-librario') paginae = [] status = self.status_librario_ex_codex() paginae.append('# 1603 Librārium') @@ -5572,7 +5618,8 @@ def make_args(self, hxl_output=True): status_quo.add_argument( '--status-in-datapackage', - help='Return status in frictionless datapackage.json', + help='Return status in frictionless datapackage.json. ' + 'With --ex-librario returns profile data-package-catalog.', # metavar='', dest='status_in_datapackage', # const=True,