extended_data.containers.data

Generic Extended Data root and factory.

Module Contents

Classes

ExtendedData

Common root and factory for any Extended Data value.

Data

API

extended_data.containers.data._FACTORY_INITIALIZED_ATTR = '_extended_data_factory_initialized'
extended_data.containers.data._DELEGATING_ATTRIBUTE_ATTR = '_extended_data_delegating_attribute'
class extended_data.containers.data.ExtendedData(value: Any = None)

Common root and factory for any Extended Data value.

ExtendedData(value) returns the most specific concrete Tier 2 container whenever one exists. Mapping values become ExtendedDict instances, list values become ExtendedList instances, strings become ExtendedString instances, and so on. Scalars and arbitrary objects remain in a small generic holder so the same workflow, export, and sync helpers are available at file, API, and vendor boundaries.

Initialization

Initialize scalar/object holders without touching concrete subtypes.

property value: Any

Return the concrete value represented by this object.

property data_type: str

Return this value type name.

property shape: str

Return the broad data shape represented by this value.

property is_mapping: bool

Return whether this value is mapping-shaped.

property is_sequence: bool

Return whether this value is list- or tuple-shaped.

property is_string: bool

Return whether this value is string-shaped.

property is_set: bool

Return whether this value is set-shaped.

property is_scalar: bool

Return whether this value is scalar-shaped.

property is_none: bool

Return whether this value is None.

classmethod from_value(value: Any = None) extended_data.containers.data.ExtendedData

Create an Extended Data object from any value.

classmethod decode(data: str | memoryview | bytes | bytearray, *, file_path: str | pathlib.Path | None = None, suffix: str | None = None) extended_data.containers.data.ExtendedData

Decode raw structured data and return concrete Extended Data.

classmethod read(file_path: str | pathlib.Path, *, suffix: str | None = None, charset: str = 'utf-8', errors: str = 'strict', headers: collections.abc.Mapping[str, str] | None = None, tld: pathlib.Path | None = None) extended_data.containers.data.ExtendedData

Read a local file or URL and return concrete Extended Data.

as_builtin() Any

Return the value lowered to built-in Python containers.

as_extended() Any

Return a detached promoted copy of the value.

copy() extended_data.containers.data.ExtendedData

Return a detached Extended Data copy.

cast(value: Any) extended_data.containers.data.ExtendedData

Return value promoted into the appropriate Extended Data subtype.

map(transform: collections.abc.Callable[[Any], Any]) extended_data.containers.data.ExtendedData

Apply a callable to this value and wrap the result.

map_builtin(transform: collections.abc.Callable[[Any], Any]) extended_data.containers.data.ExtendedData

Apply a callable to lowered built-in data and wrap the result.

transform(*steps: str) extended_data.containers.data.ExtendedData

Apply named DataWorkflow transforms and wrap the result.

merge(*mappings: collections.abc.Mapping[str, Any]) extended_data.containers.data.ExtendedData

Deep-merge mappings when this wrapper contains mapping-shaped data.

workflow() Any

Start a DataWorkflow from this value.

sync_to_file(file_path: str | pathlib.Path, *, source: str = 'memory', encoding: str | None = None, charset: str = 'utf-8', allow_empty: bool = False, dry_run: bool = False, tld: pathlib.Path | None = None, metadata: collections.abc.Mapping[str, Any] | None = None) Any

Sync this value to a local file through the shared data sync primitive.

write(file_path: str | pathlib.Path, *, encoding: str | None = None, charset: str = 'utf-8', allow_empty: bool = False, tld: pathlib.Path | None = None) pathlib.Path | None

Write this value to a file and return the output path.

to_export_safe(*, export_to_yaml: bool = False) Any

Return this value converted to export-safe primitive data.

wrap_for_export(allow_encoding: bool | str = True, **format_opts: Any) str

Return this value wrapped as an encoded export string.

get(key: Any, default: Any = None) Any

Return a mapping value by key, or default when unavailable.

append(item: Any) Self

Append to list-shaped data and return this wrapper.

extend(values: collections.abc.Iterable[Any]) Self

Extend list-shaped data and return this wrapper.

update(*args: Any, **kwargs: Any) Self

Update mapping- or set-shaped data and return this wrapper.

add(item: Any) Self

Add to set-shaped data and return this wrapper.