ducpy.serialize¶
Serialize DUC data using the Rust native extension (ducpy_native).
Attributes¶
Functions¶
Decode sqlite-style schema user_version to semver. |
|
Resolve schema version directly from repository schema/duc.sql. |
|
|
Recursively flatten nested dicts whose key is in |
|
Convert an element (or ElementWrapper) to the camelCase dict Rust expects. |
|
Convert a list of DucExternalFileEntry to a |
|
Convert a list of DictionaryEntry to a |
|
Convert a list of dataclass instances to camelCase dicts. |
|
Serialize elements to |
Module Contents¶
- ducpy.serialize.logger¶
- ducpy.serialize._decode_user_version_to_semver(user_version: int) str¶
Decode sqlite-style schema user_version to semver.
- Encoding convention:
major * 1_000_000 + minor * 1_000 + patch
- ducpy.serialize._read_schema_version_fallback() str¶
Resolve schema version directly from repository schema/duc.sql.
This is used when ducpy._version isn’t available (for example, in clean CI environments before setup-time generation has run).
- ducpy.serialize.DUC_SCHEMA_VERSION = '0.0.0'¶
- ducpy.serialize._ELEMENT_CLASS_TO_TYPE: Dict[str, str]¶
- ducpy.serialize._FLATTEN_KEYS¶
- ducpy.serialize._flatten_dict(d: dict) dict¶
Recursively flatten nested dicts whose key is in
_FLATTEN_KEYS.
- ducpy.serialize._element_to_camel(wrapper_or_element: Any) dict¶
Convert an element (or ElementWrapper) to the camelCase dict Rust expects.
- ducpy.serialize._convert_external_files(entries: list | None) Dict[str, Any] | None¶
Convert a list of DucExternalFileEntry to a
{id: data}dict.
- ducpy.serialize._convert_dict_entries(entries: list | None) Dict[str, str] | None¶
Convert a list of DictionaryEntry to a
{key: value}dict.
- ducpy.serialize._convert_list(items: list | None) list | None¶
Convert a list of dataclass instances to camelCase dicts.
- ducpy.serialize.serialize_duc(name: str, thumbnail: bytes | None = None, dictionary: list | None = None, elements: list | None = None, duc_local_state: Any = None, duc_global_state: Any = None, version_graph: Any = None, blocks: list | None = None, block_instances: list | None = None, block_collections: list | None = None, groups: list | None = None, regions: list | None = None, layers: list | None = None, external_files: list | None = None) bytes¶
Serialize elements to
.ducformat. Element instances and state dataclasses are automatically converted to the camelCase dicts expected by the Rust native module.