python-table-converter 0.2.2__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.2 → python_table_converter-0.2.4}/PKG-INFO +1 -1
- {python_table_converter-0.2.2 → 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.2 → python_table_converter-0.2.4}/table_converter/core/config.py +2 -1
- {python_table_converter-0.2.2 → python_table_converter-0.2.4}/table_converter/core/convert.py +7 -10
- python_table_converter-0.2.2/table_converter/__init__.py +0 -2
- {python_table_converter-0.2.2 → python_table_converter-0.2.4}/LICENSE +0 -0
- {python_table_converter-0.2.2 → python_table_converter-0.2.4}/README.md +0 -0
- {python_table_converter-0.2.2 → python_table_converter-0.2.4}/table_converter/cli.py +0 -0
- {python_table_converter-0.2.2 → python_table_converter-0.2.4}/table_converter/commands/convert_tables.py +0 -0
{python_table_converter-0.2.2 → 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.2 → python_table_converter-0.2.4}/table_converter/core/convert.py
RENAMED
|
@@ -251,28 +251,24 @@ def convert(
|
|
|
251
251
|
ic()
|
|
252
252
|
ic(input_files)
|
|
253
253
|
df_list = []
|
|
254
|
-
dict_constants: OrderedDict | None = None
|
|
255
|
-
dict_formats: OrderedDict | None = None
|
|
256
254
|
dict_assign_ids= None
|
|
257
255
|
root_id_stat = create_id_stat_node()
|
|
258
256
|
config = setup_config(config_path)
|
|
259
257
|
ic(config)
|
|
260
258
|
if assign_constants:
|
|
261
|
-
dict_constants = OrderedDict()
|
|
262
259
|
fields = assign_constants.split(',')
|
|
263
260
|
for field in fields:
|
|
264
261
|
if '=' in field:
|
|
265
262
|
dst, src = field.split('=')
|
|
266
|
-
|
|
263
|
+
config.process.assign_constants[dst] = src
|
|
267
264
|
else:
|
|
268
265
|
raise ValueError(f'Invalid constant assignment: {field}')
|
|
269
266
|
if assign_formats:
|
|
270
|
-
dict_formats = OrderedDict()
|
|
271
267
|
fields = assign_formats.split(',')
|
|
272
268
|
for field in fields:
|
|
273
269
|
if '=' in field:
|
|
274
270
|
dst, src = field.split('=')
|
|
275
|
-
|
|
271
|
+
config.process.assign_formats[dst] = src
|
|
276
272
|
else:
|
|
277
273
|
raise ValueError(f'Invalid template assignment: {field}')
|
|
278
274
|
if pickup_columns:
|
|
@@ -306,6 +302,7 @@ def convert(
|
|
|
306
302
|
raise ValueError(f'Unsupported file type: {ext}')
|
|
307
303
|
saver = dict_savers[ext]
|
|
308
304
|
ic(config)
|
|
305
|
+
#return # debug return
|
|
309
306
|
for input_file in input_files:
|
|
310
307
|
ic(input_file)
|
|
311
308
|
if not os.path.exists(input_file):
|
|
@@ -327,16 +324,16 @@ def convert(
|
|
|
327
324
|
new_row = OrderedDict(row)
|
|
328
325
|
set_field_value(new_row, '__debug__.__original__', orig)
|
|
329
326
|
set_field_value(new_row, '__debug__.__file__', input_file)
|
|
330
|
-
if
|
|
331
|
-
new_row = map_constants(new_row,
|
|
327
|
+
if config.process.assign_constants:
|
|
328
|
+
new_row = map_constants(new_row, config.process.assign_constants)
|
|
332
329
|
if config.map:
|
|
333
330
|
new_row = remap_columns(new_row, config.map)
|
|
334
331
|
if config.process.split_by_newline:
|
|
335
332
|
new_row = apply_fields_split_by_newline(new_row, config.process.split_by_newline)
|
|
336
333
|
if dict_assign_ids:
|
|
337
334
|
new_row = assign_id(new_row, dict_assign_ids, root_id_stat)
|
|
338
|
-
if
|
|
339
|
-
new_row = map_formats(new_row,
|
|
335
|
+
if config.process.assign_formats:
|
|
336
|
+
new_row = map_formats(new_row, config.process.assign_formats)
|
|
340
337
|
if config.map:
|
|
341
338
|
new_row = remap_columns(new_row, config.map)
|
|
342
339
|
if not output_debug:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|