jsonata-python 0.5.1__py3-none-any.whl → 0.5.3__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
@@ -34,7 +34,7 @@ def get_options(argv: Optional[list[str]] = None) -> argparse.ArgumentParser:
34
34
  """
35
35
  parser = argparse.ArgumentParser(prog="jsonata.cli", description="Pure Python JSONata CLI")
36
36
  parser.add_argument(
37
- "-v", "--version", action='version', version='%(prog)s 0.5.1')
37
+ "-v", "--version", action='version', version='%(prog)s 0.5.3')
38
38
 
39
39
  parser.add_argument(
40
40
  "-e", "--expression", metavar="<file>",
@@ -54,7 +54,7 @@ def get_options(argv: Optional[list[str]] = None) -> argparse.ArgumentParser:
54
54
  )
55
55
  parser.add_argument(
56
56
  "-o", "--output", metavar="<arg>",
57
- help="JSON output file (- for stdin)"
57
+ help="JSON output file (default=stdout)"
58
58
  )
59
59
  parser.add_argument(
60
60
  "-oc", "--ocharset", default="utf-8", metavar="<arg>",
@@ -78,7 +78,7 @@ def get_options(argv: Optional[list[str]] = None) -> argparse.ArgumentParser:
78
78
  )
79
79
  parser.add_argument(
80
80
  "-it", "--interactive", default=False, action="store_true",
81
- help="Interactive REPL"
81
+ help="Interactive REPL (requires input file)"
82
82
  )
83
83
 
84
84
  # The expression
@@ -160,8 +160,9 @@ def main(argv: Optional[list[str]] = None) -> int:
160
160
  options = parser.parse_args(argv)
161
161
 
162
162
  if options.expression is None and options.expr is None:
163
- parser.print_help()
164
- return 1
163
+ if not options.interactive:
164
+ parser.print_help()
165
+ return 1
165
166
 
166
167
  icharset = options.icharset
167
168
  ocharset = options.icharset
@@ -187,6 +188,9 @@ def main(argv: Optional[list[str]] = None) -> int:
187
188
  bindings = json.loads(bindings_str)
188
189
 
189
190
  if options.input == '-' or options.input is None:
191
+ if options.interactive:
192
+ parser.print_help()
193
+ return 1
190
194
  input = sys.stdin.read()
191
195
  else:
192
196
  with open(options.input, 'r', encoding=icharset) as fd:
jsonata/tokenizer.py CHANGED
@@ -138,7 +138,10 @@ class Tokenizer:
138
138
  start = self.position
139
139
  while current_char == 'i' or current_char == 'm':
140
140
  self.position += 1
141
- current_char = self.path[self.position]
141
+ if self.position < self.length:
142
+ current_char = self.path[self.position]
143
+ else:
144
+ current_char = None
142
145
  flags = self.path[start:self.position] + 'g'
143
146
 
144
147
  # Convert flags to Java Pattern flags
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: jsonata-python
3
- Version: 0.5.1
3
+ Version: 0.5.3
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
@@ -207,6 +207,7 @@ License: Apache License
207
207
  See the License for the specific language governing permissions and
208
208
  limitations under the License.
209
209
 
210
+ License-File: LICENSE
210
211
  Keywords: json,jsonata
211
212
  Classifier: Development Status :: 4 - Beta
212
213
  Classifier: License :: OSI Approved :: Apache Software License
@@ -277,7 +278,7 @@ options:
277
278
  -f {auto,json,string}, --format {auto,json,string}
278
279
  Input format (default=auto)
279
280
  -o <arg>, --output <arg>
280
- JSON output file (- for stdin)
281
+ JSON output file (default=stdout)
281
282
  -oc <arg>, --ocharset <arg>
282
283
  Output character set (default=utf-8)
283
284
  -time Print performance timers to stderr
@@ -286,7 +287,7 @@ options:
286
287
  JSONata variable bindings
287
288
  -bf <file>, --bindings-file <file>
288
289
  JSONata variable bindings file
289
- -it, --interactive Interactive REPL
290
+ -it, --interactive Interactive REPL (requires input file)
290
291
  ```
291
292
 
292
293
  ### Examples
@@ -316,6 +317,11 @@ helloworld.json
316
317
  "frederic.smith@very-serious.com"
317
318
  ]
318
319
  }
320
+
321
+ % python3 -m jsonata.cli -i helloworld.json -it
322
+ Enter an expression to have it evaluated.
323
+ JSONata> (a & b)
324
+ hello world
319
325
  ```
320
326
 
321
327
  ## Running Tests
@@ -7,11 +7,11 @@ jsonata/jsonata.py,sha256=jZIxVrNcZI3aBvE0PURZ4-cxpaK9JiJVH5Q_cllCXS0,84247
7
7
  jsonata/parser.py,sha256=U8nNxvsDIy0wVTfNCs2DNN7RjNVm0SqfociD9cRcsWM,53877
8
8
  jsonata/signature.py,sha256=j7eNKUuGx_9vCt5Qv8BPM7iV5vH26U0Kx8zrkDcctME,20194
9
9
  jsonata/timebox.py,sha256=bnevNR_ONvKUiIZCJZEWsRiR0gCWTGOwn5RCY7dKqYc,2861
10
- jsonata/tokenizer.py,sha256=6WMK6M-XxmOwPtr7ZqWMTtaZPdGFhVMcGHxQlP97jdk,11856
10
+ jsonata/tokenizer.py,sha256=X-JsARtkBIN6bO8_TElpw3SCageQMtfBWlexuhG2Sds,11982
11
11
  jsonata/utils.py,sha256=U13I49Ie3hEn3PKGR4361TPengDAkbyHmwipDFZJlXo,5192
12
12
  jsonata/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- jsonata/cli/__main__.py,sha256=G3bgRulCyS6nekd_7ulbsfJpWewQmZgiYylBREHgJx8,6971
14
- jsonata_python-0.5.1.dist-info/METADATA,sha256=CHwsN5yZbO2z5AIiI6_tJxoh58Op91MYL2TCD26Ow6M,17275
15
- jsonata_python-0.5.1.dist-info/WHEEL,sha256=C2FUgwZgiLbznR-k0b_5k3Ai_1aASOXDss3lzCUsUug,87
16
- jsonata_python-0.5.1.dist-info/licenses/LICENSE,sha256=y16Ofl9KOYjhBjwULGDcLfdWBfTEZRXnduOspt-XbhQ,11325
17
- jsonata_python-0.5.1.dist-info/RECORD,,
13
+ jsonata/cli/__main__.py,sha256=d_tNQ3Y_yN9o_NzBip8LdhsAVLAAA62GeowFKc6zx3Y,7125
14
+ jsonata_python-0.5.3.dist-info/METADATA,sha256=_qkeeFX_iFWyljejtPGrx3Xjt8mgkX0tKIkTk_-uNlc,17442
15
+ jsonata_python-0.5.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
16
+ jsonata_python-0.5.3.dist-info/licenses/LICENSE,sha256=y16Ofl9KOYjhBjwULGDcLfdWBfTEZRXnduOspt-XbhQ,11325
17
+ jsonata_python-0.5.3.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: hatchling 1.26.3
2
+ Generator: hatchling 1.27.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any