Skip to content

Commit b1801b5

Browse files
committed
999999999_7200235.py (#42): --methodus='cod_ab_index_levels'
1 parent dbdcc9c commit b1801b5

File tree

4 files changed

+81
-41
lines changed

4 files changed

+81
-41
lines changed

officinam/999999999/0/1603_1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4134,7 +4134,8 @@ def quod_tabula(
41344134
if abstractum:
41354135
return archivum_no1
41364136
return archivum_no1.quod_datapackage()
4137-
4137+
# print('archivum_no11', archivum_no11)
4138+
# print('archivum_no1', archivum_no1)
41384139
if strictum:
41394140
raise ValueError('quod_tabula {0}'.format(numerodination))
41404141
return None

officinam/999999999/0/999999999_7200235.py

Lines changed: 66 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
from os.path import exists
4141

4242
# import json
43-
from typing import Type
43+
from typing import Tuple, Type
4444
import yaml
4545
# import urllib.request
4646
# import requests
@@ -65,6 +65,9 @@
6565
hxltm_index_praeparationi,
6666
qhxl_hxlhashtag_2_bcp47,
6767
HXLTMAdRDFSimplicis,
68+
numerordinatio_neo_separatum,
69+
# numerordinatio_ordo,
70+
# numerordinatio_progenitori,
6871
XLSXSimplici
6972
)
7073

@@ -121,6 +124,9 @@
121124
{0} --methodus='cod_ab_index' --cum-ordinibus-ex-columnis=\
122125
'-9:#meta+id|-8:#country+code+v_iso3|-7:#country+code+v_iso2'
123126
127+
Work with local COD-AB index (levels) . . . . . . . . . . . . . . . . . . . . .
128+
{0} --methodus='cod_ab_index_levels'
129+
124130
Process XLSXs from external sources . . . . . . . . . . . . . . . . . . . . . .
125131
{0} --methodus=xlsx_metadata 999999/1603/45/16/xlsx/ago.xlsx
126132
{0} --methodus=xlsx_ad_csv --ordines=2 999999/1603/45/16/xlsx/ago.xlsx
@@ -154,9 +160,9 @@
154160
'#meta+v_iso3+alt=LOWER(#item+rem+i_qcc+is_zxxx+ix_iso3166p1a3)' \
155161
156162
Numerordinatio . . . . .. . . . . . . . . . . . . . . . . . . . . . . . . . . .
157-
{0} --methodus=xlsx_ad_no1 --ordines=1 \
158-
--numerordinatio-praefixo=1603_45_16 --pcode-praefixo=AO --unm49=24 \
159-
999999/1603/45/16/xlsx/ago.xlsx
163+
{0} --methodus=xlsx_ad_no1 \
164+
--numerordinatio-praefixo=1603_45_16 --unm49=24 --ordines=1 \
165+
--pcode-praefixo=AO 999999/1603/45/16/xlsx/ago.xlsx
160166
161167
162168
Index preparation (warn up cache) . . . . . . . . . . . . . . . . . . . . . . .
@@ -245,6 +251,7 @@ def make_args(self, hxl_output=True):
245251
# 'pcode_ex_xlsx',
246252
# 'pcode_ex_csv',
247253
'cod_ab_index',
254+
'cod_ab_index_levels',
248255
'cod_ab_ad_rdf_skos_ttl',
249256
'de_hxltm_ad_hxltm', # load main file directly
250257
# load main file by number (example: 1603_45_49)
@@ -599,23 +606,23 @@ def execute_cli(self, pyargs, stdin=STDIN, _stdout=sys.stdout,
599606
if pyargs.venandum_insectum or VENANDUM_INSECTUM:
600607
self.venandum_insectum = True
601608

602-
# if stdin.isatty():
603-
# _infile = pyargs.infile
604-
# _stdin = False
605-
# else:
606-
# if pyargs.methodus in ['xlsx_metadata', 'de_librario']:
607-
# # print(' oi pyargs.infile', pyargs.infile)
608-
# raise ValueError(
609-
# 'stdin not implemented for {0} input'.format(
610-
# pyargs.methodus))
611-
# _infile = None
612-
# _stdin = True
609+
if stdin.isatty():
610+
_infile = pyargs.infile
611+
_stdin = False
612+
else:
613+
# if pyargs.methodus in ['xlsx_metadata', 'de_librario']:
614+
# # print(' oi pyargs.infile', pyargs.infile)
615+
# raise ValueError(
616+
# 'stdin not implemented for {0} input'.format(
617+
# pyargs.methodus))
618+
# _infile = None
619+
_stdin = True
613620

614621
_infile = pyargs.infile
615-
622+
# raise NotImplementedError(pyargs.methodus)
616623
if pyargs.methodus in [
617624
'de_hxltm_ad_hxltm', 'de_librario',
618-
'index_praeparationi', 'cod_ab_index']:
625+
'index_praeparationi', 'cod_ab_index', 'cod_ab_index_levels']:
619626
# Decide which main file to load.
620627
# if pyargs.methodus.startswith('de_librario'):
621628
if pyargs.methodus.startswith(
@@ -632,6 +639,13 @@ def execute_cli(self, pyargs, stdin=STDIN, _stdout=sys.stdout,
632639
elif pyargs.methodus.startswith('cod_ab_index'):
633640
caput, data = hxltm_carricato(COD_AB_INDEX)
634641

642+
if pyargs.methodus == 'cod_ab_index_levels':
643+
# @TODO cod_ab_index_levels
644+
# caput, data = hxltm_carricato(COD_AB_INDEX)
645+
# raise NotImplementedError(pyargs.methodus)
646+
647+
caput, data = hxltm_carricato__cod_ab_levels(caput, data)
648+
635649
est_data_referentibus = hxltm__est_data_referentibus(
636650
pyargs.adde_columnis,
637651
pyargs.ex_selectis,
@@ -982,30 +996,43 @@ def actio(self):
982996
# print('failed')
983997

984998

985-
def numerordinatio_neo_separatum(
986-
numerordinatio: str, separatum: str = "_") -> str:
987-
resultatum = ''
988-
resultatum = numerordinatio.replace('_', separatum)
989-
resultatum = resultatum.replace('/', separatum)
990-
resultatum = resultatum.replace(':', separatum)
991-
# TODO: add more as need
992-
return resultatum
999+
def hxltm_carricato__cod_ab_levels(
1000+
caput: list, data: list, numerordinatio_praefixo: str = '1603_45_16'
1001+
) -> Tuple[list, list]:
1002+
"""hxltm_carricato__cod_ab_levels filter cod_ab_index into a list of levels
9931003
1004+
Args:
1005+
caput (list): _description_
1006+
data (list): _description_
9941007
995-
def numerordinatio_ordo(numerordinatio: str) -> int:
996-
normale = numerordinatio_neo_separatum(numerordinatio, '_')
997-
return (normale.count('_') + 1)
998-
999-
1000-
def numerordinatio_progenitori(
1001-
numerordinatio: str, separatum: str = "_") -> int:
1002-
# prōgenitōrī, s, m, dativus, https://en.wiktionary.org/wiki/progenitor
1003-
normale = numerordinatio_neo_separatum(numerordinatio, separatum)
1004-
_parts = normale.split(separatum)
1005-
_parts = _parts[:-1]
1006-
if len(_parts) == 0:
1007-
return "0"
1008-
return separatum.join(_parts)
1008+
Returns:
1009+
Tuple[list, list]: _description_
1010+
"""
1011+
columnae = [
1012+
'#country+code+v_unm49',
1013+
'#meta+source+cod_ab_level',
1014+
]
1015+
# print(' ooi')
1016+
1017+
caput, data = hxltm_cum_aut_sine_columnis_simplicibus(
1018+
caput, data, columnae)
1019+
# _ordo_novo = []
1020+
numerordinatio_praefixo = numerordinatio_neo_separatum(
1021+
numerordinatio_praefixo, ':')
1022+
caput_novo = ['#item+conceptum+numerordinatio']
1023+
caput_novo.extend(caput)
1024+
data_novis = []
1025+
for linea in data:
1026+
linea_novae = []
1027+
linea_novae.append('{0}:{1}:{2}'.format(
1028+
numerordinatio_praefixo, linea[0], linea[1]
1029+
))
1030+
linea_novae.extend(linea)
1031+
data_novis.append(linea_novae)
1032+
1033+
# raise NotImplementedError
1034+
# return caput, data
1035+
return caput_novo, data_novis
10091036

10101037

10111038
if __name__ == "__main__":

officinam/999999999/0/L999999999_0.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3122,6 +3122,7 @@ def _initiari(self):
31223122
- initiārī, https://en.wiktionary.org/wiki/initio#Latin
31233123
"""
31243124
if not os.path.exists(self.archivum_trivio):
3125+
# print('self.archivum_trivio', self.archivum_trivio)
31253126
self.statum = False
31263127
return self.statum
31273128

officinam/999999999/1603_45_16.sh

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,12 @@ bootstrap_1603_45_16__item() {
215215
fi
216216

217217
objectivum_archivum_basi_lvl="${objectivum_archivum_basi}/${cod_level}"
218-
objectivum_archivum_no1="${objectivum_archivum_basi_lvl}/${numerordinatio_praefixo}_${cod_level}.no1.tm.hxl.csv"
218+
objectivum_archivum_no1="${objectivum_archivum_basi_lvl}/${numerordinatio_praefixo}_${unm49}_${cod_level}.no1.tm.hxl.csv"
219+
220+
# set -x
221+
# rm "$objectivum_archivum_no1" || true
222+
# set +x
223+
# continue
219224
echo " cod-ab-$_iso3661p1a3_lower-$cod_level [$objectivum_archivum_no1] ..."
220225
if [ ! -d "$objectivum_archivum_basi_lvl" ]; then
221226
mkdir "$objectivum_archivum_basi_lvl"
@@ -951,3 +956,9 @@ set +x
951956

952957
# rapper -g 999999/0/ibge_un_adm2.no1.skos.ttl
953958
# rapper --output dot --guess 999999/0/ibge_un_adm2.no1.skos.ttl
959+
960+
961+
#### @TODO: population --------------------------------------------------------
962+
# https://www.wikidata.org/wiki/Wikidata:SPARQL_query_service/queries/examples#Countries_sorted_by_population
963+
# https://w.wiki/5CDt
964+
#

0 commit comments

Comments
 (0)