Bases (objetto.bases)
Base types.
Base Classes
- class objetto.bases.BaseMeta(name, bases, dct)
Metaclass for
objetto.bases.Base.- Inherits from:
- Inherited by:
- Features:
Forces the use of __slots__.
Forces __hash__ to be declared if __eq__ was declared.
Decorates __init__ methods to update the initializing tag.
Prevents base class attributes from changing.
Runtime checking for final decorated classes/methods.
Implements __fullname__ class property for backporting qualified name.
- __dir__()
Get a simplified list of class member names.
- final __setattr__(name, value)
Prevent setting read-only class attributes.
- Parameters
name – Name.
value – Value.
- Str name
str
- Raises
AttributeError – Read-only attribute.
- final __delattr__(name)
Prevent deleting read-only class attributes.
- Parameters
name (str) – Name.
- Raises
AttributeError – Read-only attribute.
- class objetto.bases.Base
Base class for all Objetto types.
- Metaclass:
- Inherits from:
- Inherited By:
- Features:
Forces the use of __slots__.
Forces __hash__ to be declared if __eq__ was declared.
Property that tells whether instance is initializing or not.
Default implementation of __copy__ raises an error.
Default implementation of __ne__ returns the opposite of __eq__.
Prevents base class attributes from changing.
Runtime checking for final decorated classes/methods.
Simplified __dir__ result that shows only relevant members for client code.
Implements __fullname__ class property for backporting qualified name.
- __copy__()
Prevents shallow copy by default.
- Raises
RuntimeError – Always raised.
- __repr__()
Get representation using class’ full name if possible.
- Returns
Representation.
- Return type
- __ne__(other)
Compare for inequality by negating the result of __eq__. This is a backport of the default python 3 behavior to python 2.
- Parameters
other – Another object.
- Returns
True if not equal.
- Return type
bool or NotImplemented
- __dir__()
Get a simplified list of member names.
- class objetto.bases.BaseHashable
Base hashable.
- Inherits from:
slotted.SlottedHashable
- Inherited By:
objetto.bases.KeyRelationshipobjetto.history.HistoryDescriptor
- Features:
Forces implementation of __hash__ method.
- abstract __hash__()
Get hash.
- Returns
Hash.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- class objetto.bases.BaseSized
Base sized.
- Inherits from:
slotted.SlottedSized
- Inherited By:
- Features:
Has a length (count).
- abstract __len__()
Get count.
- Returns
Count.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- class objetto.bases.BaseIterable
Base iterable.
- Inherits from:
slotted.SlottedIterable
- Inherited By:
- Features:
Can be iterated over.
- abstract __iter__()
Iterate over.
- Returns
Iterator.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- class objetto.bases.BaseContainer
Base container.
- Inherits from:
slotted.SlottedContainer
- Inherited By:
- Features:
Contains values.
- abstract __contains__(content)
Get whether content is present.
- Parameters
content – Content.
- Returns
True if contains.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
Base Decorators
- @objetto.bases.final
Decorator based on
typing.final()that enables runtime checking forobjetto.bases.Baseclasses.>>> from objetto.bases import Base, final >>> @final ... class FinalClass(Base): # final class ... pass ... >>> class Class(Base): ... @final ... def final_method(self): # final method ... pass ...
- @objetto.bases.init
Method decorator that sets the initializing tag for
objetto.bases.Baseobjects.>>> from objetto.bases import init >>> class MyClass(Base): ... def __init__(self): # initialization tag is implicitly set ... print(("__init__", self._initializing)) ... ... @init ... def init(self): ... print(("init", self._initializing)) ... ... def not_init(self): ... print(("not_init", self._initializing)) ... >>> my_obj = MyClass() ('__init__', True) >>> my_obj.init() ('init', True) >>> my_obj.not_init() ('not_init', False)
- Parameters
func (function) – Method function.
- Returns
Decorated method function.
- Return type
function
Base Functions
- objetto.bases.simplify_member_names(names)
Iterate over member names and only yield the simplified ones.
- Parameters
names (str) – Input names.
- Returns
Simplified names iterator.
- Return type
- objetto.bases.make_base_cls(base=None, qual_name=None, module=None, dct=None)
Make a subclass of
objetto.bases.Baseon the fly.- Parameters
base (type[objetto.bases.Base]) – Base class.
qual_name (str or None) – Qualified name.
module (str or None) – Module.
dct – Members dictionary.
dct – dict[str, Any] or None
- Returns
Generated subclass.
- Return type
Base Context Managers
- objetto.bases.init_context(obj, flag=True)
Context manager that sets the initializing tag for
objetto.bases.Baseobjects.>>> from objetto.bases import init_context >>> class MyClass(Base): ... def __init__(self): # initialization tag is implicitly set ... print(("__init__", self._initializing)) ... ... def init(self): ... with init_context(self): ... print(("init (inside of context)", self._initializing)) ... print(("init (outside of context)", self._initializing)) ... >>> my_obj = MyClass() ('__init__', True) >>> my_obj.init() ('init (inside of context)', True) ('init (outside of context)', False)
- Parameters
obj (objetto.bases.Base) – Instance of
objetto.bases.Base.flag (bool) – Whether to set initialization flag to True of False.
- Returns
Context manager.
- Return type
Base Abstract Member
- objetto.bases.abstract_member(types=())
Used to indicate an abstract attribute member in a class.
>>> from objetto.bases import Base, abstract_member >>> class AbstractClass(Base): ... some_attribute = abstract_member(int) # will prevent instatiation ... >>> obj = AbstractClass() Traceback (most recent call last): TypeError: Can't instantiate abstract class AbstractClass with abstract method... >>> class ConcreteClass(AbstractClass): ... some_attribute = 3 # concrete >>> obj = ConcreteClass()
Base Collection Classes
- class objetto.bases.BaseCollection
Base collection.
- Inherits from:
slotted.SlottedCollection
- Inherited By:
- Features:
Method to find content that matches attribute values.
- abstract find_with_attributes(**attributes)
Find first value that matches unique attribute values.
- Parameters
attributes – Attributes to match.
- Returns
Value that has matching attributes.
- Raises
ValueError – No attributes provided or no match found.
NotImplementedError – Abstract method not implemented.
- class objetto.bases.BaseProtectedCollection
Base protected collection.
- Inherits from:
- Inherited By:
- Features:
Has protected transformation methods.
Transformations return a transformed version (immutable) or self (mutable).
- abstract _clear()
Clear.
- Returns
Transformed.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- class objetto.bases.BaseInteractiveCollection
Base interactive collection.
- Inherits from:
- Inherited By:
- Features:
Has public transformation methods.
Transformations return a transformed version (immutable) or self (mutable).
- final clear()
Clear.
- Returns
Transformed.
- Return type
- class objetto.bases.BaseMutableCollection
Base mutable collection.
- Inherits from:
- Inherited By:
- Features:
Has public mutable transformation and magic methods.
- clear()
Clear.
Base Dictionary Classes
- class objetto.bases.BaseDict
Base dictionary collection.
- Inherits from:
slotted.SlottedMapping
- Inherited By:
- abstract __eq__(other)
Compare for equality.
- Parameters
other – Another object.
- Returns
True if equal.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract __reversed__()
Iterate over reversed keys.
- Returns
Reversed keys iterator.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract __getitem__(key)
Get value for key.
- Parameters
key (collections.abc.Hashable) – Key.
- Returns
Value.
- Raises
KeyError – Key is not present.
NotImplementedError – Abstract method not implemented.
- abstract get(key, fallback=None)
Get value for key, return fallback value if key is not present.
- Parameters
key (collections.abc.Hashable) – Key.
fallback – Fallback value.
- Returns
Value or fallback value.
- Raises
NotImplementedError – Abstract method not implemented.
- abstract iteritems()
Iterate over items.
- Returns
Items iterator.
- Return type
collections.abc.Iterator[tuple[collections.abc.Hashable, Any]]
- Raises
NotImplementedError – Abstract method not implemented.
- abstract iterkeys()
Iterate over keys.
- Returns
Keys iterator.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract itervalues()
Iterate over values.
- Returns
Values iterator.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- items()
Get items.
- Returns
Items.
- Return type
- keys()
Get keys.
- Returns
Keys.
- Return type
- values()
Get values.
- Returns
Values.
- Return type
- class objetto.bases.BaseProtectedDict
Base protected dictionary collection.
- Inherits from:
- Inherited By:
- abstract _discard(key)
Discard key if it exists.
- Parameters
key (collections.abc.Hashable) – Key.
- Returns
Transformed.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract _remove(key)
Delete existing key.
- Parameters
key (collections.abc.Hashable) – Key.
- Returns
Transformed.
- Return type
- Raises
KeyError – Key is not present.
NotImplementedError – Abstract method not implemented.
- abstract _set(key, value)
Set value for key.
- Parameters
key (collections.abc.Hashable) – Key.
value – Value.
- Returns
Transformed.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract _update(*args, **kwargs)
Update keys and values. Same parameters as
dict.update().- Returns
Transformed.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- class objetto.bases.BaseInteractiveDict
Base interactive dictionary collection.
- Inherits from:
- Inherited By:
- discard(key)
Discard key if it exists.
- Parameters
key (collections.abc.Hashable) – Key.
- Returns
Transformed.
- Return type
- remove(key)
Delete existing key.
- Parameters
key (collections.abc.Hashable) – Key.
- Returns
Transformed.
- Return type
- Raises
KeyError – Key is not present.
- set(key, value)
Set value for key.
- Parameters
key (collections.abc.Hashable) – Key.
value – Value.
- Returns
Transformed.
- Return type
- update(*args, **kwargs)
Update keys and values. Same parameters as
dict.update().- Returns
Transformed.
- Return type
- class objetto.bases.BaseMutableDict
Base mutable dictionary collection.
- Inherits from:
slotted.SlottedMutableMapping
- Inherited By:
- __setitem__(key, value)
Set value for key.
- Parameters
key (collections.abc.Hashable) – Key.
value – Value.
- __delitem__(key)
Delete key.
- Parameters
key (collections.abc.Hashable) – Key.
- Raises
KeyError – Key is not preset.
- clear()
Clear.
- abstract pop(key, fallback=<objetto._bases.bases.MISSING object>)
Get value for key and remove it, return fallback value if key is not present.
- Parameters
key (collections.abc.Hashable) – Key.
fallback – Fallback value.
- Returns
Value or fallback value.
- Raises
KeyError – Key is not present and fallback value not provided.
NotImplementedError – Abstract method not implemented.
- abstract popitem()
Get item and discard key.
- Returns
Item.
- Return type
- Raises
KeyError – Dictionary is empty.
NotImplementedError – Abstract method not implemented.
- abstract setdefault(key, default=None)
Get the value for the specified key, insert key with default if not present.
- Parameters
key (collections.abc.Hashable) – Key.
default – Default value.
- Returns
Existing or default value.
- Raises
NotImplementedError – Abstract method not implemented.
- discard(key)
Discard key if it exists.
- Parameters
key (collections.abc.Hashable) – Key.
- remove(key)
Delete existing key.
- Parameters
key (collections.abc.Hashable) – Key.
- Raises
KeyError – Key is not present.
- set(key, value)
Set value for key.
- Parameters
key (collections.abc.Hashable) – Key.
value – Value.
- update(*args, **kwargs)
Update keys and values. Same parameters as
dict.update().
Base List Classes
- class objetto.bases.BaseList
Base list collection.
- Inherits from:
slotted.SlottedSequence
- Inherited By:
- abstract __eq__(other)
Compare for equality.
- Parameters
other – Another object.
- Returns
True if equal.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract __reversed__()
Iterate over reversed values.
- Returns
Reversed values iterator.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract __getitem__(index)
Get value/values at index/from slice.
- Parameters
- Returns
Value/values.
- Return type
Any or tuple[Any]
- Raises
NotImplementedError – Abstract method not implemented.
- abstract count(value)
Count number of occurrences of a value.
- Parameters
value – Value.
- Returns
Number of occurrences.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract index(value, start=None, stop=None)
Get index of a value.
- Parameters
- Returns
Index of value.
- Return type
- Raises
ValueError – Provided stop but did not provide start.
NotImplementedError – Abstract method not implemented.
- abstract resolve_index(index, clamp=False)
Resolve index to a positive number.
- Parameters
- Returns
Resolved index.
- Return type
- Raises
IndexError – Index out of range.
NotImplementedError – Abstract method not implemented.
- abstract resolve_continuous_slice(slc)
Resolve continuous slice according to length.
- Parameters
slc (slice) – Continuous slice.
- Returns
Index and stop.
- Return type
- Raises
IndexError – Slice is noncontinuous.
NotImplementedError – Abstract method not implemented.
- class objetto.bases.BaseProtectedList
Base protected list collection.
- Inherits from:
- Inherited By:
- abstract _insert(index, *values)
Insert value(s) at index.
- Parameters
index (int) – Index.
values – Value(s).
- Returns
Transformed.
- Return type
- Raises
ValueError – No values provided.
NotImplementedError – Abstract method not implemented.
- abstract _append(value)
Append value at the end.
- Parameters
value – Value.
- Returns
Transformed.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract _extend(iterable)
Extend at the end with iterable.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
Transformed.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract _remove(value)
Remove first occurrence of value.
- Parameters
value – Value.
- Returns
Transformed.
- Return type
- Raises
ValueError – Value is not present.
NotImplementedError – Abstract method not implemented.
- abstract _reverse()
Reverse values.
- Returns
Transformed.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract _move(item, target_index)
Move values internally.
- Parameters
- Returns
Transformed.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract _delete(item)
Delete values at index/slice.
- Parameters
- Returns
Transformed.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract _update(index, *values)
Update value(s) starting at index.
- Parameters
index (int) – Index.
values – Value(s).
- Returns
Transformed.
- Return type
- Raises
ValueError – No values provided.
NotImplementedError – Abstract method not implemented.
- class objetto.bases.BaseInteractiveList
Base interactive list collection.
- Inherits from:
- Inherited By:
- insert(index, *values)
Insert value(s) at index.
- Parameters
index (int) – Index.
values – Value(s).
- Returns
Transformed.
- Return type
- Raises
ValueError – No values provided.
- append(value)
Append value at the end.
- Parameters
value – Value.
- Returns
Transformed.
- Return type
- extend(iterable)
Extend at the end with iterable.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
Transformed.
- Return type
- remove(value)
Remove first occurrence of value.
- Parameters
value – Value.
- Returns
Transformed.
- Return type
- Raises
ValueError – Value is not present.
- reverse()
Reverse values.
- Returns
Transformed.
- Return type
- move(item, target_index)
Move values internally.
- Parameters
- Returns
Transformed.
- Return type
- delete(item)
Delete values at index/slice.
- Parameters
- Returns
Transformed.
- Return type
- update(index, *values)
Update value(s) starting at index.
- Parameters
index (int) – Index.
values – Value(s).
- Returns
Transformed.
- Return type
- Raises
ValueError – No values provided.
- class objetto.bases.BaseMutableList
Base mutable list collection.
- Inherits from:
slotted.SlottedMutableSequence
- Inherited By:
- __iadd__(iterable)
In place addition.
- Parameters
iterable (collections.abc.Iterable) – Another iterable.
- Returns
Added list.
- Return type
- abstract __getitem__(index)
Get value/values at index/from slice.
- Parameters
- Returns
Value/values.
- Raises
NotImplementedError – Abstract method not implemented.
- abstract __setitem__(item, value)
Set value/values at index/slice.
- Parameters
- Raises
IndexError – Slice is noncontinuous.
ValueError – Values length does not fit in slice.
NotImplementedError – Abstract method not implemented.
- abstract __delitem__(item)
Delete value/values at index/slice.
- Parameters
- Raises
IndexError – Slice is noncontinuous.
NotImplementedError – Abstract method not implemented.
- abstract pop(index=- 1)
Pop value from index.
- Parameters
index (int) – Index.
- Returns
Value.
- Raises
NotImplementedError – Abstract method not implemented.
- clear()
Clear.
- insert(index, *values)
Insert value(s) at index.
- Parameters
index (int) – Index.
values – Value(s).
- Raises
ValueError – No values provided.
- append(value)
Append value at the end.
- Parameters
value – Value.
- extend(iterable)
Extend at the end with iterable.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- remove(value)
Remove first occurrence of value.
- Parameters
value – Value.
- Raises
ValueError – Value is not present.
- reverse()
Reverse values.
- move(item, target_index)
Move values internally.
- update(index, *values)
Update value(s) starting at index.
- Parameters
index (int) – Index.
values – Value(s).
- Raises
ValueError – No values provided.
Base Set Classes
- class objetto.bases.BaseSet
Base set collection.
- Inherits from:
slotted.SlottedSet
- Inherited By:
- __le__(other)
Less equal operator (self <= other).
- Parameters
other (collections.abc.Set) – Another set or any object.
- Returns
True if considered less equal.
- Return type
- __lt__(other)
Less than operator: self < other.
- Parameters
other (collections.abc.Set) – Another set or any object.
- Returns
True if considered less than.
- Return type
- __gt__(other)
Greater than operator: self > other.
- Parameters
other (collections.abc.Set) – Another set or any object.
- Returns
True if considered greater than.
- Return type
- __ge__(other)
Greater equal operator: self >= other.
- Parameters
other (collections.abc.Set) – Another set or any object.
- Returns
True if considered greater equal.
- Return type
- __and__(other)
Get intersection: self & other.
- Parameters
other (collections.abc.Iterable) – Iterable or any other object.
- Returns
Intersection or NotImplemented if not an iterable.
- Return type
- __rand__(other)
Get intersection: other & self.
- Parameters
other (collections.abc.Iterable) – Iterable or any other object.
- Returns
Intersection or NotImplemented if not an iterable.
- Return type
- __sub__(other)
Get difference: self - other.
- Parameters
other (collections.abc.Iterable) – Iterable or any other object.
- Returns
Difference or NotImplemented if not an iterable.
- Return type
- __rsub__(other)
Get inverse difference: other - self.
- Parameters
other (collections.abc.Iterable) – Iterable or any other object.
- Returns
Inverse difference or NotImplemented if not an iterable.
- Return type
- __or__(other)
Get union: self | other.
- Parameters
other (collections.abc.Iterable) – Iterable or any other object.
- Returns
Union or NotImplemented if not an iterable.
- Return type
- __ror__(other)
Get union: other | self.
- Parameters
other (collections.abc.Iterable) – Iterable or any other object.
- Returns
Union or NotImplemented if not an iterable.
- Return type
- __xor__(other)
Get symmetric difference: self ^ other.
- Parameters
other (collections.abc.Iterable) – Iterable or any other object.
- Returns
Symmetric difference or NotImplemented if not an iterable.
- Return type
- __rxor__(other)
Get symmetric difference: other ^ self.
- Parameters
other (collections.abc.Iterable) – Iterable or any other object.
- Returns
Symmetric difference or NotImplemented if not an iterable.
- Return type
- abstract __eq__(other)
Compare for equality.
- Parameters
other – Another object.
- Returns
True if equal.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract classmethod _from_iterable(iterable)
Make set from iterable.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
Set.
- Raises
NotImplementedError – Abstract method not implemented.
- abstract _hash()
Get hash.
- Returns
Hash.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract isdisjoint(iterable)
Get whether is a disjoint set of an iterable.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
True if is disjoint.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract issubset(iterable)
Get whether is a subset of an iterable.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
True if is subset.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract issuperset(iterable)
Get whether is a superset of an iterable.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
True if is superset.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract intersection(iterable)
Get intersection.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
Intersection.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract symmetric_difference(iterable)
Get symmetric difference.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
Symmetric difference.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract union(iterable)
Get union.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
Union.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract difference(iterable)
Get difference.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
Difference.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract inverse_difference(iterable)
Get an iterable’s difference to this.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
Inverse Difference.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- class objetto.bases.BaseProtectedSet
Base protected set collection.
- Inherits from:
- Inherited By:
- abstract _add(value)
Add value.
- Parameters
value – Value.
- Returns
Transformed.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract _discard(*values)
Discard value(s).
- Parameters
values (collections.abc.Hashable) – Value(s).
- Returns
Transformed.
- Return type
- Raises
ValueError – No values provided.
NotImplementedError – Abstract method not implemented.
- abstract _remove(*values)
Remove existing value(s).
- Parameters
values (collections.abc.Hashable) – Value(s).
- Returns
Transformed.
- Return type
- Raises
ValueError – No values provided.
KeyError – Value is not present.
NotImplementedError – Abstract method not implemented.
- abstract _replace(old_value, new_value)
Replace existing value with a new one.
- Parameters
old_value – Existing value.
new_value – New value.
- Returns
Transformed.
- Return type
- Raises
KeyError – Value is not present.
NotImplementedError – Abstract method not implemented.
- abstract _update(iterable)
Update with iterable.
- Parameters
iterable (collections.abc.Iterable[collections.abc.Hashable]) – Iterable.
- Returns
Transformed.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- class objetto.bases.BaseInteractiveSet
Base interactive set collection.
- Inherits from:
- Inherited By:
- add(value)
Add value.
- Parameters
value – Value.
- Returns
Transformed.
- Return type
- discard(*values)
Discard value(s).
- Parameters
values (collections.abc.Hashable) – Value(s).
- Returns
Transformed.
- Return type
- Raises
ValueError – No values provided.
- remove(*values)
Remove existing value(s).
- Parameters
values (collections.abc.Hashable) – Value(s).
- Returns
Transformed.
- Return type
- Raises
ValueError – No values provided.
KeyError – Value is not present.
- replace(old_value, new_value)
Replace existing value with a new one.
- Parameters
old_value – Existing value.
new_value – New value.
- Returns
Transformed.
- Return type
- Raises
KeyError – Old value is not present.
- update(iterable)
Update with iterable.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
Transformed.
- Return type
- class objetto.bases.BaseMutableSet
Base mutable set collection.
- Inherits from:
slotted.SlottedMutableSet
- Inherited By:
- __iand__(iterable)
Intersect in place: self &= iterable.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
This mutable set.
- Return type
- __isub__(iterable)
Difference in place: self -= iterable.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
This mutable set.
- Return type
- __ior__(iterable)
Update in place: self |= iterable.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
This mutable set.
- Return type
- __ixor__(iterable)
Symmetric difference in place: self ^= iterable.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
This mutable set.
- Return type
- abstract pop()
Pop value.
- Returns
Value.
- Raises
KeyError – Empty set.
NotImplementedError – Abstract method not implemented.
- abstract intersection_update(iterable)
Intersect.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Raises
NotImplementedError – Abstract method not implemented.
- abstract symmetric_difference_update(iterable)
Symmetric difference.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Raises
NotImplementedError – Abstract method not implemented.
- abstract difference_update(iterable)
Difference.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Raises
NotImplementedError – Abstract method not implemented.
- clear()
Clear.
- add(value)
Add value.
- Parameters
value – Value.
- discard(*values)
Discard value(s).
- Parameters
values (collections.abc.Hashable) – Value(s).
- Raises
ValueError – No values provided.
- remove(*values)
Remove existing value(s).
- Parameters
values (collections.abc.Hashable) – Value(s).
- Raises
ValueError – No values provided.
KeyError – Value is not present.
- replace(old_value, new_value)
Replace existing value with a new one.
- Parameters
old_value – Existing value.
new_value – New value.
- update(iterable)
Update with iterable.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
Base Exception Class
- class objetto.bases.BaseObjettoException
Base Objetto exception.
- Inherits from:
- Inherited By:
Base State Class
- class objetto.bases.BaseState(initial=())
Base immutable state.
- Inherits from:
- Inherited By:
- Parameters
initial – Initial values.
- Raises
NotImplementedError – Abstract methods not implemented.
- abstract __eq__(other)
Compare for equality.
- Parameters
other – Another object.
- Returns
True if equal.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- __copy__()
Get copy.
- Returns
Copy.
- Return type
- abstract __repr__()
Get representation.
- Returns
Representation.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- abstract property _internal
Internal values.
Base Structure Classes
- class objetto.bases.BaseStructureMeta(name, bases, dct)
Metaclass for
objetto.bases.BaseStructure.- Inherits from:
- Inherited by:
- Features:
Support for unique descriptors.
Defines serializable structure type.
- property _unique_descriptor
Unique descriptor or None.
- Return type
objetto.objects.UniqueDescriptor or objetto.data.UniqueDescriptor or None
- abstract property _serializable_structure_types
Serializable structure types.
- Return type
- property _relationship_type
Relationship type.
- Return type
- class objetto.bases.BaseStructure
Base structure.
- Metaclass:
- Inherits from:
- Inherited By:
- Features:
Is hashable.
Is a protected collection.
Has state.
Unique hash based on ID if unique descriptor is defined.
Holds values at locations.
Has a relationship for each location.
Serializes/deserializes values and itself.
- __eq__(other)
Compare with another object for equality/identity.
- Parameters
other – Another object.
- Returns
True if equal or the exact same object.
- Return type
- _hash()
Abstract
Get hash.
- Returns
Hash.
- Return type
- Raises
RuntimeError – Abstract method not implemented by subclasses.
- _eq(other)
Abstract
Compare with another object for equality.
- Parameters
other – Another object.
- Returns
True if equal.
- Return type
- Raises
RuntimeError – Abstract method not implemented by subclasses.
- abstract classmethod _get_relationship(location)
Get relationship at location.
- Parameters
location (collections.abc.Hashable) – Location.
- Returns
Relationship.
- Return type
- Raises
KeyError – Invalid location.
- classmethod deserialize_value(serialized, location=None, **kwargs)
Deserialize value for location.
- Parameters
serialized – Serialized value.
location (collections.abc.Hashable) – Location.
kwargs – Keyword arguments to be passed to the deserializers.
- Returns
Deserialized value.
- Raises
objetto.exceptions.SerializationError – Can’t deserialize value.
ValueError – Keyword arguments contain reserved keys.
- serialize_value(value, location=None, **kwargs)
Serialize value for location.
- Parameters
value – Value.
location (collections.abc.Hashable) – Location.
kwargs – Keyword arguments to be passed to the serializers.
- Returns
Serialized value.
- Raises
objetto.exceptions.SerializationError – Can’t serialize value.
ValueError – Keyword arguments contain reserved keys.
- abstract classmethod deserialize(serialized, **kwargs)
Deserialize.
- Parameters
serialized – Serialized.
kwargs – Keyword arguments to be passed to the deserializers.
- Returns
Deserialized.
- Return type
- Raises
objetto.exceptions.SerializationError – Can’t deserialize.
- abstract serialize(**kwargs)
Serialize.
- Parameters
kwargs – Keyword arguments to be passed to the serializers.
- Returns
Serialized.
- Raises
objetto.exceptions.SerializationError – Can’t serialize.
- abstract property _state
State.
- Return type
- class objetto.bases.BaseInteractiveStructure
Base interactive structure.
- Inherits from:
- Inherited By:
- Features:
Is an interactive collection/structure.
- class objetto.bases.BaseMutableStructure
Base mutable structure.
- Inherits from:
- Inherited By:
- Features:
Is a mutable collection/structure.
- class objetto.bases.BaseAuxiliaryStructureMeta(name, bases, dct)
Metaclass for
objetto.bases.BaseAuxiliaryStructure.- Inherits from:
- Inherited by:
- Features:
Defines a base auxiliary type.
Enforces correct type for
objetto.bases.BaseAuxiliaryStructure._relationship.
- abstract property _base_auxiliary_type
Base auxiliary structure type.
- Return type
- class objetto.bases.BaseAuxiliaryStructure
Structure with a single relationship for all locations.
- Inherits from:
- Inherited By:
- find_with_attributes(**attributes)
Find first value that matches unique attribute values.
- Parameters
attributes – Attributes to match.
- Returns
Value that has matching attributes.
- Raises
ValueError – No attributes provided or no match found.
- classmethod _get_relationship(location=None)
Get relationship.
- Parameters
location (collections.abc.Hashable) – Location.
- Returns
Relationship.
- Return type
- _relationship = BaseRelationship(checked=False, deserializer=None, factory=None, module=None, represented=True, serialized=True, serializer=None, subtypes=False, types=frozenset())
Class Attribute
Relationship for all locations.
- class objetto.bases.BaseInteractiveAuxiliaryStructure
Base interactive auxiliary structure.
- class objetto.bases.BaseMutableAuxiliaryStructure
Base mutable auxiliary structure.
Base Dict Structure Classes
- class objetto.bases.BaseDictStructureMeta(name, bases, dct)
Metaclass for
objetto.bases.BaseDictStructure.- Inherits from:
- Inherited by:
- Features:
Defines a key relationship type.
Enforces correct type for
objetto.bases.BaseDictStructure._key_relationship.
- property _key_relationship_type
Relationship type.
- Return type
type[objetto.objects.KeyRelationship or objetto.data.KeyRelationship]
- class objetto.bases.BaseDictStructure
Base dictionary structure.
- Metaclass:
- Inherits from:
- Inherited By:
- __reversed__()
Iterate over reversed keys.
- Returns
Reversed keys iterator.
- Return type
- __getitem__(key)
Get value for key.
- Parameters
key (collections.abc.Hashable) – Key.
- Returns
Value.
- Raises
KeyError – Invalid key.
- __iter__()
Iterate over keys.
- Returns
Key iterator.
- Return type
- __contains__(key)
Get whether key is present.
- Parameters
key (collections.abc.Hashable) – Key.
- Returns
True if contains.
- Return type
- get(key, fallback=None)
Get value for key, return fallback value if key is not present.
- Parameters
key (collections.abc.Hashable) – Key.
fallback – Fallback value.
- Returns
Value or fallback value.
- iteritems()
Iterate over items.
- Returns
Items iterator.
- Return type
collections.abc.Iterator[tuple[collections.abc.Hashable, Any]]
- iterkeys()
Iterate over keys.
- Returns
Keys iterator.
- Return type
- itervalues()
Iterate over values.
- Returns
Values iterator.
- Return type
- _key_relationship = KeyRelationship(checked=False, factory=None, module=None, subtypes=False, types=frozenset())
Class Attribute
Relationship for the keys.
- abstract property _state
Internal state.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- class objetto.bases.BaseInteractiveDictStructure
Base interactive dictionary structure.
- class objetto.bases.BaseMutableDictStructure
Base mutable dictionary structure.
Base List Structure Classes
- class objetto.bases.BaseListStructureMeta(name, bases, dct)
Metaclass for
objetto.bases.BaseListStructure.- Inherits from:
- Inherited by:
- class objetto.bases.BaseListStructure
Base list structure.
- Metaclass:
- Inherits from:
- Inherited By:
- __reversed__()
Iterate over reversed values.
- Returns
Reversed values iterator.
- Return type
- __iter__()
Iterate over values.
- Returns
Values iterator.
- Return type
- __contains__(value)
Get whether value is present.
- Parameters
value – Value.
- Returns
True if contains.
- Return type
- count(value)
Count number of occurrences of a value.
- Returns
Number of occurrences.
- Return type
- index(value, start=None, stop=None)
Get index of a value.
- Parameters
- Returns
Index of value.
- Return type
- Raises
ValueError – Provided stop but did not provide start.
- resolve_index(index, clamp=False)
Resolve index to a positive number.
- Parameters
- Returns
Resolved index.
- Return type
- Raises
IndexError – Index out of range.
- resolve_continuous_slice(slc)
Resolve continuous slice according to length.
- Parameters
slc (slice) – Continuous slice.
- Returns
Index and stop.
- Return type
- Raises
IndexError – Slice is noncontinuous.
- abstract property _state
Internal state.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- class objetto.bases.BaseInteractiveListStructure
Base interactive list structure.
- class objetto.bases.BaseMutableListStructure
Base mutable list structure.
Base Set Structure Classes
- class objetto.bases.BaseSetStructureMeta(name, bases, dct)
Metaclass for
objetto.bases.BaseSetStructure.- Inherits from:
- Inherited by:
- class objetto.bases.BaseSetStructure
Base set structure.
- Metaclass:
- Inherits from:
- Inherited By:
- __iter__()
Iterate over values.
- Returns
Values iterator.
- Return type
- __contains__(value)
Get whether value is present.
- Parameters
value (collections.abc.Hashable) – Value.
- Returns
True if contains.
- Return type
- isdisjoint(iterable)
Get whether is a disjoint set of an iterable.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
True if is disjoint.
- Return type
- issubset(iterable)
Get whether is a subset of an iterable.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
True if is subset.
- Return type
- issuperset(iterable)
Get whether is a superset of an iterable.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
True if is superset.
- Return type
- intersection(iterable)
Get intersection.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
Intersection.
- Return type
- difference(iterable)
Get difference.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
Difference.
- Return type
- inverse_difference(iterable)
Get an iterable’s difference to this.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
Inverse Difference.
- Return type
- symmetric_difference(iterable)
Get symmetric difference.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
Symmetric difference.
- Return type
- union(iterable)
Get union.
- Parameters
iterable (collections.abc.Iterable) – Iterable.
- Returns
Union.
- Return type
- abstract property _state
Internal state.
- Return type
- Raises
NotImplementedError – Abstract method not implemented.
- class objetto.bases.BaseInteractiveSetStructure
Base interactive set structure.
- class objetto.bases.BaseMutableSetStructure
Base mutable set structure.
Base Attribute Structure Classes
- class objetto.bases.BaseAttributeStructureMeta(name, bases, dct)
Metaclass for
objetto.bases.BaseAttributeStructure.- Inherits from:
- Inherited by:
- Features:
Support for
objetto.bases.BaseAttributedescriptors.
- abstract property _attribute_type
Attribute type.
- Return type
- property _attributes
Attributes mapped by name.
- Return type
- property _attribute_names
Names mapped by attribute.
- Return type
- class objetto.bases.BaseAttributeStructure
Base attribute structure.
- Metaclass:
- Inherits from:
- Inherited by:
- Features:
Holds values in attributes defined by descriptors.
Can be cast into a dictionary.
- __reversed__()
Iterate over reversed attribute names.
- Returns
Reversed attribute names iterator.
- Return type
- __getitem__(name)
Get value for attribute name.
- __len__()
Get count of attributes with value.
- Returns
Count of attributes with value.
- Return type
- __iter__()
Iterate over names of attributes with value.
- Returns
Names of attributes with value.
- Return type
- __contains__(name)
Get whether attribute name is valid and has a value.
- classmethod _get_relationship(location)
Get relationship at location (attribute name).
- classmethod _get_attribute(name)
Get attribute by name.
- abstract _set(name, value)
Set attribute value.
- Parameters
name (str) – Attribute name.
value – Value.
- Returns
Transformed.
- Return type
- Raises
AttributeError – Attribute is not changeable and already has a value.
- abstract _delete(name)
Delete attribute value.
- Parameters
name (str) – Attribute name.
- Returns
Transformed.
- Return type
- Raises
KeyError – Attribute does not exist or has no value.
AttributeError – Attribute is not deletable.
- abstract _update(*args, **kwargs)
Update multiple attribute values. Same parameters as
dict.update().- Returns
Transformed.
- Return type
- Raises
AttributeError – Attribute is not changeable and already has a value.
- keys()
Get names of the attributes with values.
- Returns
Attribute names.
- Return type
- find_with_attributes(**attributes)
Find first value that matches unique attribute values.
- Parameters
attributes – Attributes to match.
- Returns
Value.
- Raises
ValueError – No attributes provided or no match found.
- abstract property _state
Internal state.
- Return type
objetto.states.DictState[str, Any]
- class objetto.bases.BaseInteractiveAttributeStructure
Base interactive attribute structure.
- Inherits from:
- Inherited by:
- set(name, value)
Set attribute value.
- Parameters
name (str) – Attribute name.
value – Value.
- Returns
Transformed.
- Return type
- Raises
AttributeError – Attribute is not changeable and already has a value.
- delete(name)
Delete attribute value.
- Parameters
name (str) – Attribute name.
- Returns
Transformed.
- Return type
- Raises
KeyError – Attribute does not exist or has no value.
AttributeError – Attribute is not deletable.
- update(*args, **kwargs)
Update multiple attribute values. Same parameters as
dict.update().- Returns
Transformed.
- Return type
- Raises
AttributeError – Attribute is not changeable and already has a value.
- class objetto.bases.BaseMutableAttributeStructure
Base mutable attribute structure.
- Inherits from:
- Inherited by:
- __setitem__(name, value)
Set attribute value.
- __delitem__(name)
Delete attribute value.
- delete(name)
Delete attribute value.
- set(name, value)
Set attribute value.
- update(*args, **kwargs)
Update multiple attribute values. Same parameters as
dict.update().- Raises
KeyError – Attribute does not exist.
Base Relationship Class
- class objetto.bases.BaseRelationship(types=(), subtypes=False, checked=None, module=None, factory=None, serialized=True, serializer=None, deserializer=None, represented=True)
Relationship between a structure and its values.
- Inherits from:
- Inherited by:
- Parameters
types (str or type or None or tuple[str or type or None]) – Types.
subtypes (bool) – Whether to accept subtypes.
checked (bool) – Whether to perform runtime type check.
module (str or None) – Module path for lazy types/factories.
factory (str or collections.abc.Callable or None) – Value factory.
serialized (bool) – Whether should be serialized.
serializer (str or collections.abc.Callable or None) – Custom serializer.
deserializer (str or collections.abc.Callable or None) – Custom deserializer.
represented (bool) – Whether should be represented.
- Raises
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
- __eq__(other)
Compare with another object for equality.
- Parameters
other – Another object.
- Returns
True if considered equal.
- Return type
- get_single_exact_type(types=(<class 'type'>, ))
Get single exact type from available types if possible.
- fabricate_value(value, factory=True, **kwargs)
Perform type check and run value through factory.
- Parameters
value – Value.
factory (bool) – Whether to run value through factory.
kwargs – Keyword arguments to be passed to the factory.
- Returns
Fabricated value.
- property factory
Value factory.
- Return type
str or collections.abc.Callable or None
- property serializer
Custom serializer.
- Return type
str or collections.abc.Callable or None
- property deserializer
Custom deserializer.
- Return type
str or collections.abc.Callable or None
Base Attribute Class
- class objetto.bases.BaseAttributeMeta(name, bases, dct)
Metaclass for
objetto.bases.BaseAttribute.- Inherits from:
- Inherited by:
- Features:
Defines relationship type.
- abstract property _relationship_type
Relationship type.
- Return type
- class objetto.bases.BaseAttribute(relationship=BaseRelationship(checked=False, deserializer=None, factory=None, module=None, represented=True, serialized=True, serializer=None, subtypes=False, types=frozenset()), default=<objetto._bases.bases.MISSING object>, default_factory=None, module=None, required=True, changeable=True, deletable=False, finalized=False, abstracted=False, metadata=None)
Base attribute descriptor for
objetto.bases.BaseAttributeStructureclasses.- Metaclass:
- Inherits from:
- Inherited by:
- Parameters
relationship (objetto.bases.BaseRelationship) – Relationship.
default – Default value.
default_factory (str or collections.abc.Callable or None) – Default value factory.
module (str or None) – Optional module path to use in case partial paths are provided.
required (bool) – Whether attribute is required to have a value or not.
changeable (bool) – Whether attribute value can be changed.
deletable (bool) – Whether attribute value can be deleted.
finalized (bool) – If True, attribute can’t be overridden by subclasses.
abstracted (bool) – If True, attribute needs to be overridden by subclasses.
metadata – Metadata.
- Raises
TypeError – Invalid parameter type.
ValueError – Invalid parameter value.
ValueError – Can’t specify both ‘default’ and ‘default_factory’ arguments.
ValueError – Can’t be ‘required’ and ‘deletable’ at the same time.
ValueError – Can’t be ‘finalized’ and ‘abstracted’ at the same time.
- __get__(instance, owner)
Get attribute value when accessing from valid instance or when attribute is constant. Get this descriptor otherwise.
- Parameters
instance (objetto.bases.BaseAttributeStructure or None) – Instance.
owner (type[objetto.bases.BaseAttributeStructure]) – Owner class.
- Returns
Value or this descriptor.
- Return type
Any or objetto.bases.BaseAttribute
- __eq__(other)
Compare with another object for identity.
- Parameters
other – Another object.
- Returns
True if the same object.
- Return type
- copy(**kwargs)
Make a copy of this attribute and optionally change some of its parameters.
- Parameters
kwargs – New parameters.
- Returns
New attribute.
- Return type
- get_name(instance)
Get attribute name.
- Parameters
instance (objetto.bases.BaseAttributeStructure) – Instance.
- Returns
Attribute Name.
- Return type
- get_value(instance)
Get attribute value.
- Parameters
instance (objetto.bases.BaseAttributeStructure) – Instance.
- Returns
Attribute Value.
- Raises
AttributeError – Could not get value.
- fabricate_default_value(**kwargs)
Fabricate default value.
- Parameters
kwargs – Keyword arguments to be passed to the factories.
- Returns
Fabricated value.
- Raises
ValueError – No default or default factory.
- property relationship
Relationship.
- Return type
- property default
Default value.
- property default_factory
Default value factory.
- Return type
str or collections.abc.Callable or None
Base Data Classes
- class objetto.bases.BaseDataMeta(name, bases, dct)
Metaclass for
objetto.bases.BaseData.- Inherits from:
- Inherited by:
- Features:
Defines serializable structure type as
objetto.bases.BaseData.Defines a relationship type as
objetto.data.DataRelationship.
- property _serializable_structure_types
Serializable structure types.
- Return type
- property _relationship_type
Relationship type.
- Return type
- class objetto.bases.BaseData
Base data.
- Metaclass:
- Inherits from:
- Inherited by:
- Features:
Is an immutable protected structure.
- __copy__()
Get copy.
- Returns
Copy.
- Return type
- __invariant__()
Gets called whenever a new instance is made. Can be used for validation.
- property _state
State.
- Return type
- class objetto.bases.BaseInteractiveData
Base interactive data.
- Inherits from:
- Inherited by:
- Features:
Is an immutable interactive data structure.
- class objetto.bases.BaseAuxiliaryDataMeta(name, bases, dct)
Metaclass for
objetto.bases.BaseAuxiliaryData.- Inherits from:
- Inherited by:
- Features:
Defines a base auxiliary type.
- abstract property _base_auxiliary_type
Base auxiliary data type.
- Return type
- class objetto.bases.BaseAuxiliaryData
Base auxiliary data.
- Metaclass:
- Inherits from:
- Inherited by:
- _eq(other)
Compare with another object for equality.
- Parameters
other – Another object.
- Returns
True if equal.
- Return type
- find_with_attributes(**attributes)
Find first value that matches unique attribute values.
- Parameters
attributes – Attributes to match.
- Returns
Value.
- Raises
ValueError – No attributes provided or no match found.
- _relationship = DataRelationship(checked=False, compared=True, deserializer=None, factory=None, module=None, represented=True, serialized=True, serializer=None, subtypes=False, types=frozenset())
Relationship for all locations.
- class objetto.bases.BaseInteractiveAuxiliaryData
Base interactive auxiliary data.
Base Object Classes
- class objetto.bases.BaseObjectMeta(name, bases, dct)
Metaclass for
objetto.bases.BaseObject.- Inherits from:
- Inherited by:
- Features:
Support for history descriptors.
Stores data methods.
Defines a state factory.
Defines serializable structure types as
objetto.bases.BaseDataandobjetto.bases.BaseObject.Defines a relationship type as
objetto.objects.Relationship.Constructs automatic Data class.
- Raises
TypeError – Class has multiple history descriptors.
- abstract property _state_factory
State factory.
- Return type
- property _serializable_structure_types
Serializable structure types.
- Return type
tuple[type[objetto.bases.BaseObject], type[objetto.bases.BaseData]]
- property _relationship_type
Relationship type.
- Return type
- property _history_descriptor
History descriptor or None.
- Return type
objetto.objects.HistoryDescriptor or None
- property _reactions
Reactions sorted by priority.
- Return type
- abstract property Data
Data type.
- Return type
- class objetto.bases.BaseObject(app)
Base object.
- Metaclass:
- Inherits from:
- Inherited By:
- Features:
Is a protected structure.
- Parameters
app (objetto.applications.Application) – Application.
- __copy__()
Get copy by using serialization.
- Returns
Copy.
- Return type
- __post_deserialize__()
This magic method gets automatically called after deserialization.
- _eq(other)
Compare with another object for identity.
- Parameters
other – Another object.
- Returns
True if the same object.
- Return type
- abstract _locate(child)
Locate child object.
- Parameters
child (objetto.bases.BaseObject) – Child object.
- Returns
Location.
- Return type
- Raises
ValueError – Could not locate child.
- abstract _locate_data(child)
Locate child object’s data.
- Parameters
child (objetto.bases.BaseObject) – Child object.
- Returns
Data location.
- Return type
- Raises
ValueError – Could not locate child’s data.
- _in_same_application(value)
Get whether a value is an object and belongs to the same application as this.
- Parameters
value – Any value or object.
- Returns
True if is an object and belongs to the same application.
- Return type
- _batch_context()
Batch context.
- Parameters
name (str) – Batch name.
metadata – Metadata.
- Returns
Batch context manager.
- Return type
contextlib.AbstractContextManager[collections.abc.Iterator[objetto.changes.Batch]]
- abstract classmethod deserialize(serialized, app=None, **kwargs)
Deserialize.
- Parameters
serialized – Serialized.
app (objetto.applications.Application) – Application (required).
kwargs – Keyword arguments to be passed to the deserializers.
- Returns
Deserialized.
- Return type
- Raises
ValueError – Missing required ‘app’ attribute.
objetto.exceptions.SerializationError – Can’t deserialize.
- property _state
State.
- Return type
objetto.states.BaseState
- property _parent
Parent object or None.
- Return type
objetto.bases.BaseObject or None
- property _children
Children objects.
- Return type
- property _history
History.
- Return type
objetto.history.HistoryObject or None
- property app
Application.
- Return type
- property data
Data.
- Return type
objetto.bases.BaseData or None
- class objetto.bases.BaseMutableObject(app)
Base mutable object.
- Inherits from:
- Inherited By:
objetto.objects.BaseMutableAuxiliaryObject
- Features:
Is an mutable object structure.
- class objetto.bases.BaseAuxiliaryObjectMeta(name, bases, dct)
Metaclass for
objetto.bases.BaseAuxiliaryObject.- Inherits from:
- Inherited by:
- Features:
Defines a base auxiliary type.
Defines a base auxiliary Data type.
Constructs automatic Data class.
- abstract property _base_auxiliary_type
Base auxiliary object type.
- Return type
- abstract property _base_auxiliary_data_type
Base auxiliary data type.
- Return type
- property Data
Data type.
- Return type
- class objetto.bases.BaseAuxiliaryObject(app)
Base auxiliary object.
- Metaclass:
- Inherits from:
- Inherited By:
- find_with_attributes(**attributes)
Find first value that matches unique attribute values. This method will be optimized if the auxiliary objects is utiling the
objetto.reactions.UniqueAttributesreaction, which caches unique attributes as indexes.- Parameters
attributes – Attributes to match.
- Returns
Value.
- Raises
ValueError – No attributes provided or no match found.
- _relationship = Relationship(checked=False, child=True, data=True, data_relationship=DataRelationship(checked=False, compared=True, deserializer=None, factory=None, module=None, represented=True, serialized=True, serializer=None, subtypes=False, types=frozenset()), deserializer=None, factory=None, history=True, module=None, represented=True, serialized=True, serializer=None, subtypes=False, types=frozenset())
Relationship for all locations.
- class objetto.bases.BaseMutableAuxiliaryObject(app)
Base mutable auxiliary object.
Base Proxy Object Class
- class objetto.bases.BaseProxyObject(obj)
Base auxiliary proxy object.
- Inherits from:
- Inherited By:
- Parameters
obj (objetto.bases.BaseAuxiliaryObject) – Auxiliary object.
- __eq__(other)
Compare with another object for identity.
- Parameters
other – Another object.
- Returns
True if the same object.
- Return type
- __iter__()
Iterate over.
- Returns
Iterator.
- Return type
- __contains__(value)
Get whether value is present.
- Parameters
value – Value.
- Returns
True if contains.
- Return type
- _clear()
Clear.
- Returns
Transformed.
- Return type
- find_with_attributes(**attributes)
Find first value that matches unique attribute values.
- Parameters
attributes – Attributes to match.
- Returns
Value that has matching attributes.
- Raises
ValueError – No attributes provided or no match found.
- property _obj
Auxiliary object.
- Return type
- property _state
State.
- Return type
- property _parent
Parent object or None.
- Return type
objetto.bases.BaseObject or None
- property _children
Children objects.
- Return type
- property _history
History or None.
- Return type
objetto.history.HistoryObject or None
- property app
Application.
- Return type
- property data
Data.
- Return type
objetto.bases.BaseData or None
Base Reaction Class
- class objetto.bases.BaseReaction
Base method-like that gets called whenever an action is sent through the object.
- Inherits from:
- Inherited by:
- abstract __call__(obj, action, phase)
React to actions.
- Parameters
obj (objetto.bases.BaseObject) – Object.
action (objetto.objects.Action) – Action.
phase (
objetto.constants.PREorobjetto.constants.POST) – Phase.
- __get__(instance, owner)
Get bound reaction method from valid instance or this descriptor otherwise.
- Parameters
instance (objetto.bases.BaseObject or None) – Instance.
owner (type[objetto.bases.BaseObject]) – Owner class.
- Returns
Bound reaction method or this descriptor.
- Return type
function or objetto.bases.BaseReaction
- __eq__(other)
Compare with another object for equality.
- Parameters
other – Another object.
- Returns
True if considered equal.
- Return type
Base Factory Class
- class objetto.bases.BaseFactory
Base callable factory object.
- Inherits from:
- Inherited By:
- abstract __call__(value, **kwargs)
Call with input value and optional keyword arguments.
- Parameters
value – Input value.
kwargs – Keyword arguments.
- Returns
Output value.
- __add__(other)
Add with another factory.
- Parameters
other (objetto.bases.BaseFactoryor str or collections.abc.Callable or None) – Another factory.
- Returns
Multi factory with added factories.
- Return type
Base Serializer Class
Base Deserializer Class
Base Change Classes
- class objetto.bases.BaseChange(**initial)
Base change.
- Inherits from:
- Inherited By:
- obj : Data Attribute
Object being changed.
- class objetto.bases.BaseAtomicChange(**initial)
Base atomic change.
- Inherits from:
- Inherited By:
- old_state : Data Attribute
Object state before the change.
- new_state : Data Attribute
Object state after the change.
- old_children : Data Attribute
Children objects being released.
- new_children : Data Attribute
Children objects being adopted.
- history_adopters : Data Attribute
Objects adopting the history from the object being changed.
- history : Data Attribute
History where this changed originated from (result of an redo/undo operation).
- Type
objetto.history.HistoryObject or None
Base Phase Enum
Abstract Member Classes
- final class objetto.bases.AbstractMemberMeta(name, bases, dct)
Metaclass for
objetto.bases.AbstractMember.- Inherits from:
- Features:
Enforces abstract tag.
- final class objetto.bases.AbstractMember(*args, **kwargs)
Abstract member for classes.
Note
Do not use this class directly. Use the helper function
objetto.bases.abstract_member()instead.- Metaclass:
- Inherits from:
- Features:
Prevents class from instantiating if not overriden by a concrete member.