jsonata-python 0.2.0__py3-none-any.whl → 0.3.0__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 +1 -1
- jsonata/datetimeutils.py +4 -14
- jsonata/functions.py +2 -2
- jsonata/jsonata.py +2 -7
- {jsonata_python-0.2.0.dist-info → jsonata_python-0.3.0.dist-info}/METADATA +5 -4
- {jsonata_python-0.2.0.dist-info → jsonata_python-0.3.0.dist-info}/RECORD +8 -8
- {jsonata_python-0.2.0.dist-info → jsonata_python-0.3.0.dist-info}/WHEEL +1 -1
- {jsonata_python-0.2.0.dist-info → jsonata_python-0.3.0.dist-info}/licenses/LICENSE +0 -0
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.
|
|
37
|
+
"-v", "--version", action='version', version='%(prog)s 0.3.0')
|
|
38
38
|
|
|
39
39
|
parser.add_argument(
|
|
40
40
|
"-e", "--expression", metavar="<file>",
|
jsonata/datetimeutils.py
CHANGED
|
@@ -146,11 +146,7 @@ class DateTimeUtils:
|
|
|
146
146
|
@staticmethod
|
|
147
147
|
def words_to_number(text: str) -> int:
|
|
148
148
|
parts = re.split(",\\s|\\sand\\s|[\\s\\-]", text)
|
|
149
|
-
values = [
|
|
150
|
-
i = 0
|
|
151
|
-
while i < len(parts):
|
|
152
|
-
values[i] = DateTimeUtils._word_values[parts[i]]
|
|
153
|
-
i += 1
|
|
149
|
+
values = [DateTimeUtils._word_values[part] for i, part in enumerate(parts)]
|
|
154
150
|
segs = deque()
|
|
155
151
|
segs.append(0)
|
|
156
152
|
for value in values:
|
|
@@ -170,11 +166,7 @@ class DateTimeUtils:
|
|
|
170
166
|
@staticmethod
|
|
171
167
|
def words_to_long(text: str) -> int:
|
|
172
168
|
parts = re.split(",\\s|\\sand\\s|[\\s\\-]", text)
|
|
173
|
-
values = [
|
|
174
|
-
i = 0
|
|
175
|
-
while i < len(parts):
|
|
176
|
-
values[i] = DateTimeUtils._word_values_long[parts[i]]
|
|
177
|
-
i += 1
|
|
169
|
+
values = [DateTimeUtils._word_values_long[part] for i, part in enumerate(parts)]
|
|
178
170
|
segs = deque()
|
|
179
171
|
segs.append(int(0))
|
|
180
172
|
for value in values:
|
|
@@ -229,8 +221,7 @@ class DateTimeUtils:
|
|
|
229
221
|
def roman_to_decimal(roman: str) -> int:
|
|
230
222
|
decimal = 0
|
|
231
223
|
max = 1
|
|
232
|
-
for i in
|
|
233
|
-
digit = roman[i]
|
|
224
|
+
for i, digit in enumerate(reversed(roman)):
|
|
234
225
|
value = DateTimeUtils._roman_values[digit]
|
|
235
226
|
if value < max:
|
|
236
227
|
decimal -= value
|
|
@@ -416,8 +407,7 @@ class DateTimeUtils:
|
|
|
416
407
|
separator_position = 0
|
|
417
408
|
format_codepoints = list(primary_format)
|
|
418
409
|
# ArrayUtils.reverse(format_codepoints)
|
|
419
|
-
for ix in
|
|
420
|
-
code_point = format_codepoints[ix]
|
|
410
|
+
for ix, code_point in enumerate(reversed(format_codepoints)):
|
|
421
411
|
digit = False
|
|
422
412
|
i = 0
|
|
423
413
|
while i < len(DateTimeUtils._decimal_groups):
|
jsonata/functions.py
CHANGED
|
@@ -569,7 +569,7 @@ class Functions:
|
|
|
569
569
|
# @returns {Array} The array of match objects
|
|
570
570
|
#
|
|
571
571
|
@staticmethod
|
|
572
|
-
def match_(string: Optional[str], regex: Optional[re.Pattern], limit: Optional[int]) -> Optional[list[dict]]:
|
|
572
|
+
def match_(string: Optional[str], regex: Optional[re.Pattern], limit: Optional[int]) -> Optional[list[dict[str, Any]]]:
|
|
573
573
|
# undefined inputs always return undefined
|
|
574
574
|
if string is None:
|
|
575
575
|
return None
|
|
@@ -676,7 +676,7 @@ class Functions:
|
|
|
676
676
|
# @return
|
|
677
677
|
#
|
|
678
678
|
@staticmethod
|
|
679
|
-
def to_jsonata_match(mr: re.Match[str]) -> dict[str, str]:
|
|
679
|
+
def to_jsonata_match(mr: re.Match[str]) -> dict[str, list[str]]:
|
|
680
680
|
obj = {"match": mr.group()}
|
|
681
681
|
|
|
682
682
|
groups = []
|
jsonata/jsonata.py
CHANGED
|
@@ -275,7 +275,7 @@ class Jsonata:
|
|
|
275
275
|
elif expr.type == "regex":
|
|
276
276
|
result = self.evaluate_regex(expr) # , input, environment);
|
|
277
277
|
elif expr.type == "function":
|
|
278
|
-
result = self.evaluate_function(expr, input, environment,
|
|
278
|
+
result = self.evaluate_function(expr, input, environment, utils.Utils.NONE)
|
|
279
279
|
elif expr.type == "variable":
|
|
280
280
|
result = self.evaluate_variable(expr, input, environment)
|
|
281
281
|
elif expr.type == "lambda":
|
|
@@ -1274,11 +1274,6 @@ class Jsonata:
|
|
|
1274
1274
|
|
|
1275
1275
|
lhs = self.eval(expr.lhs, input, environment)
|
|
1276
1276
|
|
|
1277
|
-
# Map null to NULL_VALUE before applying to functions
|
|
1278
|
-
# TODO: fix more generically!
|
|
1279
|
-
if lhs is None:
|
|
1280
|
-
lhs = utils.Utils.NULL_VALUE
|
|
1281
|
-
|
|
1282
1277
|
if expr.rhs.type == "function":
|
|
1283
1278
|
# Symbol applyTo = new Symbol(); applyTo.context = lhs
|
|
1284
1279
|
# this is a Object _invocation_; invoke it with lhs expression as the first argument
|
|
@@ -1348,7 +1343,7 @@ class Jsonata:
|
|
|
1348
1343
|
|
|
1349
1344
|
evaluated_args = []
|
|
1350
1345
|
|
|
1351
|
-
if applyto_context is not
|
|
1346
|
+
if applyto_context is not utils.Utils.NONE:
|
|
1352
1347
|
evaluated_args.append(applyto_context)
|
|
1353
1348
|
# eager evaluation - evaluate the arguments
|
|
1354
1349
|
args = expr.arguments if expr.arguments is not None else []
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: jsonata-python
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
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
|
|
@@ -217,7 +217,8 @@ Description-Content-Type: text/markdown
|
|
|
217
217
|
|
|
218
218
|
# jsonata-python
|
|
219
219
|
|
|
220
|
-
[![Build Status][github-actions-shield]][github-actions-link]
|
|
220
|
+
[![Build Status][github-actions-shield]][github-actions-link]
|
|
221
|
+
[](https://www.pypi.org/project/jsonata-python)
|
|
221
222
|
|
|
222
223
|
[github-actions-shield]: https://github.com/rayokota/jsonata-python/actions/workflows/test.yml/badge.svg?branch=master
|
|
223
224
|
[github-actions-link]: https://github.com/rayokota/jsonata-python/actions
|
|
@@ -227,7 +228,7 @@ Pure Python implementation of JSONata.
|
|
|
227
228
|
This is a Python port of the [JSONata reference implementation](https://github.com/jsonata-js/jsonata),
|
|
228
229
|
and also borrows from the [Dashjoin Java port](https://github.com/dashjoin/jsonata-java).
|
|
229
230
|
|
|
230
|
-
This implementation supports 100% of the language features of JSONata, with no external
|
|
231
|
+
This implementation supports 100% of the language features of JSONata, with no external dependencies.
|
|
231
232
|
The JSONata documentation can be found [here](https://jsonata.org).
|
|
232
233
|
|
|
233
234
|
|
|
@@ -335,4 +336,4 @@ nox --sessions tests
|
|
|
335
336
|
|
|
336
337
|
## Notes
|
|
337
338
|
|
|
338
|
-
JSONata date/time functions that use ISO 8601 formats are only supported
|
|
339
|
+
JSONata date/time functions that use ISO 8601 formats are only supported with Python 3.11+.
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
jsonata/__init__.py,sha256=4r8USHj4SoBy_TD8dLxt9HJIgpLfXApFrZBipi4rgr0,388
|
|
2
2
|
jsonata/constants.py,sha256=WtdH_l_s5KD-SiOJ4GR2az7WpVgKB2HguXUnyfy4tvs,3017
|
|
3
|
-
jsonata/datetimeutils.py,sha256=
|
|
4
|
-
jsonata/functions.py,sha256=
|
|
3
|
+
jsonata/datetimeutils.py,sha256=IzU6y-vwyhwobHyw9rsImBye-RfWDV7K8Vk0Xs-yiG0,48567
|
|
4
|
+
jsonata/functions.py,sha256=VAHFQtXQI7tY-EVwIrku95jKniUimTTKY6-exBTQo1k,73260
|
|
5
5
|
jsonata/jexception.py,sha256=6Jz7WMsIiNlQ7-1Hq8RKiE2HxcHq2PDekw0qsSe3lqo,12885
|
|
6
|
-
jsonata/jsonata.py,sha256=
|
|
6
|
+
jsonata/jsonata.py,sha256=jZIxVrNcZI3aBvE0PURZ4-cxpaK9JiJVH5Q_cllCXS0,84247
|
|
7
7
|
jsonata/parser.py,sha256=OSxO9eNQy2WrDOPX_Obow487PWwngRN7bCMtDoK55AI,53794
|
|
8
8
|
jsonata/signature.py,sha256=zTO9zmT7XzxA4GHYf2Rgquu419D7UZ-NYzIwiqqNvCM,20184
|
|
9
9
|
jsonata/timebox.py,sha256=bnevNR_ONvKUiIZCJZEWsRiR0gCWTGOwn5RCY7dKqYc,2861
|
|
10
10
|
jsonata/tokenizer.py,sha256=6WMK6M-XxmOwPtr7ZqWMTtaZPdGFhVMcGHxQlP97jdk,11856
|
|
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=
|
|
14
|
-
jsonata_python-0.
|
|
15
|
-
jsonata_python-0.
|
|
16
|
-
jsonata_python-0.
|
|
17
|
-
jsonata_python-0.
|
|
13
|
+
jsonata/cli/__main__.py,sha256=pzzkZomVSkoDpiWg1f_0-TrC5uLHg1wu2aNYNPnT3zM,6971
|
|
14
|
+
jsonata_python-0.3.0.dist-info/METADATA,sha256=29v4aOPgmo8ZKgPUy49Mq0kHf7ewahj1j9bYP6p8H1w,17297
|
|
15
|
+
jsonata_python-0.3.0.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
16
|
+
jsonata_python-0.3.0.dist-info/licenses/LICENSE,sha256=y16Ofl9KOYjhBjwULGDcLfdWBfTEZRXnduOspt-XbhQ,11325
|
|
17
|
+
jsonata_python-0.3.0.dist-info/RECORD,,
|
|
File without changes
|