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

DucData

Dict subclass allowing attribute-style access (data.elements).

Functions

_wrap(→ Any)

Recursively wrap dicts as DucData for attribute access.

_read_bytes(→ bytes)

Accept bytes, a file-like object, or a file path and return raw bytes.

parse_duc(→ DucData)

Parse a .duc file into a DucData dict.

parse_duc_lazy(→ DucData)

Parse a .duc file lazily (external file data blobs are omitted).

get_external_file(→ Optional[DucData])

Fetch a single external file entry from a .duc buffer.

list_external_files(→ List[DucData])

List metadata for all external files (without data blobs).

Module Contents

ducpy.parse.logger
class ducpy.parse.DucData

Bases: dict

Dict 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 .duc file into a DucData dict.

Parameters

sourcebytes | file | str

Raw bytes, an open binary file, or a path to a .duc file.

Returns

DucData

Attribute-accessible dict matching the ExportedDataState schema with snake_case keys.

ducpy.parse.parse_duc_lazy(source: bytes | bytearray | BinaryIO | str) DucData

Parse a .duc file lazily (external file data blobs are omitted).

Use get_external_file() or list_external_files() to retrieve external file data on demand.

ducpy.parse.get_external_file(source: bytes | bytearray | BinaryIO | str, file_id: str) DucData | None

Fetch a single external file entry from a .duc buffer.

ducpy.parse.list_external_files(source: bytes | bytearray | BinaryIO | str) List[DucData]

List metadata for all external files (without data blobs).