python-table-converter 0.2.3__tar.gz → 0.2.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_table_converter-0.2.3 → python_table_converter-0.2.4}/PKG-INFO +1 -1
- {python_table_converter-0.2.3 → python_table_converter-0.2.4}/pyproject.toml +1 -1
- python_table_converter-0.2.4/table_converter/__init__.py +2 -0
- {python_table_converter-0.2.3 → python_table_converter-0.2.4}/table_converter/core/config.py +2 -1
- {python_table_converter-0.2.3 → python_table_converter-0.2.4}/table_converter/core/convert.py +4 -5
- python_table_converter-0.2.3/table_converter/__init__.py +0 -2
- {python_table_converter-0.2.3 → python_table_converter-0.2.4}/LICENSE +0 -0
- {python_table_converter-0.2.3 → python_table_converter-0.2.4}/README.md +0 -0
- {python_table_converter-0.2.3 → python_table_converter-0.2.4}/table_converter/cli.py +0 -0
- {python_table_converter-0.2.3 → python_table_converter-0.2.4}/table_converter/commands/convert_tables.py +0 -0
{python_table_converter-0.2.3 → python_table_converter-0.2.4}/table_converter/core/config.py
RENAMED
|
@@ -13,6 +13,7 @@ type FieldMap = Mapping[str, str|FieldMap]
|
|
|
13
13
|
@dataclasses.dataclass
|
|
14
14
|
class ProcessConfig:
|
|
15
15
|
assign_constants: FlatFieldMap = dataclasses.field(default_factory=OrderedDict)
|
|
16
|
+
assign_formats: FlatFieldMap = dataclasses.field(default_factory=OrderedDict)
|
|
16
17
|
split_by_newline: FlatFieldMap = dataclasses.field(default_factory=OrderedDict)
|
|
17
18
|
|
|
18
19
|
def __setitem__(self, key, value):
|
|
@@ -57,11 +58,11 @@ def setup_config(
|
|
|
57
58
|
ic(loaded)
|
|
58
59
|
if 'map' in loaded:
|
|
59
60
|
config.map = flatten(loaded['map'])
|
|
60
|
-
#if 'process' in loaded:
|
|
61
61
|
dict_process = loaded.get('process')
|
|
62
62
|
if isinstance(dict_process, Mapping):
|
|
63
63
|
for process_key in [
|
|
64
64
|
'assign_constants',
|
|
65
|
+
'assign_formats',
|
|
65
66
|
'split_by_newline',
|
|
66
67
|
]:
|
|
67
68
|
dict_subprocess = dict_process.get(process_key)
|
{python_table_converter-0.2.3 → python_table_converter-0.2.4}/table_converter/core/convert.py
RENAMED
|
@@ -251,7 +251,6 @@ def convert(
|
|
|
251
251
|
ic()
|
|
252
252
|
ic(input_files)
|
|
253
253
|
df_list = []
|
|
254
|
-
dict_formats: OrderedDict | None = None
|
|
255
254
|
dict_assign_ids= None
|
|
256
255
|
root_id_stat = create_id_stat_node()
|
|
257
256
|
config = setup_config(config_path)
|
|
@@ -265,12 +264,11 @@ def convert(
|
|
|
265
264
|
else:
|
|
266
265
|
raise ValueError(f'Invalid constant assignment: {field}')
|
|
267
266
|
if assign_formats:
|
|
268
|
-
dict_formats = OrderedDict()
|
|
269
267
|
fields = assign_formats.split(',')
|
|
270
268
|
for field in fields:
|
|
271
269
|
if '=' in field:
|
|
272
270
|
dst, src = field.split('=')
|
|
273
|
-
|
|
271
|
+
config.process.assign_formats[dst] = src
|
|
274
272
|
else:
|
|
275
273
|
raise ValueError(f'Invalid template assignment: {field}')
|
|
276
274
|
if pickup_columns:
|
|
@@ -304,6 +302,7 @@ def convert(
|
|
|
304
302
|
raise ValueError(f'Unsupported file type: {ext}')
|
|
305
303
|
saver = dict_savers[ext]
|
|
306
304
|
ic(config)
|
|
305
|
+
#return # debug return
|
|
307
306
|
for input_file in input_files:
|
|
308
307
|
ic(input_file)
|
|
309
308
|
if not os.path.exists(input_file):
|
|
@@ -333,8 +332,8 @@ def convert(
|
|
|
333
332
|
new_row = apply_fields_split_by_newline(new_row, config.process.split_by_newline)
|
|
334
333
|
if dict_assign_ids:
|
|
335
334
|
new_row = assign_id(new_row, dict_assign_ids, root_id_stat)
|
|
336
|
-
if
|
|
337
|
-
new_row = map_formats(new_row,
|
|
335
|
+
if config.process.assign_formats:
|
|
336
|
+
new_row = map_formats(new_row, config.process.assign_formats)
|
|
338
337
|
if config.map:
|
|
339
338
|
new_row = remap_columns(new_row, config.map)
|
|
340
339
|
if not output_debug:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|