ducpy.parse¶
Parse .duc files using the Rust native extension (ducpy_native).
Returns plain dicts with snake_case keys. Attribute-style access is available via DucData wrapper.
Attributes¶
Classes¶
Dict subclass allowing attribute-style access ( |
Functions¶
|
Recursively wrap dicts as DucData for attribute access. |
|
Accept bytes, a file-like object, or a file path and return raw bytes. |
|
Parse a |
|
Parse a |
|
Fetch a single external file entry from a |
|
List metadata for all external files (without data blobs). |
Module Contents¶
- ducpy.parse.logger¶
- class ducpy.parse.DucData¶
Bases:
dictDict subclass allowing attribute-style access (
data.elements).Initialize self. See help(type(self)) for accurate signature.
- __getattr__(key: str) Any¶
- __setattr__(key: str, value: Any) None¶
Implement setattr(self, name, value).
- __delattr__(key: str) None¶
Implement delattr(self, name).
- ducpy.parse._wrap(obj: Any) Any¶
Recursively wrap dicts as DucData for attribute access.
- ducpy.parse._read_bytes(source: bytes | bytearray | BinaryIO | str) bytes¶
Accept bytes, a file-like object, or a file path and return raw bytes.
- ducpy.parse.parse_duc(source: bytes | bytearray | BinaryIO | str) DucData¶
Parse a
.ducfile into aDucDatadict.This function reads a raw .duc binary blob or file path and parses it using the Rust native extension. It returns a specialized dictionary (DucData) that allows attribute-style access to the parsed properties (e.g. data.elements[0].id), using snake_case keys instead of the internal camelCase format.
Parameters¶
- sourcebytes | file | str
Raw bytes, an open binary file, or a string path to a
.ducfile.
Returns¶
- DucData
An attribute-accessible dictionary matching the internal ExportedDataState schema with snake_case keys. Common keys include elements, global_state, local_state, and version_graph.
Examples¶
>>> data = duc.parse_duc("path/to/file.duc") >>> data = duc.parse_duc(binary_data) >>> print(f"Found {len(data.elements)} elements") >>> print(f"First element type: {data.elements[0].type}")
- ducpy.parse.parse_duc_lazy(source: bytes | bytearray | BinaryIO | str) DucData¶
Parse a
.ducfile lazily (external file data blobs are omitted).Use
get_external_file()orlist_external_files()to retrieve external file data on demand.