Skip to content

Commit

Permalink
999999999_7200235.py (#45) --methodus= wdata_adm0 & cod_ab_et_wdata (…
Browse files Browse the repository at this point in the history
…drafts)
  • Loading branch information
fititnt committed Jul 19, 2022
1 parent 53cec35 commit 8baa986
Showing 1 changed file with 69 additions and 5 deletions.
74 changes: 69 additions & 5 deletions officina/999999999/0/999999999_7200235.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import sys
import os
import argparse
import csv
# import csv
# import re
from pathlib import Path
from os.path import exists
Expand Down Expand Up @@ -132,6 +132,12 @@
{0} --methodus='cod_ab_index_levels' --sine-capite \
--cum-columnis='#item+conceptum+numerordinatio'
Work with WDATA ADM0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
{0} --methodus='wdata_adm0'
Work with local COD AB + WDATA ADM0 . . . . . . . . . . . . . . . . . . . . . .
{0} --methodus='cod_ab_et_wdata' --numerordinatio-praefixo='1603_16'
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 @@ -203,6 +209,9 @@
COD_AB_INDEX = NUMERORDINATIO_BASIM + \
'/999999/1603/45/16/1603_45_16.index.hxl.csv'

WDATA_ADM0 = NUMERORDINATIO_BASIM + \
'/999999/1603/3/45/16/1/1/1603_3_45_16_1_1.tm.hxl.csv'

# autopep8 --list-fixes ./999999999/0/999999999_7200235.py
# pylint --disable=W0511,C0103,C0116 ./999999999/0/999999999_7200235.py

Expand Down Expand Up @@ -262,6 +271,7 @@ def make_args(self, hxl_output=True):
choices=[
# 'pcode_ex_xlsx',
# 'pcode_ex_csv',
'cod_ab_et_wdata',
'cod_ab_index',
'cod_ab_index_levels',
'cod_ab_index_levels_ttl',
Expand All @@ -270,6 +280,7 @@ def make_args(self, hxl_output=True):
'de_hxltm_ad_hxltm', # load main file directly
# load main file by number (example: 1603_45_49)
'de_librario',
'wdata_adm0',
'xlsx_metadata',
'xlsx_ad_csv',
'xlsx_ad_hxl',
Expand Down Expand Up @@ -660,7 +671,8 @@ def execute_cli(self, pyargs, stdin=STDIN, _stdout=sys.stdout,
if pyargs.methodus in [
'de_hxltm_ad_hxltm', 'de_librario',
'index_praeparationi', 'cod_ab_index', 'cod_ab_ad_no1_csv',
'cod_ab_index_levels', 'cod_ab_index_levels_ttl']:
'cod_ab_index_levels', 'cod_ab_index_levels_ttl',
'wdata_adm0', 'cod_ab_et_wdata']:
# Decide which main file to load.
# if pyargs.methodus.startswith('de_librario'):
if pyargs.methodus.startswith(
Expand All @@ -676,6 +688,27 @@ def execute_cli(self, pyargs, stdin=STDIN, _stdout=sys.stdout,
caput, data = hxltm_carricato(_infile, _stdin)
elif pyargs.methodus.startswith('cod_ab_index'):
caput, data = hxltm_carricato(COD_AB_INDEX)
elif pyargs.methodus.startswith('cod_ab_et_wdata'):
caput, data = hxltm_carricato(COD_AB_INDEX)
elif pyargs.methodus.startswith('wdata_adm0'):
caput, data = hxltm_carricato(WDATA_ADM0)

# # if pyargs.methodus == 'cod_ab_index_levels':
if pyargs.methodus == 'cod_ab_et_wdata':
# print("Foi")
# @TODO cod_ab_index_levels
# caput, data = hxltm_carricato(COD_AB_INDEX)
# raise NotImplementedError(pyargs.methodus)
caput_cod, data_cod = hxltm_carricato__cod_ab_levels(
caput, data,
numerordinatio_praefixo=numerordinatio_praefixo,
no1_simplici=True, cod_ab_level__inline=True)

caput_wdata, data_wdata = hxltm_carricato(WDATA_ADM0)

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

# if pyargs.methodus == 'cod_ab_index_levels':
if pyargs.methodus == 'cod_ab_index_levels':
Expand All @@ -692,8 +725,7 @@ def execute_cli(self, pyargs, stdin=STDIN, _stdout=sys.stdout,
# raise NotImplementedError(pyargs.methodus)
caput, data = hxltm_carricato__cod_ab_levels(
caput, data,
numerordinatio_praefixo=numerordinatio_praefixo,
no1_simplici=True)
numerordinatio_praefixo=numerordinatio_praefixo)

if pyargs.methodus == 'cod_ab_index_levels_ttl':
paginae = hxltm_carricato__cod_ab_levels_ttl(
Expand Down Expand Up @@ -1071,9 +1103,19 @@ def actio(self):
# print('failed')


def hxltm_carricato__cod_ab_levels(
def hxltm_carricato__cod_ab_et_wdata(
caput: list, data: list, numerordinatio_praefixo: str = '1603_45_16',
no1_simplici: bool = False
) -> Tuple[list, list]:
# @TODO finish this draft
caput_novo = caput
data_novis = data
return caput_novo, data_novis


def hxltm_carricato__cod_ab_levels(
caput: list, data: list, numerordinatio_praefixo: str = '1603_45_16',
no1_simplici: bool = False, cod_ab_level__inline: bool = False
) -> Tuple[list, list]:
"""hxltm_carricato__cod_ab_levels filter cod_ab_index into a list of levels
Expand Down Expand Up @@ -1119,6 +1161,28 @@ def hxltm_carricato__cod_ab_levels(
_numerordinatio__done = []

for linea in data:

if cod_ab_level__inline:
_cod_ab_level = []
for cod_ab_level in range(0, (int(linea[1]) + 1)):
_cod_ab_level.append(str(cod_ab_level))
_cod_ab_level_str = '|'.join(_cod_ab_level)
linea_novae = []
numerordinatio = '{0}:{1}'.format(
numerordinatio_praefixo, linea[0]
)
_numerordinatio__done.append(numerordinatio)
linea_novae.append(numerordinatio)
if no1_simplici:
linea_novae.append(linea[0])
linea_novae.append(linea[0])
linea_novae.append(_cod_ab_level_str)
linea_novae.append(linea[2])
linea_novae.append(linea[3])
# linea_novae.extend(linea)
data_novis.append(linea_novae)
continue

# for cod_ab_level in range(0, int(linea[1])):
for cod_ab_level in range(0, (int(linea[1]) + 1)):
linea_novae = []
Expand Down

0 comments on commit 8baa986

Please sign in to comment.