jsonata-python 0.6.0__py3-none-any.whl → 0.6.1__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.
jsonata/cli/__main__.py CHANGED
@@ -32,9 +32,9 @@ from jsonata import functions, jexception, jsonata, timebox
32
32
  def get_options(argv: Optional[list[str]] = None) -> argparse.ArgumentParser:
33
33
  """Parses command-line arguments.
34
34
  """
35
- parser = argparse.ArgumentParser(prog="jsonata.cli", description="Pure Python JSONata CLI")
35
+ parser = argparse.ArgumentParser(prog="jsonata", description="Pure Python JSONata CLI")
36
36
  parser.add_argument(
37
- "-v", "--version", action='version', version='%(prog)s 0.6.0')
37
+ "-v", "--version", action='version', version='%(prog)s 0.6.1')
38
38
 
39
39
  parser.add_argument(
40
40
  "-e", "--expression", metavar="<file>",
jsonata/functions.py CHANGED
@@ -2105,7 +2105,8 @@ class Functions:
2105
2105
  dt = datetime.datetime.strptime(timestamp, "%Y")
2106
2106
  else:
2107
2107
  dt = datetime.datetime.fromisoformat(timestamp)
2108
- dt = dt.replace(tzinfo=datetime.timezone.utc)
2108
+ if dt.tzinfo is None:
2109
+ dt = dt.replace(tzinfo=datetime.timezone.utc)
2109
2110
  return int(dt.timestamp() * 1000)
2110
2111
  # try:
2111
2112
  # size = len(timestamp)
jsonata/jsonata.py CHANGED
@@ -800,9 +800,9 @@ class Jsonata:
800
800
 
801
801
  result = None
802
802
  if op == "=":
803
- result = lhs == rhs # isDeepEqual(lhs, rhs);
803
+ result = utils.Utils.is_deep_equal(lhs, rhs)
804
804
  elif op == "!=":
805
- result = lhs != rhs # !isDeepEqual(lhs, rhs);
805
+ result = not utils.Utils.is_deep_equal(lhs, rhs)
806
806
  return result
807
807
 
808
808
  #
jsonata/utils.py CHANGED
@@ -90,6 +90,27 @@ class Utils:
90
90
  sequence.sequence = True
91
91
  return sequence
92
92
 
93
+ @staticmethod
94
+ def is_deep_equal(lhs: Optional[Any], rhs: Optional[Any]) -> bool:
95
+ if isinstance(lhs, list) and isinstance(rhs, list):
96
+ if len(lhs) != len(rhs):
97
+ return False
98
+ for ii, _ in enumerate(lhs):
99
+ if not Utils.is_deep_equal(lhs[ii], rhs[ii]):
100
+ return False
101
+ return True
102
+ elif isinstance(lhs, dict) and isinstance(rhs, dict):
103
+ if lhs.keys() != rhs.keys():
104
+ return False
105
+ for key in lhs.keys():
106
+ if not Utils.is_deep_equal(lhs[key], rhs[key]):
107
+ return False
108
+ return True
109
+ if lhs == rhs and type(lhs) == type(rhs):
110
+ return True
111
+
112
+ return False
113
+
93
114
  class JList(list):
94
115
  sequence: bool
95
116
  outer_wrapper: bool
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jsonata-python
3
- Version: 0.6.0
3
+ Version: 0.6.1
4
4
  Summary: Pure Python implementation of JSONata
5
5
  Project-URL: Homepage, https://github.com/rayokota/jsonata-python
6
6
  Project-URL: Bug Reports, https://github.com/rayokota/jsonata-python/issues
@@ -235,7 +235,7 @@ The JSONata documentation can be found [here](https://jsonata.org).
235
235
  ## Installation
236
236
 
237
237
  ```
238
- pip install jsonata-python
238
+ pipx install jsonata-python
239
239
  ```
240
240
 
241
241
  ## Getting Started
@@ -256,8 +256,8 @@ A very simple start:
256
256
  The CLI provides the same functionality as the [Dashjoin JSONata CLI](https://github.com/dashjoin/jsonata-cli).
257
257
 
258
258
  ```
259
- % python3 -m jsonata.cli
260
- usage: jsonata.cli [-h] [-v] [-e <file>] [-i <arg>] [-ic <arg>] [-f {auto,json,string}] [-o <arg>] [-oc <arg>] [-time] [-c] [-b <json-string>]
259
+ % jsonata -h
260
+ usage: jsonata [-h] [-v] [-e <file>] [-i <arg>] [-ic <arg>] [-f {auto,json,string}] [-o <arg>] [-oc <arg>] [-time] [-c] [-b <json-string>]
261
261
  [-bf <file>] [-it]
262
262
  [expr]
263
263
 
@@ -293,19 +293,19 @@ options:
293
293
  ### Examples
294
294
 
295
295
  ```
296
- % echo '{"a":"hello", "b":" world"}' | python3 -m jsonata.cli '(a & b)'
296
+ % echo '{"a":"hello", "b":" world"}' | jsonata '(a & b)'
297
297
  hello world
298
298
 
299
- % echo '{"a":"hello", "b":" world"}' | python3 -m jsonata.cli -o helloworld.json $
299
+ % echo '{"a":"hello", "b":" world"}' | jsonata -o helloworld.json $
300
300
  # helloworld.json written
301
301
 
302
- % ls | python3 -m jsonata.cli $
302
+ % ls | jsonata $
303
303
  helloworld.json
304
304
 
305
- % ps -o pid="",%cpu="",%mem="" | python3 -m jsonata.cli '$.$split(/\n/).$trim().[ $split(/\s+/)[$length()>0].$number() ]' -c
305
+ % ps -o pid="",%cpu="",%mem="" | jsonata '$.$split(/\n/).$trim().[ $split(/\s+/)[$length()>0].$number() ]' -c
306
306
  [[4105,0,0],[4646,0,0],[4666,0,0],[33696,0,0]...]
307
307
 
308
- % curl -s https://raw.githubusercontent.com/jsonata-js/jsonata/master/test/test-suite/datasets/dataset1.json | python3 -m jsonata.cli '{"Name": FirstName & " " & Surname, "Cities": **.City, "Emails": Email[type="home"].address}'
308
+ % curl -s https://raw.githubusercontent.com/jsonata-js/jsonata/master/test/test-suite/datasets/dataset1.json | jsonata '{"Name": FirstName & " " & Surname, "Cities": **.City, "Emails": Email[type="home"].address}'
309
309
  {
310
310
  "Name": "Fred Smith",
311
311
  "Cities": [
@@ -318,7 +318,7 @@ helloworld.json
318
318
  ]
319
319
  }
320
320
 
321
- % python3 -m jsonata.cli -i helloworld.json -it
321
+ % jsonata -i helloworld.json -it
322
322
  Enter an expression to have it evaluated.
323
323
  JSONata> (a & b)
324
324
  hello world
@@ -1,17 +1,18 @@
1
1
  jsonata/__init__.py,sha256=4r8USHj4SoBy_TD8dLxt9HJIgpLfXApFrZBipi4rgr0,388
2
2
  jsonata/constants.py,sha256=WtdH_l_s5KD-SiOJ4GR2az7WpVgKB2HguXUnyfy4tvs,3017
3
3
  jsonata/datetimeutils.py,sha256=IzU6y-vwyhwobHyw9rsImBye-RfWDV7K8Vk0Xs-yiG0,48567
4
- jsonata/functions.py,sha256=2vip5OJt8VMprF1vOnvr3iCQQlLGbfOItQ3MwDXzCTM,75691
4
+ jsonata/functions.py,sha256=it09GOcMOJ2XDlvh_yhf-bgABaHMTrUFhzXa0kUsrNk,75729
5
5
  jsonata/jexception.py,sha256=6Jz7WMsIiNlQ7-1Hq8RKiE2HxcHq2PDekw0qsSe3lqo,12885
6
- jsonata/jsonata.py,sha256=jZIxVrNcZI3aBvE0PURZ4-cxpaK9JiJVH5Q_cllCXS0,84247
6
+ jsonata/jsonata.py,sha256=YmLrus5eBOdcGIzV6nEzsFOkBRJvosE-3bjpdQZVISg,84248
7
7
  jsonata/parser.py,sha256=dzZ6PeM5l3scTHq4DzCXt4FSRO49yzYEk7XqspCcHNU,55359
8
8
  jsonata/signature.py,sha256=j7eNKUuGx_9vCt5Qv8BPM7iV5vH26U0Kx8zrkDcctME,20194
9
9
  jsonata/timebox.py,sha256=bnevNR_ONvKUiIZCJZEWsRiR0gCWTGOwn5RCY7dKqYc,2861
10
10
  jsonata/tokenizer.py,sha256=6noGxO1L_n2V-Uva5oV044Xx0p08Gm7-XXSfLEG4rR0,12429
11
- jsonata/utils.py,sha256=U13I49Ie3hEn3PKGR4361TPengDAkbyHmwipDFZJlXo,5192
11
+ jsonata/utils.py,sha256=WDs-z5JRJ5pUEpmAwUY3xgDFxEIsvTqZXp8UX6cNSpQ,5952
12
12
  jsonata/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- jsonata/cli/__main__.py,sha256=xfwJE5nkt6tYH__Zk1PQ_R0idkmQq1XcAKRFt3-bTEo,7125
14
- jsonata_python-0.6.0.dist-info/METADATA,sha256=m_Srw48y9PCRzQYzqZz6TJM7mU73pWddDhw9FXEGLOo,17442
15
- jsonata_python-0.6.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
- jsonata_python-0.6.0.dist-info/licenses/LICENSE,sha256=y16Ofl9KOYjhBjwULGDcLfdWBfTEZRXnduOspt-XbhQ,11325
17
- jsonata_python-0.6.0.dist-info/RECORD,,
13
+ jsonata/cli/__main__.py,sha256=x1cz-w1NYBb_UNJuDnwqmGaz1SdfHwpMjKXIz5GQG-A,7121
14
+ jsonata_python-0.6.1.dist-info/METADATA,sha256=lNCEnZXUk7pzV8kP9unZq0AVkNoB2ZngEPbdfiaoUO8,17337
15
+ jsonata_python-0.6.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
16
+ jsonata_python-0.6.1.dist-info/entry_points.txt,sha256=a-W2yyT3IPhcC1q12BhKPcWnjNi3NXTZ3ZxoI9_UK88,54
17
+ jsonata_python-0.6.1.dist-info/licenses/LICENSE,sha256=y16Ofl9KOYjhBjwULGDcLfdWBfTEZRXnduOspt-XbhQ,11325
18
+ jsonata_python-0.6.1.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.27.0
2
+ Generator: hatchling 1.28.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ jsonata = jsonata.cli.__main__:main