zs-yaml 0.8.2.dev1__tar.gz → 0.8.3.dev3__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.
- zs_yaml-0.8.3.dev3/CHANGELOG.md +58 -0
- {zs_yaml-0.8.2.dev1/zs_yaml.egg-info → zs_yaml-0.8.3.dev3}/PKG-INFO +1 -1
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/zs_yaml/__init__.py +1 -1
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/zs_yaml/_version.py +3 -3
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/zs_yaml/convert.py +55 -9
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3/zs_yaml.egg-info}/PKG-INFO +1 -1
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/zs_yaml.egg-info/SOURCES.txt +1 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/.github/workflows/ci.yml +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/.gitignore +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/LICENSE +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/README.md +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/doc/zs-yaml.png +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/doc/zs-yaml.svg +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/examples/team/addresses.yaml +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/examples/team/custom_transformations.py +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/examples/team/hobbies.yaml +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/examples/team/skills.yaml +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/examples/team/team.zs +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/examples/team/team1.yaml +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/examples/team/test_all_conversions.py +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/examples/team/test_pyobj_to_yaml.py +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/examples/team/work_experience.yaml +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/pyproject.toml +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/setup.cfg +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/zs_yaml/built_in_transformations.py +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/zs_yaml/main.py +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/zs_yaml/yaml_transformer.py +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/zs_yaml.egg-info/dependency_links.txt +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/zs_yaml.egg-info/entry_points.txt +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/zs_yaml.egg-info/requires.txt +0 -0
- {zs_yaml-0.8.2.dev1 → zs_yaml-0.8.3.dev3}/zs_yaml.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [0.8.2] - 2025-12-06
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- `bin_to_dict` function to deserialize binary directly to dict
|
|
12
|
+
|
|
13
|
+
## [0.8.1] - 2025-12-03
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- Cache management: `YamlTransformer.clear_cache()` method for explicit cache invalidation
|
|
17
|
+
|
|
18
|
+
### Changed
|
|
19
|
+
- Performance: Skip transformation processing entirely when YAML contains no function invocations
|
|
20
|
+
|
|
21
|
+
## [0.8.0] - 2025-07-03
|
|
22
|
+
|
|
23
|
+
### Added
|
|
24
|
+
- `pyobj_to_yaml` conversion function for dumping Python objects to YAML files
|
|
25
|
+
- Dedicated exceptions and more informative error messages
|
|
26
|
+
|
|
27
|
+
## [0.7.0] - 2024-12-09
|
|
28
|
+
|
|
29
|
+
### Added
|
|
30
|
+
- `py_eval` transformation function for generating node values via Python snippets
|
|
31
|
+
- `extract_extern_as_yaml` supports compressed externals (gzip, zstd, lz4, brotli)
|
|
32
|
+
- `extract_extern_as_yaml` supports generating YAMLs without null-value fields
|
|
33
|
+
|
|
34
|
+
## [0.6.1] - 2024-12-04
|
|
35
|
+
|
|
36
|
+
### Changed
|
|
37
|
+
- Minimum zserio version updated to 2.15.0
|
|
38
|
+
|
|
39
|
+
## [0.6.0] - 2024-11-08
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
- Crash that hid zserio exception messages in some cases
|
|
43
|
+
|
|
44
|
+
## [0.5.0] - 2024-10-07
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
- `yaml_to_pyobj` conversion function (library API only)
|
|
48
|
+
|
|
49
|
+
## [0.4.0] - 2024-08-10
|
|
50
|
+
|
|
51
|
+
### Added
|
|
52
|
+
- Initial release
|
|
53
|
+
- YAML format support for zserio serialization
|
|
54
|
+
- Automatic metadata inclusion in YAML
|
|
55
|
+
- Bidirectional conversion between YAML, JSON, and binary formats
|
|
56
|
+
- Template substitution for flexible YAML content generation
|
|
57
|
+
- Built-in transformations: `insert_yaml_as_extern`, `insert_yaml`, `repeat_node`
|
|
58
|
+
- Custom transformation hooks
|
|
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
|
|
|
28
28
|
commit_id: COMMIT_ID
|
|
29
29
|
__commit_id__: COMMIT_ID
|
|
30
30
|
|
|
31
|
-
__version__ = version = '0.8.
|
|
32
|
-
__version_tuple__ = version_tuple = (0, 8,
|
|
31
|
+
__version__ = version = '0.8.3.dev3'
|
|
32
|
+
__version_tuple__ = version_tuple = (0, 8, 3, 'dev3')
|
|
33
33
|
|
|
34
|
-
__commit_id__ = commit_id = '
|
|
34
|
+
__commit_id__ = commit_id = 'gc8ec0d36c'
|
|
@@ -199,6 +199,58 @@ def json_to_yaml(json_input_path, yaml_output_path):
|
|
|
199
199
|
yaml.safe_dump(data, yaml_file, default_flow_style=False, sort_keys=False)
|
|
200
200
|
|
|
201
201
|
|
|
202
|
+
def bin_to_dict(bin_input, schema_module, schema_type, init_args=None):
|
|
203
|
+
"""
|
|
204
|
+
Converts binary data to a Python dictionary using Zserio deserialization.
|
|
205
|
+
|
|
206
|
+
Args:
|
|
207
|
+
bin_input (str or bytes): Path to the input binary file, or binary data as bytes.
|
|
208
|
+
schema_module (str): The schema module name (e.g., 'ndslive.schema.smart.v2024_11.tile.api').
|
|
209
|
+
schema_type (str): The schema type name (e.g., 'SmartLayerTile').
|
|
210
|
+
init_args (list, optional): Initialization arguments for zserio deserialization.
|
|
211
|
+
|
|
212
|
+
Returns:
|
|
213
|
+
tuple: (data_dict, metadata_dict) where data_dict is the deserialized data
|
|
214
|
+
and metadata_dict contains schema_module and schema_type.
|
|
215
|
+
|
|
216
|
+
Raises:
|
|
217
|
+
TransformationError: If deserialization fails.
|
|
218
|
+
"""
|
|
219
|
+
if init_args is None:
|
|
220
|
+
init_args = []
|
|
221
|
+
|
|
222
|
+
try:
|
|
223
|
+
module = importlib.import_module(schema_module)
|
|
224
|
+
ImportedType = getattr(module, schema_type)
|
|
225
|
+
if ImportedType is None:
|
|
226
|
+
raise ValueError(f"Type {schema_type} not found in module {schema_module}")
|
|
227
|
+
|
|
228
|
+
# Handle both file path and bytes input
|
|
229
|
+
if isinstance(bin_input, bytes):
|
|
230
|
+
zserio_object = zserio.deserialize_from_bytes(ImportedType, bin_input, *init_args)
|
|
231
|
+
else:
|
|
232
|
+
zserio_object = zserio.deserialize_from_file(ImportedType, bin_input, *init_args)
|
|
233
|
+
|
|
234
|
+
json_data = zserio.to_json_string(zserio_object)
|
|
235
|
+
data = json.loads(json_data)
|
|
236
|
+
|
|
237
|
+
metadata = {
|
|
238
|
+
'schema_module': schema_module,
|
|
239
|
+
'schema_type': schema_type
|
|
240
|
+
}
|
|
241
|
+
if init_args:
|
|
242
|
+
metadata['initialization_args'] = init_args
|
|
243
|
+
|
|
244
|
+
return data, metadata
|
|
245
|
+
except Exception as e:
|
|
246
|
+
file_info = bin_input if isinstance(bin_input, str) else "<bytes>"
|
|
247
|
+
raise TransformationError(
|
|
248
|
+
f"Failed to convert binary to dict: {e}",
|
|
249
|
+
file_path=file_info,
|
|
250
|
+
original_error=e
|
|
251
|
+
)
|
|
252
|
+
|
|
253
|
+
|
|
202
254
|
def bin_to_yaml(bin_input_path, yaml_output_path):
|
|
203
255
|
"""
|
|
204
256
|
Converts a binary file to a YAML file using Zserio deserialization.
|
|
@@ -223,15 +275,7 @@ def bin_to_yaml(bin_input_path, yaml_output_path):
|
|
|
223
275
|
if not schema_module or not schema_type:
|
|
224
276
|
raise ValueError("Error: schema_module and schema_type must be specified in the _meta section of the YAML file")
|
|
225
277
|
|
|
226
|
-
|
|
227
|
-
ImportedType = getattr(module, schema_type)
|
|
228
|
-
if ImportedType is None:
|
|
229
|
-
raise ValueError(f"Type {schema_type} not found in module {schema_module}")
|
|
230
|
-
|
|
231
|
-
zserio_object = zserio.deserialize_from_file(ImportedType, bin_input_path, *init_args)
|
|
232
|
-
json_data = zserio.to_json_string(zserio_object)
|
|
233
|
-
|
|
234
|
-
data = json.loads(json_data)
|
|
278
|
+
data, metadata = bin_to_dict(bin_input_path, schema_module, schema_type, init_args)
|
|
235
279
|
|
|
236
280
|
# Create a new dictionary to ensure _meta comes first
|
|
237
281
|
final_data = {'_meta': meta['_meta']}
|
|
@@ -239,6 +283,8 @@ def bin_to_yaml(bin_input_path, yaml_output_path):
|
|
|
239
283
|
|
|
240
284
|
with open(yaml_output_path, 'w') as yaml_file:
|
|
241
285
|
yaml.safe_dump(final_data, yaml_file, default_flow_style=False, sort_keys=False)
|
|
286
|
+
except TransformationError:
|
|
287
|
+
raise
|
|
242
288
|
except Exception as e:
|
|
243
289
|
raise TransformationError(
|
|
244
290
|
f"Failed to convert binary to YAML: {e}",
|
|
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
|