osducli 0.0.51__py3-none-any.whl → 0.0.53__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.
osducli/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.51
1
+ 0.0.53
osducli/click_cli.py CHANGED
@@ -187,6 +187,15 @@ def global_params(func):
187
187
  return wrapper
188
188
 
189
189
 
190
+ def _apply_jmespath(result, jmes):
191
+ try:
192
+ query_expression = compile_jmespath(jmes)
193
+ return query_expression.search(result, Options(collections.OrderedDict))
194
+ except KeyError as ex:
195
+ # Raise a ValueError which argparse can handle
196
+ raise ValueError from ex
197
+
198
+
190
199
  def command_with_output(table_transformer=None):
191
200
  """Handle global parameters setting to setup state and remove parameters from those passed
192
201
  to the decorated function call."""
@@ -227,18 +236,13 @@ def command_with_output(table_transformer=None):
227
236
  result = func(*args, **kwargs)
228
237
  if result is not None:
229
238
  if type(result) in [dict, list]:
230
- if state.jmes is not None or (
231
- table_transformer is not None and state.output is None
232
- ):
233
- jmes = state.jmes if state.jmes is not None else table_transformer
234
- try:
235
- query_expression = compile_jmespath(jmes)
236
- result = query_expression.search(
237
- result, Options(collections.OrderedDict)
238
- )
239
- except KeyError as ex:
240
- # Raise a ValueError which argparse can handle
241
- raise ValueError from ex
239
+ transformer = table_transformer
240
+ if callable(transformer):
241
+ transformer = transformer(*args, **kwargs)
242
+
243
+ if state.jmes is not None or (transformer is not None and state.output is None):
244
+ jmes = state.jmes if state.jmes is not None else transformer
245
+ result = _apply_jmespath(result, jmes)
242
246
 
243
247
  if state.output == "json":
244
248
  print(json.dumps(result, indent=2))
@@ -18,6 +18,15 @@ from osdu_api.model.search.query_request import QueryRequest
18
18
  from osducli.click_cli import CustomClickCommand, State, command_with_output
19
19
  from osducli.cliclient import CliOsduClient, handle_cli_exceptions
20
20
 
21
+ QUERY_JMESPATH_EXPRESSION = "results[*].{Id:id,Kind:kind,CreateTime:createTime}"
22
+ AGGREGATE_JMESPATH_EXPRESSION = "sort_by(aggregations,&key)[*].{Key:key,Count:count}"
23
+
24
+
25
+ def _default_query_jmespath(*args, **kwargs):
26
+ aggregate = kwargs.get("_aggr")
27
+ if aggregate is None and len(args) >= 6:
28
+ aggregate = args[5]
29
+ return AGGREGATE_JMESPATH_EXPRESSION if aggregate else QUERY_JMESPATH_EXPRESSION
21
30
 
22
31
  # click entry point
23
32
  @click.command(cls=CustomClickCommand)
@@ -34,7 +43,7 @@ from osducli.cliclient import CliOsduClient, handle_cli_exceptions
34
43
  )
35
44
  @click.option("-a", "--aggregate", "_aggr", help="Aggregate by element", required=False)
36
45
  @handle_cli_exceptions
37
- @command_with_output("results[*].{Id:id,Kind:kind,CreateTime:createTime}")
46
+ @command_with_output(_default_query_jmespath)
38
47
  def _click_command(state: State, kind: str, _id: str, _query: str, limit: int, _aggr: str):
39
48
  """Search using more advanced query terms"""
40
49
  return query(state, kind, _id, _query, limit, _aggr)
@@ -1,8 +1,8 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: osducli
3
- Version: 0.0.51
3
+ Version: 0.0.53
4
4
  Summary: OSDU command line
5
- Author-email: Equinor ASA <mhew@equinor.com>
5
+ Author: OSDU Community
6
6
  License-Expression: Apache-2.0
7
7
  Project-URL: homepage, https://community.opengroup.org/osdu/platform/data-flow/data-loading/osdu-cli
8
8
  Project-URL: issue-tracker, https://community.opengroup.org/osdu/platform/data-flow/data-loading/osdu-cli/-/issues
@@ -11,7 +11,7 @@ Classifier: Development Status :: 3 - Alpha
11
11
  Classifier: Environment :: Console
12
12
  Classifier: Natural Language :: English
13
13
  Classifier: Programming Language :: Python :: 3.13
14
- Requires-Python: >=3.12
14
+ Requires-Python: >=3.13
15
15
  Description-Content-Type: text/x-rst
16
16
  License-File: LICENSE.md
17
17
  Requires-Dist: click
@@ -75,6 +75,14 @@ For more information, specify the `-h` flag:
75
75
  Change Log
76
76
  ==========
77
77
 
78
+ 0.0.53
79
+ ------
80
+ - Fix json formatting for search query command
81
+
82
+ 0.0.52
83
+ ------
84
+ - Fix result for aggregate in search command
85
+
78
86
  0.0.51
79
87
  ------
80
88
  - Get record version command
@@ -1,7 +1,7 @@
1
- osducli/VERSION,sha256=pKLYb8I7W-9_9iuPirYhJ9jzAkpo28gEuYMDA0g7API,6
1
+ osducli/VERSION,sha256=EvrjPj9Un2g-BN93GmiTlrqsVf4F7bokReAVfyALC3g,6
2
2
  osducli/__init__.py,sha256=J3RwqAbN7MWvz8vL24fMUar9Sfk8nMI8xq_aSHGXUy8,591
3
3
  osducli/__main__.py,sha256=4HonhahSaS3Un0f93qnbs_pmJ5pbbVHU-qdhsssVkB0,3661
4
- osducli/click_cli.py,sha256=EIe42DOnHDRKU3mPGwT12jI-yX3hsBOp_nS4nMTWc_Y,10864
4
+ osducli/click_cli.py,sha256=0lZeUAeoJ2MbgWu_nJP7inr16ceUKRo382J4KcoZxPI,10888
5
5
  osducli/cliclient.py,sha256=u1pF5wYK1OmboGQld6cLsVXsSr0Fau000dZjvsW-yK0,13872
6
6
  osducli/config.py,sha256=OSsUK2UNiEYL_ikpAKkJhpodxMYMw39mEhav5IoUfRo,7873
7
7
  osducli/log.py,sha256=a5pzV2QIOqFEWCGFj01FaZk9PEzMkAr6duHei_dCme8,1549
@@ -70,7 +70,7 @@ osducli/commands/search/_const.py,sha256=YYTZd35Z9O0gEf6kb9Ntonvv3qArkAcszKAq2VA
70
70
  osducli/commands/search/id.py,sha256=1tVbgpDRhW08gyaLfQbCZjFrQDUGPh8gupf7pNhiN6c,1909
71
71
  osducli/commands/search/info.py,sha256=j6cjYDbxiiQEKXs0LJGQ_0scKReCGi6iQJrfn2X0B20,1333
72
72
  osducli/commands/search/kind.py,sha256=9vGVp4QG4dTII4LGcLYKDAE2PmcB-isgiCfwiITVauU,1786
73
- osducli/commands/search/query.py,sha256=nZkOyhz0dTKEHCvICkyeEkfph4Wd6O_p51GTzJg1lEY,2606
73
+ osducli/commands/search/query.py,sha256=GMOr2Lug_6nehKeQ8GeyUzcPWION-Vb11VKaoL_u7Vs,2986
74
74
  osducli/commands/status/__init__.py,sha256=5g1PB_tU0sqP7aplnihjfhMzVVQdlB3Y01QIeHAtSMw,595
75
75
  osducli/commands/status/status.py,sha256=yh6KVUpNYbrLJIH-7GjMyo2MpR8Wvycr4KdkxUI1V5A,4543
76
76
  osducli/commands/storage/__init__.py,sha256=Ilc97Kje3VVLZIBJucd_2jsW1GF5En00xF-A6kiLAFM,585
@@ -236,9 +236,9 @@ osducli/util/file.py,sha256=kfh6SLOI7X54gZ0hWF3kQ1npXPylNYgE1d1_w-fFyr0,1821
236
236
  osducli/util/prompt.py,sha256=0i3eNnxOHRQstvsvfiKnN0lIxXu6sEXIcU8txeYRhNs,7492
237
237
  osducli/util/pypi.py,sha256=-DW5CThkKKiOwLp2tg85BmrLKZzkMI9pu8DyWNPZH6E,1192
238
238
  osducli/util/service_info.py,sha256=YsVvoRoeG1osFjql2AgVkGoj1TePuhBZf3CQXl2a9As,2577
239
- osducli-0.0.51.dist-info/licenses/LICENSE.md,sha256=9xnGPjJkOAgd0kH4QLlvOIYKqY1M49gWUQpoUxAU-9Y,12788
240
- osducli-0.0.51.dist-info/METADATA,sha256=QUUwGY12jCAaYkGbOiLNJjS0IniEkQS_sQ_aSe0Z9xM,6326
241
- osducli-0.0.51.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
242
- osducli-0.0.51.dist-info/entry_points.txt,sha256=gASIcihV0BSJDZOUK-zTzb8RiccZCvKfVZMna9RsEIg,47
243
- osducli-0.0.51.dist-info/top_level.txt,sha256=lqiP5fuyH8lx7c2emYoIVZNxZAPX-bSwnMH789wxUAY,8
244
- osducli-0.0.51.dist-info/RECORD,,
239
+ osducli-0.0.53.dist-info/licenses/LICENSE.md,sha256=9xnGPjJkOAgd0kH4QLlvOIYKqY1M49gWUQpoUxAU-9Y,12788
240
+ osducli-0.0.53.dist-info/METADATA,sha256=yJog5mj33V7yYD0nrnpGDd7Rqk-el22HNuQ00iEGRyw,6426
241
+ osducli-0.0.53.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
242
+ osducli-0.0.53.dist-info/entry_points.txt,sha256=gASIcihV0BSJDZOUK-zTzb8RiccZCvKfVZMna9RsEIg,47
243
+ osducli-0.0.53.dist-info/top_level.txt,sha256=lqiP5fuyH8lx7c2emYoIVZNxZAPX-bSwnMH789wxUAY,8
244
+ osducli-0.0.53.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5