python-table-converter 0.2.11__tar.gz → 0.2.12__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.11 → python_table_converter-0.2.12}/PKG-INFO +1 -1
- {python_table_converter-0.2.11 → python_table_converter-0.2.12}/pyproject.toml +1 -1
- python_table_converter-0.2.12/table_converter/__init__.py +2 -0
- {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/config.py +52 -2
- {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/convert.py +10 -2
- python_table_converter-0.2.11/table_converter/__init__.py +0 -2
- {python_table_converter-0.2.11 → python_table_converter-0.2.12}/LICENSE +0 -0
- {python_table_converter-0.2.11 → python_table_converter-0.2.12}/README.md +0 -0
- {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/cli.py +0 -0
- {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/commands/convert_tables.py +0 -0
- {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/constants.py +0 -0
- {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/functions/assign_id.py +0 -0
- {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/functions/flatten.py +0 -0
- {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/functions/get_field_value.py +0 -0
- {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/functions/search_column_value.py +0 -0
- {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/functions/set_field_value.py +0 -0
{python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/config.py
RENAMED
|
@@ -24,8 +24,9 @@ class AssignIdConfig:
|
|
|
24
24
|
@dataclasses.dataclass
|
|
25
25
|
class FilterConfig:
|
|
26
26
|
field: str
|
|
27
|
-
operator: Literal['==', '!=', '>', '>=', '<', '<=']
|
|
28
|
-
value: str
|
|
27
|
+
operator: Literal['==', '!=', '>', '>=', '<', '<=', 'not-in']
|
|
28
|
+
#value: str
|
|
29
|
+
value: str | list[str]
|
|
29
30
|
|
|
30
31
|
@dataclasses.dataclass
|
|
31
32
|
class SplitConfig:
|
|
@@ -87,6 +88,7 @@ def setup_process_config(
|
|
|
87
88
|
if isinstance(dict_subprocess, Mapping):
|
|
88
89
|
config.process[process_key] = flatten(loaded['process'][process_key])
|
|
89
90
|
setup_process_assign_ids_config(config, dict_process)
|
|
91
|
+
setup_process_filter_config(config, dict_process)
|
|
90
92
|
setup_process_split_config(config, dict_process)
|
|
91
93
|
|
|
92
94
|
def setup_process_assign_ids_config(
|
|
@@ -126,6 +128,54 @@ def setup_process_assign_ids_config(
|
|
|
126
128
|
f'Unsupported assign_ids value type: {type(value)}'
|
|
127
129
|
)
|
|
128
130
|
|
|
131
|
+
def setup_process_filter_config(
|
|
132
|
+
config: Config,
|
|
133
|
+
dict_process: Mapping,
|
|
134
|
+
):
|
|
135
|
+
list_subprocess = dict_process.get('filter')
|
|
136
|
+
if not isinstance(list_subprocess, list):
|
|
137
|
+
raise ValueError(
|
|
138
|
+
'Filter must be a list.'
|
|
139
|
+
)
|
|
140
|
+
for item in list_subprocess:
|
|
141
|
+
if isinstance(item, Mapping):
|
|
142
|
+
field = item.get('field')
|
|
143
|
+
if not field:
|
|
144
|
+
ic.enable()
|
|
145
|
+
ic(item)
|
|
146
|
+
ic(item.get('field'))
|
|
147
|
+
raise ValueError(
|
|
148
|
+
'Field is required for filter.'
|
|
149
|
+
)
|
|
150
|
+
operator = item.get('operator')
|
|
151
|
+
if not operator:
|
|
152
|
+
ic.enable()
|
|
153
|
+
ic(item)
|
|
154
|
+
ic(item.get('operator'))
|
|
155
|
+
raise ValueError(
|
|
156
|
+
'Operator is required for filter.'
|
|
157
|
+
)
|
|
158
|
+
value = item.get('value')
|
|
159
|
+
if not value:
|
|
160
|
+
ic.enable()
|
|
161
|
+
ic(item)
|
|
162
|
+
ic(item.get('value'))
|
|
163
|
+
raise ValueError(
|
|
164
|
+
'Value is required for filter.'
|
|
165
|
+
)
|
|
166
|
+
config.process.filter.append(FilterConfig(
|
|
167
|
+
field = field,
|
|
168
|
+
operator = operator,
|
|
169
|
+
value = value,
|
|
170
|
+
))
|
|
171
|
+
else:
|
|
172
|
+
ic.enable()
|
|
173
|
+
ic(item)
|
|
174
|
+
ic(type(item))
|
|
175
|
+
raise ValueError(
|
|
176
|
+
f'Unsupported filter item type: {type(item)}'
|
|
177
|
+
)
|
|
178
|
+
|
|
129
179
|
def setup_process_split_config(
|
|
130
180
|
config: Config,
|
|
131
181
|
dict_process: Mapping,
|
{python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/convert.py
RENAMED
|
@@ -221,11 +221,19 @@ def filter_row(
|
|
|
221
221
|
if config.operator == '==':
|
|
222
222
|
if not found:
|
|
223
223
|
return False
|
|
224
|
-
if str(value) != str(config.value):
|
|
224
|
+
if value != config.value and str(value) != str(config.value):
|
|
225
225
|
return False
|
|
226
226
|
elif config.operator == '!=':
|
|
227
|
-
if str(value) == str(config.value):
|
|
227
|
+
if str(value) == str(config.value) or value == config.value:
|
|
228
228
|
return False
|
|
229
|
+
elif config.operator == 'not-in':
|
|
230
|
+
if isinstance(config.value, list):
|
|
231
|
+
if value in config.value:
|
|
232
|
+
return False
|
|
233
|
+
if str(value) in config.value:
|
|
234
|
+
return False
|
|
235
|
+
else:
|
|
236
|
+
raise ValueError(f'Unsupported filter value type: type{config.value}')
|
|
229
237
|
else:
|
|
230
238
|
raise ValueError(f'Unsupported operator: {config.operator}')
|
|
231
239
|
return True
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/constants.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|