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.
Files changed (16) hide show
  1. {python_table_converter-0.2.11 → python_table_converter-0.2.12}/PKG-INFO +1 -1
  2. {python_table_converter-0.2.11 → python_table_converter-0.2.12}/pyproject.toml +1 -1
  3. python_table_converter-0.2.12/table_converter/__init__.py +2 -0
  4. {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/config.py +52 -2
  5. {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/convert.py +10 -2
  6. python_table_converter-0.2.11/table_converter/__init__.py +0 -2
  7. {python_table_converter-0.2.11 → python_table_converter-0.2.12}/LICENSE +0 -0
  8. {python_table_converter-0.2.11 → python_table_converter-0.2.12}/README.md +0 -0
  9. {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/cli.py +0 -0
  10. {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/commands/convert_tables.py +0 -0
  11. {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/constants.py +0 -0
  12. {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/functions/assign_id.py +0 -0
  13. {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/functions/flatten.py +0 -0
  14. {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/functions/get_field_value.py +0 -0
  15. {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/functions/search_column_value.py +0 -0
  16. {python_table_converter-0.2.11 → python_table_converter-0.2.12}/table_converter/core/functions/set_field_value.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-table-converter
3
- Version: 0.2.11
3
+ Version: 0.2.12
4
4
  Summary: A table data converter
5
5
  Home-page: https://github.com/akivajp/python-table-converter
6
6
  License: MIT
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "python-table-converter"
3
- version = "0.2.11"
3
+ version = "0.2.12"
4
4
  description = "A table data converter"
5
5
  authors = ["Akiva Miura <akiva.miura@gmail.com>"]
6
6
  license = "MIT"
@@ -0,0 +1,2 @@
1
+ __version__ = "0.2.12"
2
+ __version_tuple__ = (0, 2, 12)
@@ -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,
@@ -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
@@ -1,2 +0,0 @@
1
- __version__ = "0.2.11"
2
- __version_tuple__ = (0, 2, 11)