udata-hydra-csvapi 0.4.3.dev4__py3-none-any.whl → 0.4.3.dev5__py3-none-any.whl

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.
api_tabular/core/query.py CHANGED
@@ -163,35 +163,20 @@ def split_top_level(s: str) -> list[str]:
163
163
 
164
164
 
165
165
  def find_arg_val(param: str) -> tuple[str, str]:
166
- if param.count('"') not in {0, 2, 4}:
167
- raise ValueError(f"argument '{param}' could not be parsed")
168
- column_operator_pattern = r'^"[^"]*"__[a-z]+'
169
- value_pattern = r'\."[^"]*"$'
170
- if param.count('"') == 0:
171
- # no quote, we expect col__op.val
172
- _split = param.split(".")
173
- if len(_split) != 2:
174
- raise ValueError(f"argument '{param}' could not be parsed")
175
- return tuple[str, str](_split) # ty: ignore[invalid-argument-type]
176
- elif param.count('"') == 4:
177
- # 4 quotes, we expect "col.umn"__op."val.ue"
178
- col_op = re.findall(column_operator_pattern, param)
179
- val = re.findall(value_pattern, param)
180
- if len(col_op) != 1 or len(val) != 1:
181
- raise ValueError(f"argument '{param}' could not be parsed")
166
+ # the operator is not checked here, add_filter validates it like for unquoted columns
167
+ quoted_column = re.match(r'^"([^"]*)"__', param)
168
+ if quoted_column:
182
169
  # we drop the double quotes around the column as they will be added back in get_column_and_operator
183
- # the dot is included in the value result, we pop it in the result
184
- return col_op[0].replace('"', ""), val[0][1:]
170
+ column_prefix = f"{quoted_column.group(1)}__"
171
+ operator_value = param[quoted_column.end() :]
185
172
  else:
186
- # we have any of "col.umn"__op.val, col__op."val.ue"
187
- col_op = re.findall(column_operator_pattern, param)
188
- val = re.findall(value_pattern, param)
189
- if not col_op:
190
- # case col__op."val.ue"
191
- return param.split(".")[0], val[0][1:]
192
- else:
193
- # case "col.umn"__op.val
194
- return col_op[0].replace('"', ""), param.split(".")[-1]
173
+ column_prefix, operator_value = "", param
174
+ operator, dot, value = operator_value.partition(".")
175
+ # a quoted value is kept as is, an unquoted one can't contain a dot
176
+ value_is_valid = re.fullmatch(r'"[^"]*"', value) or not re.search(r'[".]', value)
177
+ if not dot or '"' in operator or not value_is_valid:
178
+ raise ValueError(f"argument '{param}' could not be parsed")
179
+ return column_prefix + operator, value
195
180
 
196
181
 
197
182
  def parse_operator(query: str, operator: str, top_level: bool = False):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: udata-hydra-csvapi
3
- Version: 0.4.3.dev4
3
+ Version: 0.4.3.dev5
4
4
  Summary: API for CSV converted by udata-hydra
5
5
  Author-email: "data.gouv.fr" <opendatateam@data.gouv.fr>
6
6
  License-Expression: MIT
@@ -5,7 +5,7 @@ api_tabular/core/cors.py,sha256=xX4qSbv06pVT-NrohQlysFPSR9z7Pj2THz18TCbvJ90,1707
5
5
  api_tabular/core/data.py,sha256=5j-3d_el7LMoHpn6V__UdhYHD6GiJbwdH67jrnOYWZQ,1459
6
6
  api_tabular/core/error.py,sha256=xRt6fkQfsiupv0tWWzdX0DJjAKbw1n0tRxFyt15VBLA,1062
7
7
  api_tabular/core/health.py,sha256=NeFT1C00onvm3CbgesFAcN1N8bmelbQdEYFbmmftICQ,647
8
- api_tabular/core/query.py,sha256=J7woFLDzA8RpMBXJKpKm8olDdZsp2_TQEROJtIaeokM,10238
8
+ api_tabular/core/query.py,sha256=Qf34vtzt_kPJBYIrHX2QsV-K3ADrbDeLeb8xC__cs-k,9616
9
9
  api_tabular/core/sentry.py,sha256=fN5MrDZszLnzLXF3b_nUymPVB0ffNn4PI7xS1GtJNyE,948
10
10
  api_tabular/core/swagger.py,sha256=mMEESM4UlgK-voyRTKrddVuUrlUMfTDOQtK1VrVp7Ak,14748
11
11
  api_tabular/core/url.py,sha256=af7VKfrMtKMzlHrGgtLDLuRBim4qFv7xlt2PYxAyW2g,761
@@ -16,8 +16,8 @@ api_tabular/metrics/app.py,sha256=W2htxUO54bTfQLReJhEY3JtsbLWaefC71DmjV9SvUII,42
16
16
  api_tabular/tabular/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
17
  api_tabular/tabular/app.py,sha256=6lwujb2Pf_70QQlTKL8bhQTnhYinRyDlF_yTdit0pQw,6528
18
18
  api_tabular/tabular/utils.py,sha256=BL2nl04-3imBQG-RZiYvVMjxoBORi4lwrKq8NiWecLY,4487
19
- udata_hydra_csvapi-0.4.3.dev4.dist-info/licenses/LICENSE,sha256=fb-HAYw94ffh--z1cZrWbpk6YKM0p9WFG7kdd0K7uGQ,1062
20
- udata_hydra_csvapi-0.4.3.dev4.dist-info/METADATA,sha256=h571GAbAb6UrNwO_O4SZbMMmvpId-1FdiVM0s_NRyw8,21835
21
- udata_hydra_csvapi-0.4.3.dev4.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
22
- udata_hydra_csvapi-0.4.3.dev4.dist-info/top_level.txt,sha256=MAaK09hxwPhIBBC0i1TdEBAgdu3W_gXnAZqk767gVak,12
23
- udata_hydra_csvapi-0.4.3.dev4.dist-info/RECORD,,
19
+ udata_hydra_csvapi-0.4.3.dev5.dist-info/licenses/LICENSE,sha256=fb-HAYw94ffh--z1cZrWbpk6YKM0p9WFG7kdd0K7uGQ,1062
20
+ udata_hydra_csvapi-0.4.3.dev5.dist-info/METADATA,sha256=2VEJANlzoHtKJt5iU3MCEw1H-jPyirRWHCreKOTFDHg,21835
21
+ udata_hydra_csvapi-0.4.3.dev5.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
22
+ udata_hydra_csvapi-0.4.3.dev5.dist-info/top_level.txt,sha256=MAaK09hxwPhIBBC0i1TdEBAgdu3W_gXnAZqk767gVak,12
23
+ udata_hydra_csvapi-0.4.3.dev5.dist-info/RECORD,,