Skip to content

Commit

Permalink
999999999_7200235.py (#45) hxltm__ex_dict() & hxltm_carricato__cod_ab…
Browse files Browse the repository at this point in the history
…_et_wdata() draft
  • Loading branch information
fititnt committed Jul 19, 2022
1 parent 8baa986 commit e69fa0a
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 3 deletions.
43 changes: 40 additions & 3 deletions officina/999999999/0/999999999_7200235.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
csv_imprimendo,
# hxltm__data_referentibus,
hxltm__est_data_referentibus,
hxltm__ex_dict,
hxltm__quod_data_referentibus,
hxltm_adde_columna,
hxltm_carricato,
Expand Down Expand Up @@ -708,6 +709,7 @@ def execute_cli(self, pyargs, stdin=STDIN, _stdout=sys.stdout,

caput, data = hxltm_carricato__cod_ab_et_wdata(
caput_cod, data_cod,
caput_wdata, data_wdata,
numerordinatio_praefixo=numerordinatio_praefixo)

# if pyargs.methodus == 'cod_ab_index_levels':
Expand Down Expand Up @@ -1104,12 +1106,47 @@ def actio(self):


def hxltm_carricato__cod_ab_et_wdata(
caput: list, data: list, numerordinatio_praefixo: str = '1603_45_16',
caput_cod: list, data_cod: list,
caput_wdata: list, data_wdata: list,
numerordinatio_praefixo: str = '1603_45_16',
no1_simplici: bool = False
) -> Tuple[list, list]:
# @TODO finish this draft
caput_novo = caput
data_novis = data
unm49_index_cod = 1 # we assume this will be the index
unm49_index_wdata = 0 # we assume this will be the index

numerordinatio_praefixo = numerordinatio_neo_separatum(
numerordinatio_praefixo, ':')
cod_dict = {}
wdata_dict = {}
resultatum_dict = {}
for item in data_cod:
cod_dict[int(item[unm49_index_cod])] = dict(zip(caput_cod, item))
for item in data_wdata:
wdata_dict[int(item[unm49_index_wdata])] = dict(zip(caput_cod, item))

# print(cod_dict)
caput_novo = caput_cod
data_novis = data_cod

for unm49 in range(0, 1000):
if unm49 not in cod_dict and unm49 not in wdata_dict:
continue
if unm49 in wdata_dict:
if unm49 in cod_dict:
resultatum_dict[unm49] = {
**wdata_dict[unm49], **cod_dict[unm49]}
else:
resultatum_dict[unm49] = wdata_dict[unm49]
if unm49 in cod_dict:
resultatum_dict[unm49] = cod_dict[unm49]

resultatum_dict[unm49]['#item+conceptum+numerordinatio'] = \
'{0}:{1}:1'.format(numerordinatio_praefixo, str(unm49))

caput_novo, data_novis = hxltm__ex_dict(resultatum_dict)

# print(resultatum_dict[4])
return caput_novo, data_novis


Expand Down
42 changes: 42 additions & 0 deletions officina/999999999/0/L999999999_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -4970,6 +4970,48 @@ def hxltm__est_data_referentibus(*options):
return resultatum


def hxltm__ex_dict(
hxltm_dict: dict, caput: list = None, caput_aliis: dict = None):
"""hxltm__ex_dict boostrap an HXLTM caput/data from a Python dict
Args:
hxltm_dict (dict): _description_
caput (list, optional): _description_. Defaults to None.
caput_aliis (dict, optional): _description_. Defaults to None.
Returns:
(Tuple): caput_novo, data_novis
"""

caput_novo = []
data_novis = []
if caput is None:
_first = list(hxltm_dict.keys())[0]
caput_novo = hxltm_dict[_first].keys()

if caput_aliis is not None:
_hxltm_dict = {}
for clavem, v in hxltm_dict.items():
_hxltm_dict[clavem] = v
for k_old, k_new in caput_aliis:
if k_old in _hxltm_dict[clavem]:
_hxltm_dict[clavem][k_new] = _hxltm_dict[clavem].pop(k_old)
else:
_hxltm_dict = hxltm_dict

for _index, res in _hxltm_dict.items():
linea_novae = []
for item in caput_novo:
if item in res:
linea_novae.append(res[item])
else:
linea_novae.append('')
data_novis.append(linea_novae)

caput_novo = caput
return caput_novo, data_novis


def hxltm__quod_data_referentibus(index_nomini: str):
_path = '{0}/999999/0/{1}.index.json'.format(
NUMERORDINATIO_BASIM,
Expand Down

0 comments on commit e69fa0a

Please sign in to comment.