Namespace
- class app.util.namespace.Namespace[source]
Bases:
Generic
A flexible namespace object that can be accessed like a dictionary or using attributes.
This class provides a dynamic container for attributes, supporting both attribute and dict-style access. It supports freezing (to prevent further modification), recursive merging, and can be extended with mixins for logging, naming, and hierarchy. Used as a base for configuration and data structures throughout pygaindalf.
Inheritance Diagram for Namespace
Methods
__init__
(*[, frozen_schema, frozen_namespace])Initialize a Namespace instance.
asdict
([recursive, private, protected, public])Convert the namespace to a dictionary.
freeze_namespace
([freeze, recursive, temporary])Freeze the namespace.
freeze_schema
([freeze, recursive, temporary])Freeze the schema of the namespace.
merge
(d)Merge a dictionary into the namespace.
unfreeze_namespace
([recursive, temporary])Unfreeze the namespace.
unfreeze_schema
([recursive, temporary])Unfreeze the schema of the namespace.
Attributes
Get the frozen state of the namespace.
Get the frozen state of the schema.
- Attribute = Attribute
- Default = Default
- DictView = DictView
- class FreezableNamespaceProtocol[source]
Bases:
Protocol
- __init__(*args, **kwargs)
- class FreezableSchemaProtocol[source]
Bases:
Protocol
- __init__(*args, **kwargs)
-
NAMESPACE__DEFAULT:
TypeAliasType
= <app.util.namespace.namespace.Namespace.NoDefault object>
- NO_DEFAULT = <app.util.namespace.namespace.Namespace.NoDefault object>
- __init__(*, frozen_schema=False, frozen_namespace=False, **kwargs)[source]
Initialize a Namespace instance.
- Parameters:
- Raises:
TypeError – If mixin order is incorrect in the MRO.
- asdict(recursive=True, private=False, protected=True, public=True)[source]
Convert the namespace to a dictionary.
- Parameters:
- Returns:
The namespace as a dictionary.
- Return type:
- freeze_namespace(freeze=True, *, recursive=False, temporary=False)[source]
Freeze the namespace.
- Parameters:
- Returns:
A context manager for temporary freezing.
- Return type:
- freeze_schema(freeze=True, *, recursive=False, temporary=False)[source]
Freeze the schema of the namespace.
- Parameters:
- Returns:
A context manager for temporary freezing.
- Return type:
- property frozen_namespace: bool
Get the frozen state of the namespace.
- Returns:
True if the namespace is frozen, False otherwise.
- Return type:
- property frozen_schema: bool
Get the frozen state of the schema.
- Returns:
True if the schema is frozen, False otherwise.
- Return type:
- unfreeze_namespace(recursive=False, temporary=False)[source]
Unfreeze the namespace.
- Parameters:
- Returns:
A context manager for temporary unfreezing.
- Return type: