avrotize 2.21.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.
- avrotize/__init__.py +66 -0
- avrotize/__main__.py +6 -0
- avrotize/_version.py +34 -0
- avrotize/asn1toavro.py +160 -0
- avrotize/avrotize.py +152 -0
- avrotize/avrotocpp/CMakeLists.txt.jinja +77 -0
- avrotize/avrotocpp/build.bat.jinja +7 -0
- avrotize/avrotocpp/build.sh.jinja +7 -0
- avrotize/avrotocpp/dataclass_body.jinja +108 -0
- avrotize/avrotocpp/vcpkg.json.jinja +21 -0
- avrotize/avrotocpp.py +483 -0
- avrotize/avrotocsharp/README.md.jinja +166 -0
- avrotize/avrotocsharp/class_test.cs.jinja +266 -0
- avrotize/avrotocsharp/dataclass_core.jinja +293 -0
- avrotize/avrotocsharp/enum_test.cs.jinja +20 -0
- avrotize/avrotocsharp/project.csproj.jinja +30 -0
- avrotize/avrotocsharp/project.sln.jinja +34 -0
- avrotize/avrotocsharp/run_coverage.ps1.jinja +98 -0
- avrotize/avrotocsharp/run_coverage.sh.jinja +149 -0
- avrotize/avrotocsharp/testproject.csproj.jinja +19 -0
- avrotize/avrotocsharp.py +1180 -0
- avrotize/avrotocsv.py +121 -0
- avrotize/avrotodatapackage.py +173 -0
- avrotize/avrotodb.py +1383 -0
- avrotize/avrotogo/go_enum.jinja +12 -0
- avrotize/avrotogo/go_helpers.jinja +31 -0
- avrotize/avrotogo/go_struct.jinja +151 -0
- avrotize/avrotogo/go_test.jinja +47 -0
- avrotize/avrotogo/go_union.jinja +38 -0
- avrotize/avrotogo.py +476 -0
- avrotize/avrotographql.py +197 -0
- avrotize/avrotoiceberg.py +210 -0
- avrotize/avrotojava/class_test.java.jinja +212 -0
- avrotize/avrotojava/enum_test.java.jinja +21 -0
- avrotize/avrotojava/testproject.pom.jinja +54 -0
- avrotize/avrotojava.py +2156 -0
- avrotize/avrotojs.py +250 -0
- avrotize/avrotojsons.py +481 -0
- avrotize/avrotojstruct.py +345 -0
- avrotize/avrotokusto.py +364 -0
- avrotize/avrotomd/README.md.jinja +49 -0
- avrotize/avrotomd.py +137 -0
- avrotize/avrotools.py +168 -0
- avrotize/avrotoparquet.py +208 -0
- avrotize/avrotoproto.py +359 -0
- avrotize/avrotopython/dataclass_core.jinja +241 -0
- avrotize/avrotopython/enum_core.jinja +87 -0
- avrotize/avrotopython/pyproject_toml.jinja +18 -0
- avrotize/avrotopython/test_class.jinja +97 -0
- avrotize/avrotopython/test_enum.jinja +23 -0
- avrotize/avrotopython.py +626 -0
- avrotize/avrotorust/dataclass_enum.rs.jinja +74 -0
- avrotize/avrotorust/dataclass_struct.rs.jinja +204 -0
- avrotize/avrotorust/dataclass_union.rs.jinja +105 -0
- avrotize/avrotorust.py +435 -0
- avrotize/avrotots/class_core.ts.jinja +140 -0
- avrotize/avrotots/class_test.ts.jinja +77 -0
- avrotize/avrotots/enum_core.ts.jinja +46 -0
- avrotize/avrotots/gitignore.jinja +34 -0
- avrotize/avrotots/index.ts.jinja +0 -0
- avrotize/avrotots/package.json.jinja +23 -0
- avrotize/avrotots/tsconfig.json.jinja +21 -0
- avrotize/avrotots.py +687 -0
- avrotize/avrotoxsd.py +344 -0
- avrotize/cddltostructure.py +1841 -0
- avrotize/commands.json +3496 -0
- avrotize/common.py +834 -0
- avrotize/constants.py +87 -0
- avrotize/csvtoavro.py +132 -0
- avrotize/datapackagetoavro.py +76 -0
- avrotize/dependencies/cpp/vcpkg/vcpkg.json +19 -0
- avrotize/dependencies/cs/net90/dependencies.csproj +29 -0
- avrotize/dependencies/go/go121/go.mod +6 -0
- avrotize/dependencies/java/jdk21/pom.xml +91 -0
- avrotize/dependencies/python/py312/requirements.txt +13 -0
- avrotize/dependencies/rust/stable/Cargo.toml +17 -0
- avrotize/dependencies/typescript/node22/package.json +16 -0
- avrotize/dependency_resolver.py +348 -0
- avrotize/dependency_version.py +432 -0
- avrotize/generic/generic.avsc +57 -0
- avrotize/jsonstoavro.py +2167 -0
- avrotize/jsonstostructure.py +2864 -0
- avrotize/jstructtoavro.py +878 -0
- avrotize/kstructtoavro.py +93 -0
- avrotize/kustotoavro.py +455 -0
- avrotize/openapitostructure.py +717 -0
- avrotize/parquettoavro.py +157 -0
- avrotize/proto2parser.py +498 -0
- avrotize/proto3parser.py +403 -0
- avrotize/prototoavro.py +382 -0
- avrotize/prototypes/any.avsc +19 -0
- avrotize/prototypes/api.avsc +106 -0
- avrotize/prototypes/duration.avsc +20 -0
- avrotize/prototypes/field_mask.avsc +18 -0
- avrotize/prototypes/struct.avsc +60 -0
- avrotize/prototypes/timestamp.avsc +20 -0
- avrotize/prototypes/type.avsc +253 -0
- avrotize/prototypes/wrappers.avsc +117 -0
- avrotize/structuretocddl.py +597 -0
- avrotize/structuretocpp/CMakeLists.txt.jinja +76 -0
- avrotize/structuretocpp/build.bat.jinja +3 -0
- avrotize/structuretocpp/build.sh.jinja +3 -0
- avrotize/structuretocpp/dataclass_body.jinja +50 -0
- avrotize/structuretocpp/vcpkg.json.jinja +11 -0
- avrotize/structuretocpp.py +697 -0
- avrotize/structuretocsharp/class_test.cs.jinja +180 -0
- avrotize/structuretocsharp/dataclass_core.jinja +156 -0
- avrotize/structuretocsharp/enum_test.cs.jinja +36 -0
- avrotize/structuretocsharp/json_structure_converters.cs.jinja +399 -0
- avrotize/structuretocsharp/program.cs.jinja +49 -0
- avrotize/structuretocsharp/project.csproj.jinja +17 -0
- avrotize/structuretocsharp/project.sln.jinja +34 -0
- avrotize/structuretocsharp/testproject.csproj.jinja +18 -0
- avrotize/structuretocsharp/tuple_converter.cs.jinja +121 -0
- avrotize/structuretocsharp.py +2295 -0
- avrotize/structuretocsv.py +365 -0
- avrotize/structuretodatapackage.py +659 -0
- avrotize/structuretodb.py +1125 -0
- avrotize/structuretogo/go_enum.jinja +12 -0
- avrotize/structuretogo/go_helpers.jinja +26 -0
- avrotize/structuretogo/go_interface.jinja +18 -0
- avrotize/structuretogo/go_struct.jinja +187 -0
- avrotize/structuretogo/go_test.jinja +70 -0
- avrotize/structuretogo.py +729 -0
- avrotize/structuretographql.py +502 -0
- avrotize/structuretoiceberg.py +355 -0
- avrotize/structuretojava/choice_core.jinja +34 -0
- avrotize/structuretojava/class_core.jinja +23 -0
- avrotize/structuretojava/enum_core.jinja +18 -0
- avrotize/structuretojava/equals_hashcode.jinja +30 -0
- avrotize/structuretojava/pom.xml.jinja +26 -0
- avrotize/structuretojava/tuple_core.jinja +49 -0
- avrotize/structuretojava.py +938 -0
- avrotize/structuretojs/class_core.js.jinja +33 -0
- avrotize/structuretojs/enum_core.js.jinja +10 -0
- avrotize/structuretojs/package.json.jinja +12 -0
- avrotize/structuretojs/test_class.js.jinja +84 -0
- avrotize/structuretojs/test_enum.js.jinja +58 -0
- avrotize/structuretojs/test_runner.js.jinja +45 -0
- avrotize/structuretojs.py +657 -0
- avrotize/structuretojsons.py +498 -0
- avrotize/structuretokusto.py +639 -0
- avrotize/structuretomd/README.md.jinja +204 -0
- avrotize/structuretomd.py +322 -0
- avrotize/structuretoproto.py +764 -0
- avrotize/structuretopython/dataclass_core.jinja +363 -0
- avrotize/structuretopython/enum_core.jinja +45 -0
- avrotize/structuretopython/map_alias.jinja +21 -0
- avrotize/structuretopython/pyproject_toml.jinja +23 -0
- avrotize/structuretopython/test_class.jinja +103 -0
- avrotize/structuretopython/test_enum.jinja +34 -0
- avrotize/structuretopython.py +799 -0
- avrotize/structuretorust/dataclass_enum.rs.jinja +63 -0
- avrotize/structuretorust/dataclass_struct.rs.jinja +121 -0
- avrotize/structuretorust/dataclass_union.rs.jinja +81 -0
- avrotize/structuretorust.py +714 -0
- avrotize/structuretots/class_core.ts.jinja +78 -0
- avrotize/structuretots/enum_core.ts.jinja +6 -0
- avrotize/structuretots/gitignore.jinja +8 -0
- avrotize/structuretots/index.ts.jinja +1 -0
- avrotize/structuretots/package.json.jinja +39 -0
- avrotize/structuretots/test_class.ts.jinja +35 -0
- avrotize/structuretots/tsconfig.json.jinja +21 -0
- avrotize/structuretots.py +740 -0
- avrotize/structuretoxsd.py +679 -0
- avrotize/xsdtoavro.py +413 -0
- avrotize-2.21.1.dist-info/METADATA +1319 -0
- avrotize-2.21.1.dist-info/RECORD +171 -0
- avrotize-2.21.1.dist-info/WHEEL +4 -0
- avrotize-2.21.1.dist-info/entry_points.txt +3 -0
- avrotize-2.21.1.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
{%- if ordinals | length == 0 %}
|
|
4
|
+
_{{ class_name }}_members = []
|
|
5
|
+
{%- endif %}
|
|
6
|
+
|
|
7
|
+
class {{ class_name }}(Enum):
|
|
8
|
+
"""
|
|
9
|
+
{{ docstring }}
|
|
10
|
+
"""
|
|
11
|
+
{%- for symbol in symbols %}
|
|
12
|
+
{{ symbol }} = '{{symbol}}'
|
|
13
|
+
{%- endfor %}
|
|
14
|
+
|
|
15
|
+
@classmethod
|
|
16
|
+
def from_ordinal(cls, ordinal: int|str) -> '{{ class_name }}':
|
|
17
|
+
"""
|
|
18
|
+
Get enum member by ordinal
|
|
19
|
+
|
|
20
|
+
Args:
|
|
21
|
+
ordinal (int| str): The ordinal of the enum member. This can be an integer or a string representation of an integer.
|
|
22
|
+
|
|
23
|
+
Returns:
|
|
24
|
+
The enum member corresponding to the ordinal.
|
|
25
|
+
"""
|
|
26
|
+
{%- if ordinals | length == 0 %}
|
|
27
|
+
# pylint: disable=global-statement
|
|
28
|
+
global _{{ class_name }}_members
|
|
29
|
+
# pylint: enable=global-statement
|
|
30
|
+
{%- endif %}
|
|
31
|
+
|
|
32
|
+
if ordinal is None:
|
|
33
|
+
raise ValueError("ordinal must not be None")
|
|
34
|
+
if isinstance(ordinal, str) and ordinal.isdigit():
|
|
35
|
+
ordinal = int(ordinal)
|
|
36
|
+
{%- if ordinals | length > 0 %}
|
|
37
|
+
if isinstance(ordinal, int):
|
|
38
|
+
{%- for sym, ord in ordinals.items() -%}
|
|
39
|
+
{%- if loop.first %}
|
|
40
|
+
if ordinal == {{ ord }}:
|
|
41
|
+
{%- else %}
|
|
42
|
+
elif ordinal == {{ ord }}:
|
|
43
|
+
{%- endif %}
|
|
44
|
+
return {{ class_name }}.{{ sym }}
|
|
45
|
+
{%- endfor %}
|
|
46
|
+
raise ValueError("Ordinal not found in enum")
|
|
47
|
+
else:
|
|
48
|
+
raise ValueError("Ordinal must be an integer or a string representation of an integer")
|
|
49
|
+
{%- else %}
|
|
50
|
+
if not _{{ class_name }}_members:
|
|
51
|
+
_{{ class_name }}_members = list(cls)
|
|
52
|
+
if 0 <= int(ordinal) < len(_{{ class_name }}_members):
|
|
53
|
+
return _{{ class_name }}_members[ordinal]
|
|
54
|
+
else:
|
|
55
|
+
raise IndexError("Ordinal out of range for enum")
|
|
56
|
+
{%- endif %}
|
|
57
|
+
|
|
58
|
+
@classmethod
|
|
59
|
+
def to_ordinal(cls, member: '{{ class_name }}') -> int:
|
|
60
|
+
"""
|
|
61
|
+
Get enum ordinal
|
|
62
|
+
|
|
63
|
+
Args:
|
|
64
|
+
member ({{ class_name }}): The enum member to get the ordinal of.
|
|
65
|
+
|
|
66
|
+
Returns:
|
|
67
|
+
The ordinal of the enum member.
|
|
68
|
+
"""
|
|
69
|
+
{%- if ordinals | length == 0 %}
|
|
70
|
+
# pylint: disable=global-statement
|
|
71
|
+
global _{{ class_name }}_members
|
|
72
|
+
# pylint: enable=global-statement
|
|
73
|
+
|
|
74
|
+
if not _{{ class_name }}_members:
|
|
75
|
+
_{{ class_name }}_members = list(cls)
|
|
76
|
+
return _{{ class_name }}_members.index(member)
|
|
77
|
+
{%- else %}
|
|
78
|
+
{% for sym, ord in ordinals.items() %}
|
|
79
|
+
if member == {{ class_name }}.{{ sym }}:
|
|
80
|
+
return {{ ord }}
|
|
81
|
+
{%- endfor %}
|
|
82
|
+
raise ValueError("Member not found in enum")
|
|
83
|
+
{%- endif %}
|
|
84
|
+
|
|
85
|
+
{%- if ordinals | length == 0 %}
|
|
86
|
+
_{{ class_name }}_members = list({{ class_name }})
|
|
87
|
+
{%- endif %}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "{{ package_name }}"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A package for handling Avro schema data"
|
|
5
|
+
authors = ["Your Name"]
|
|
6
|
+
license = "MIT"
|
|
7
|
+
packages = [ { include = "{{ package_name|replace('-','_')|lower }}", from="src" } ]
|
|
8
|
+
|
|
9
|
+
[tool.poetry.dependencies]
|
|
10
|
+
python = "<4.0,>=3.10"
|
|
11
|
+
dataclasses-json = "^0.6.7"
|
|
12
|
+
|
|
13
|
+
[tool.poetry.dev-dependencies]
|
|
14
|
+
pylint = "^3.2.3"
|
|
15
|
+
|
|
16
|
+
[build-system]
|
|
17
|
+
requires = ["poetry-core>=1.0.0"]
|
|
18
|
+
build-backend = "poetry.core.masonry.api"
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Test case for {{ class_name }}
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
import unittest
|
|
8
|
+
|
|
9
|
+
sys.path.append(os.path.realpath(os.path.join(os.path.dirname(__file__), '../src'.replace('/', os.sep))))
|
|
10
|
+
|
|
11
|
+
from {{ package_name | lower }} import {{ class_name }}
|
|
12
|
+
|
|
13
|
+
{%- for import_type in import_types if import_type not in ['decimal.Decimal', 'datetime.datetime', 'datetime.date', 'datetime.time', 'datetime.timedelta'] %}
|
|
14
|
+
{%- set import_type_name = 'Test_'+import_type.split('.')[-1] %}
|
|
15
|
+
{%- set flat_package = '_'.join(import_type.split('.')[:-1]) | lower %}
|
|
16
|
+
{%- set import_package_name = flat_package if flat_package.startswith('test_') else 'test_' + flat_package %}
|
|
17
|
+
|
|
18
|
+
{%- if import_type.startswith('.') %}
|
|
19
|
+
from .{{ import_package_name }} import {{ import_type_name }}
|
|
20
|
+
{%- else %}
|
|
21
|
+
from {{ import_package_name }} import {{ import_type_name }}
|
|
22
|
+
{%- endif -%}
|
|
23
|
+
{%- endfor %}
|
|
24
|
+
{%- for import_type in import_types if import_type in ['datetime.datetime', 'datetime.date', 'datetime.time', 'datetime.timedelta'] %}
|
|
25
|
+
{%- if loop.first %}
|
|
26
|
+
import datetime
|
|
27
|
+
{%- endif %}
|
|
28
|
+
{%- endfor %}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class {{ test_class_name }}(unittest.TestCase):
|
|
32
|
+
"""
|
|
33
|
+
Test case for {{ class_name }}
|
|
34
|
+
"""
|
|
35
|
+
|
|
36
|
+
def setUp(self):
|
|
37
|
+
"""
|
|
38
|
+
Set up test case
|
|
39
|
+
"""
|
|
40
|
+
self.instance = {{ test_class_name }}.create_instance()
|
|
41
|
+
|
|
42
|
+
@staticmethod
|
|
43
|
+
def create_instance():
|
|
44
|
+
"""
|
|
45
|
+
Create instance of {{ class_name }} for testing
|
|
46
|
+
"""
|
|
47
|
+
instance = {{ class_name }}(
|
|
48
|
+
{%- for field in fields %}
|
|
49
|
+
{{ field.name }}={{ field.test_value }}{%- if not loop.last %},{%- endif %}
|
|
50
|
+
{%- endfor %}
|
|
51
|
+
)
|
|
52
|
+
return instance
|
|
53
|
+
|
|
54
|
+
{% for field in fields %}
|
|
55
|
+
def test_{{ field.name }}_property(self):
|
|
56
|
+
"""
|
|
57
|
+
Test {{ field.name }} property
|
|
58
|
+
"""
|
|
59
|
+
test_value = {{ field.test_value }}
|
|
60
|
+
self.instance.{{ field.name }} = test_value
|
|
61
|
+
self.assertEqual(self.instance.{{ field.name }}, test_value)
|
|
62
|
+
{% endfor %}
|
|
63
|
+
|
|
64
|
+
{%- if avro_annotation %}
|
|
65
|
+
def test_to_byte_array_avro(self):
|
|
66
|
+
"""
|
|
67
|
+
Test to_byte_array method with avro media type
|
|
68
|
+
"""
|
|
69
|
+
media_type = "application/vnd.apache.avro+avro"
|
|
70
|
+
bytes_data = self.instance.to_byte_array(media_type)
|
|
71
|
+
new_instance = {{ class_name }}.from_data(bytes_data, media_type)
|
|
72
|
+
bytes_data2 = new_instance.to_byte_array(media_type)
|
|
73
|
+
self.assertEqual(bytes_data, bytes_data2)
|
|
74
|
+
{%- endif %}
|
|
75
|
+
|
|
76
|
+
{%- if dataclasses_json_annotation %}
|
|
77
|
+
def test_to_byte_array_json(self):
|
|
78
|
+
"""
|
|
79
|
+
Test to_byte_array method with json media type
|
|
80
|
+
"""
|
|
81
|
+
media_type = "application/json"
|
|
82
|
+
bytes_data = self.instance.to_byte_array(media_type)
|
|
83
|
+
new_instance = {{ class_name }}.from_data(bytes_data, media_type)
|
|
84
|
+
bytes_data2 = new_instance.to_byte_array(media_type)
|
|
85
|
+
self.assertEqual(bytes_data, bytes_data2)
|
|
86
|
+
|
|
87
|
+
def test_to_json():
|
|
88
|
+
"""
|
|
89
|
+
Test to_json method
|
|
90
|
+
"""
|
|
91
|
+
json_data = self.instance.to_json()
|
|
92
|
+
media_type = "application/json"
|
|
93
|
+
new_instance = {{ class_name }}.from_data(json_data)
|
|
94
|
+
json_data2 = new_instance.to_json()
|
|
95
|
+
self.assertEqual(json_data, json_data2)
|
|
96
|
+
{%- endif %}
|
|
97
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import sys
|
|
3
|
+
import unittest
|
|
4
|
+
|
|
5
|
+
sys.path.append(os.path.realpath(os.path.join(os.path.dirname(__file__), '../src'.replace('/', os.sep))))
|
|
6
|
+
|
|
7
|
+
from {{ package_name | lower }} import {{ class_name }}
|
|
8
|
+
|
|
9
|
+
class {{ test_class_name }}(unittest.TestCase):
|
|
10
|
+
|
|
11
|
+
def setUp(self):
|
|
12
|
+
"""
|
|
13
|
+
Setup test
|
|
14
|
+
"""
|
|
15
|
+
self.instance = {{ test_class_name }}.create_instance()
|
|
16
|
+
|
|
17
|
+
@staticmethod
|
|
18
|
+
def create_instance():
|
|
19
|
+
"""
|
|
20
|
+
Create instance of {{ class_name }}
|
|
21
|
+
"""
|
|
22
|
+
return "{{ symbols[0] }}"
|
|
23
|
+
|