Skip to content

Commit

Permalink
999999999_0.py (#42): --cum-ordinibus-ex-columnis
Browse files Browse the repository at this point in the history
  • Loading branch information
fititnt committed May 21, 2022
1 parent 9b19fcc commit 56a2420
Show file tree
Hide file tree
Showing 2 changed files with 114 additions and 1 deletion.
31 changes: 30 additions & 1 deletion officinam/999999999/0/999999999_7200235.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
hxltm_carricato,
NUMERORDINATIO_BASIM,
hxltm_cum_columna,
# hxltm_cum_columnis_desideriis,
hxltm_cum_filtro,
hxltm_cum_ordinibus_ex_columnis,
hxltm_sine_columnis,
hxltm_ex_selectis,
hxltm_index_praeparationi,
Expand Down Expand Up @@ -108,6 +110,9 @@
--ex-selectis='#date+created<2010-01-01' \
--ex-selectis='#date+updated>2020-01-01'
{0} --methodus='cod_ab_index' --cum-ordinibus-ex-columnis=\
'-9:#meta+id|-8:#country+code+v_iso3|-7#country+code+v_iso2'
Process XLSXs from external sources . . . . . . . . . . . . . . . . . . . . . .
{0} --methodus=xlsx_metadata 999999/1603/45/16/xlsx/ago.xlsx
{0} --methodus=xlsx_ad_csv --ordines=2 999999/1603/45/16/xlsx/ago.xlsx
Expand Down Expand Up @@ -332,6 +337,17 @@ def make_args(self, hxl_output=True):
default=None
)

memoria_internalo.add_argument(
'--cum-ordinibus-ex-columnis',
help='With this with preferred order of columns (not enforced). '
'If it cannot find the columns, it will not change the order.'
'Example: "-999:#meta+id|0:#meta+code|999:#meta+note"',
dest='cum_ordinibus_ex_columnis',
nargs='?',
# required=True
default=None
)

# memoria_internalo.add_argument(
# '--per-columnas',
# help='Apply filters to existing columns. '
Expand Down Expand Up @@ -566,7 +582,20 @@ def execute_cli(self, pyargs, stdin=STDIN, _stdout=sys.stdout,
if pyargs.sine_columnis:
opus = pyargs.sine_columnis.split(',')
caput, data = hxltm_sine_columnis(
caput, data, opus, data_referentibus)
caput, data, opus, data_referentibus)

# if pyargs.ex_metadatis:
if pyargs.cum_ordinibus_ex_columnis:
_opus = pyargs.cum_ordinibus_ex_columnis
if not isinstance(pyargs.cum_ordinibus_ex_columnis, list):
_opus = [pyargs.cum_ordinibus_ex_columnis]
opus = []
for item in _opus:
opus.extend(map(str.strip, item.split('|')))

# opus = pyargs.cum_ordinibus_ex_columnis.split('|')
caput, data = hxltm_cum_ordinibus_ex_columnis(
caput, data, opus, data_referentibus)

if pyargs.methodus == 'index_praeparationi':

Expand Down
84 changes: 84 additions & 0 deletions officinam/999999999/0/L999999999_0.py
Original file line number Diff line number Diff line change
Expand Up @@ -1899,6 +1899,90 @@ def hxltm_carricato(
return caput, data


def hxltm_cum_ordinibus_ex_columnis(
caput: list, data: list, quaestio: list, data_referentibus: dict = None
) -> Tuple[list, list]:
"""hxltm_cum_columnis_desideriis with preferred order (not enforced)
Trivia:
- cum (+ ablativus), https://en.wiktionary.org/wiki/cum#Latin
- ōrdinibus, pl, m, ablativus, https://en.wiktionary.org/wiki/ordo#Latin
- ex (+ ablativus) https://en.wiktionary.org/wiki/ex#Latin
- columnā, s, f, ablativus, https://en.wiktionary.org/wiki/columna#Latin
- columnīs, pl, f, ablativus,
- columnae, pl, f, vocātīvus,
- dēsīderiīs, pl, n, vocātīvus,
Args:
caput (list): _description_
data (list): _description_
quaestio (str): _description_
data_referentibus (dict): Pre-loaded external referential data
Returns:
Tuple[list, list]: _description_
"""
# _ordo_novo = []
caput_novo = []
data_novis = []
quaestio_dict = {}
for index, item in enumerate(caput):
quaestio_dict[int(index)] = item

# print('pre quaestio_dict', quaestio_dict)
for item in quaestio:
# print(item)
if item.find(':') == -1:
raise SyntaxError('{0} ":" et <{1}>?? <{2}>'.format(
__name__, item, quaestio
))
_num, _hash = item.split(':')
if _num.lstrip('+-').isnumeric():
_num = int(_num)
else:
raise SyntaxError('{0} "numero" et <{1}> <{2}>?? <{3}>'.format(
__name__, _num, item, quaestio
))

quaestio_dict[int(_num)] = _hash
# print('post quaestio_dict', quaestio_dict)
# ordo_novo = set()
ordo_novo = []

# print(sorted(quaestio_dict.items(), key=lambda item: int(item[0])))
quaestio_dict_sorted = \
sorted(quaestio_dict.items(), key=lambda item: int(item[0]))

for index, item in quaestio_dict_sorted:
# print('quaestio_dict_sorted item', item)
if item in caput and caput.index(item) not in ordo_novo:
# print(item, caput.index(item))
ordo_novo.append(caput.index(item))

# print(' ordo_novo', ordo_novo)

# return [], [[]]
# for index in enumerate(ordo_novo):
for index in ordo_novo:
caput_novo.append(caput[index])

# print(caput)
# print(caput_novo)
# print(list(range(0, len(caput) -1)))
if caput_novo == caput:
# print('already equal. return same input')
return caput, data

for _, linea in enumerate(data):
linea_novae = []
for index in ordo_novo:
linea_novae.append(linea[index])
# linea_novae.extend(linea)
data_novis.append(linea_novae)

return caput_novo, data_novis


def hxltm_cum_columna(
caput: list, data: list, quaestio: str, data_referentibus: dict = None
) -> Tuple[list, list]:
Expand Down

0 comments on commit 56a2420

Please sign in to comment.