jsonbp 1.2.0__tar.gz → 1.2.2__tar.gz

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.
Files changed (42) hide show
  1. {jsonbp-1.2.0/jsonbp.egg-info → jsonbp-1.2.2}/PKG-INFO +16 -16
  2. {jsonbp-1.2.0 → jsonbp-1.2.2}/README.md +12 -12
  3. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/blueprint.py +4 -6
  4. jsonbp-1.2.2/jsonbp/localization/__init__.py +0 -0
  5. jsonbp-1.2.2/jsonbp/types/__init__.py +0 -0
  6. jsonbp-1.2.2/jsonbp/types/date.py +26 -0
  7. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/types/string.py +1 -1
  8. {jsonbp-1.2.0 → jsonbp-1.2.2/jsonbp.egg-info}/PKG-INFO +16 -16
  9. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp.egg-info/SOURCES.txt +3 -0
  10. {jsonbp-1.2.0 → jsonbp-1.2.2}/pyproject.toml +5 -3
  11. {jsonbp-1.2.0 → jsonbp-1.2.2}/tests/test_choose_root.py +2 -2
  12. {jsonbp-1.2.0 → jsonbp-1.2.2}/LICENSE.txt +0 -0
  13. {jsonbp-1.2.0 → jsonbp-1.2.2}/MANIFEST.in +0 -0
  14. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/__init__.py +0 -0
  15. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/array.py +0 -0
  16. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/declaration.py +0 -0
  17. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/error.py +0 -0
  18. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/exception.py +0 -0
  19. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/field.py +0 -0
  20. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/loader.py +0 -0
  21. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/localization/en_US.ini +0 -0
  22. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/localization/pt_BR.ini +0 -0
  23. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/parser.py +0 -0
  24. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/ply/__init__.py +0 -0
  25. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/ply/lex.py +0 -0
  26. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/ply/yacc.py +0 -0
  27. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/types/bool.py +0 -0
  28. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/types/decimal.py +0 -0
  29. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/types/float.py +0 -0
  30. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/types/instant.py +0 -0
  31. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/types/integer.py +0 -0
  32. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/types/limits.py +0 -0
  33. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp/types.py +0 -0
  34. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp.egg-info/dependency_links.txt +0 -0
  35. {jsonbp-1.2.0 → jsonbp-1.2.2}/jsonbp.egg-info/top_level.txt +0 -0
  36. {jsonbp-1.2.0 → jsonbp-1.2.2}/setup.cfg +0 -0
  37. {jsonbp-1.2.0 → jsonbp-1.2.2}/tests/test_caching.py +0 -0
  38. {jsonbp-1.2.0 → jsonbp-1.2.2}/tests/test_deserialization.py +0 -0
  39. {jsonbp-1.2.0 → jsonbp-1.2.2}/tests/test_error_fallbacks.py +0 -0
  40. {jsonbp-1.2.0 → jsonbp-1.2.2}/tests/test_loading.py +0 -0
  41. {jsonbp-1.2.0 → jsonbp-1.2.2}/tests/test_parsing.py +0 -0
  42. {jsonbp-1.2.0 → jsonbp-1.2.2}/tests/test_serialization.py +0 -0
@@ -1,20 +1,20 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: jsonbp
3
- Version: 1.2.0
3
+ Version: 1.2.2
4
4
  Summary: Schema based JSON Parser/Serializer
5
5
  Author-email: Gustavo Venturini <gustavo.c.venturini@gmail.com>
6
- License: MIT
6
+ License-Expression: BSD-3-Clause
7
7
  Project-URL: Homepage, https://github.com/vottini/jsonbp
8
8
  Project-URL: Documentation, https://jsonbp.readthedocs.io/en/stable/
9
9
  Keywords: JSON,serialization,deserialization
10
10
  Classifier: Development Status :: 5 - Production/Stable
11
11
  Classifier: Intended Audience :: Developers
12
- Classifier: License :: OSI Approved :: MIT License
13
12
  Classifier: Operating System :: OS Independent
14
13
  Classifier: Programming Language :: Python :: 3 :: Only
15
14
  Requires-Python: >=3.11
16
15
  Description-Content-Type: text/markdown
17
16
  License-File: LICENSE.txt
17
+ Dynamic: license-file
18
18
 
19
19
 
20
20
  # jsonbp
@@ -50,10 +50,10 @@ Here's a simple example:
50
50
 
51
51
  ```
52
52
  root {
53
- x: float (min=0.0),
54
- y: float (min=0.0, max=1.0),
53
+ x: Float (min=0.0),
54
+ y: Float (min=0.0, max=1.0),
55
55
 
56
- optional color: {
56
+ optional Color: {
57
57
  RED,
58
58
  GOLD,
59
59
  GREEN
@@ -100,26 +100,26 @@ modular. In the above example, one could split the definitions and get
100
100
  something more reusable, like the following:
101
101
 
102
102
  ```
103
- type non_negative : float (min=0.0)
104
- type normalized : non_negative (max=1.0)
103
+ type NonNegative : Float (min=0.0)
104
+ type Normalized : NonNegative (max=1.0)
105
105
 
106
- object coordinates {
107
- x: non_negative,
108
- y: normalized
106
+ object Coordinates {
107
+ x: NonNegative,
108
+ y: Normalized
109
109
  }
110
110
 
111
111
  include "color.jbp"
112
- object colored_coordinates extends coordinates {
113
- optional color: color
112
+ object ColoredCoordinates extends Coordinates {
113
+ optional color: Color
114
114
  }
115
115
 
116
- root colored_coordinates[minLength=2]
116
+ root ColoredCoordinates[minLength=2]
117
117
  ```
118
118
 
119
119
  where the contents of file "color.jbp" would be:
120
120
 
121
121
  ```
122
- enum color {
122
+ enum Color {
123
123
  RED,
124
124
  GOLD,
125
125
  GREEN
@@ -32,10 +32,10 @@ Here's a simple example:
32
32
 
33
33
  ```
34
34
  root {
35
- x: float (min=0.0),
36
- y: float (min=0.0, max=1.0),
35
+ x: Float (min=0.0),
36
+ y: Float (min=0.0, max=1.0),
37
37
 
38
- optional color: {
38
+ optional Color: {
39
39
  RED,
40
40
  GOLD,
41
41
  GREEN
@@ -82,26 +82,26 @@ modular. In the above example, one could split the definitions and get
82
82
  something more reusable, like the following:
83
83
 
84
84
  ```
85
- type non_negative : float (min=0.0)
86
- type normalized : non_negative (max=1.0)
85
+ type NonNegative : Float (min=0.0)
86
+ type Normalized : NonNegative (max=1.0)
87
87
 
88
- object coordinates {
89
- x: non_negative,
90
- y: normalized
88
+ object Coordinates {
89
+ x: NonNegative,
90
+ y: Normalized
91
91
  }
92
92
 
93
93
  include "color.jbp"
94
- object colored_coordinates extends coordinates {
95
- optional color: color
94
+ object ColoredCoordinates extends Coordinates {
95
+ optional color: Color
96
96
  }
97
97
 
98
- root colored_coordinates[minLength=2]
98
+ root ColoredCoordinates[minLength=2]
99
99
  ```
100
100
 
101
101
  where the contents of file "color.jbp" would be:
102
102
 
103
103
  ```
104
- enum color {
104
+ enum Color {
105
105
  RED,
106
106
  GOLD,
107
107
  GREEN
@@ -376,12 +376,10 @@ class JsonBlueprint:
376
376
 
377
377
  """Selects or changes the root element of a blueprint.
378
378
 
379
- This function allows you to select or overwrite the root
380
- type of a blueprint file when no root is defined, or when you want
381
- to use a different root for serializing/deserializing data with a
382
- JsonBlueprint instance. The original JsonBlueprint instance remains
383
- unchanged; instead, a new instance is created with the same context,
384
- but with the modified root type.
379
+ This function allows you to create a derivative JsonBlueprint
380
+ instance, overwriting the root type (or selecting one, if none
381
+ is defined). The original source JsonBlueprint instance remains
382
+ unchanged.
385
383
 
386
384
  Args:
387
385
  root_type (str): name of the type to be used as root.
File without changes
File without changes
@@ -0,0 +1,26 @@
1
+
2
+ from datetime import date
3
+
4
+ _defaults = {
5
+ 'format': "%Y-%m-%d"
6
+ }
7
+
8
+
9
+ def _format(value, specs):
10
+ result = value.strftime(specs['format'])
11
+ return f'"{result}"'
12
+
13
+
14
+ def _parse(value, specs):
15
+ str_value = str(value)
16
+ parsed_date = date.fromisoformat(str_value)
17
+ return True, parsed_date
18
+
19
+
20
+ type_specs = {
21
+ 'name': 'Date',
22
+ 'parser': _parse,
23
+ 'formatter': _format,
24
+ 'defaults': _defaults
25
+ }
26
+
@@ -25,7 +25,7 @@ def _parse(value, specs):
25
25
  "context": { "length": strLength }
26
26
  }
27
27
 
28
- fullFormat = fr"^{specs['format']}$"
28
+ fullFormat = f"^{specs['format']}$"
29
29
  if re.search(fullFormat, value) is None:
30
30
  return False, {
31
31
  "error": jsonbp.ErrorType.INVALID_FORMAT,
@@ -1,20 +1,20 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: jsonbp
3
- Version: 1.2.0
3
+ Version: 1.2.2
4
4
  Summary: Schema based JSON Parser/Serializer
5
5
  Author-email: Gustavo Venturini <gustavo.c.venturini@gmail.com>
6
- License: MIT
6
+ License-Expression: BSD-3-Clause
7
7
  Project-URL: Homepage, https://github.com/vottini/jsonbp
8
8
  Project-URL: Documentation, https://jsonbp.readthedocs.io/en/stable/
9
9
  Keywords: JSON,serialization,deserialization
10
10
  Classifier: Development Status :: 5 - Production/Stable
11
11
  Classifier: Intended Audience :: Developers
12
- Classifier: License :: OSI Approved :: MIT License
13
12
  Classifier: Operating System :: OS Independent
14
13
  Classifier: Programming Language :: Python :: 3 :: Only
15
14
  Requires-Python: >=3.11
16
15
  Description-Content-Type: text/markdown
17
16
  License-File: LICENSE.txt
17
+ Dynamic: license-file
18
18
 
19
19
 
20
20
  # jsonbp
@@ -50,10 +50,10 @@ Here's a simple example:
50
50
 
51
51
  ```
52
52
  root {
53
- x: float (min=0.0),
54
- y: float (min=0.0, max=1.0),
53
+ x: Float (min=0.0),
54
+ y: Float (min=0.0, max=1.0),
55
55
 
56
- optional color: {
56
+ optional Color: {
57
57
  RED,
58
58
  GOLD,
59
59
  GREEN
@@ -100,26 +100,26 @@ modular. In the above example, one could split the definitions and get
100
100
  something more reusable, like the following:
101
101
 
102
102
  ```
103
- type non_negative : float (min=0.0)
104
- type normalized : non_negative (max=1.0)
103
+ type NonNegative : Float (min=0.0)
104
+ type Normalized : NonNegative (max=1.0)
105
105
 
106
- object coordinates {
107
- x: non_negative,
108
- y: normalized
106
+ object Coordinates {
107
+ x: NonNegative,
108
+ y: Normalized
109
109
  }
110
110
 
111
111
  include "color.jbp"
112
- object colored_coordinates extends coordinates {
113
- optional color: color
112
+ object ColoredCoordinates extends Coordinates {
113
+ optional color: Color
114
114
  }
115
115
 
116
- root colored_coordinates[minLength=2]
116
+ root ColoredCoordinates[minLength=2]
117
117
  ```
118
118
 
119
119
  where the contents of file "color.jbp" would be:
120
120
 
121
121
  ```
122
- enum color {
122
+ enum Color {
123
123
  RED,
124
124
  GOLD,
125
125
  GREEN
@@ -16,12 +16,15 @@ jsonbp.egg-info/PKG-INFO
16
16
  jsonbp.egg-info/SOURCES.txt
17
17
  jsonbp.egg-info/dependency_links.txt
18
18
  jsonbp.egg-info/top_level.txt
19
+ jsonbp/localization/__init__.py
19
20
  jsonbp/localization/en_US.ini
20
21
  jsonbp/localization/pt_BR.ini
21
22
  jsonbp/ply/__init__.py
22
23
  jsonbp/ply/lex.py
23
24
  jsonbp/ply/yacc.py
25
+ jsonbp/types/__init__.py
24
26
  jsonbp/types/bool.py
27
+ jsonbp/types/date.py
25
28
  jsonbp/types/decimal.py
26
29
  jsonbp/types/float.py
27
30
  jsonbp/types/instant.py
@@ -3,9 +3,12 @@
3
3
  requires = ["setuptools"]
4
4
  build-backend = "setuptools.build_meta"
5
5
 
6
+ [tool.setuptools]
7
+ packages = ["jsonbp", "jsonbp.ply", "jsonbp.types", "jsonbp.localization"]
8
+
6
9
  [project]
7
10
  name = "jsonbp"
8
- version = "1.2.0"
11
+ version = "1.2.2"
9
12
  description = "Schema based JSON Parser/Serializer"
10
13
  authors = [
11
14
  { name = "Gustavo Venturini", email = "gustavo.c.venturini@gmail.com" }
@@ -13,11 +16,10 @@ authors = [
13
16
  requires-python = ">=3.11"
14
17
  readme = { file = "README.md", content-type = "text/markdown" }
15
18
  keywords = ["JSON", "serialization", "deserialization"]
16
- license = {text = "MIT"}
19
+ license = "BSD-3-Clause"
17
20
  classifiers = [
18
21
  "Development Status :: 5 - Production/Stable",
19
22
  "Intended Audience :: Developers",
20
- "License :: OSI Approved :: MIT License",
21
23
  "Operating System :: OS Independent",
22
24
  "Programming Language :: Python :: 3 :: Only",
23
25
  ]
@@ -55,8 +55,8 @@ def testChooseRoot():
55
55
  success, _ = derived.deserialize(json_txt)
56
56
  assert success
57
57
 
58
- arrayDerived = blueprint.choose_root("Payload", asArray=True,
59
- minArrayLength=2, maxArrayLength=3)
58
+ arrayDerived = blueprint.choose_root("Payload", as_array=True,
59
+ min_array_length=2, max_array_length=3)
60
60
 
61
61
  outcome1, _ = arrayDerived.deserialize(f"[{json_txt}, {json_txt}]")
62
62
  outcome2, _ = arrayDerived.deserialize(f"[{json_txt}, {json_txt}, {json_txt}, {json_txt}]")
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes