adorn.orchestrator.base module
Vanilla coordinator
- class adorn.orchestrator.base.Base(units, alters=None)
Bases:
adorn.orchestrator.orchestrator.OrchestratorVanilla coordinator between different
UnitBasefinds the firstUnitspecified in the list ofUnitthat contains a type and delegates the action to the givenUnit. Therefore, the earlier aUnitappears inunitsthe higher priority it has in the orchestrator.- Parameters
- Return type
None
- a_get(cls, obj)
Finds all the
Alterassociated with cls- Parameters
cls (Type) – a type that you want to check or convert the
objintoobj (Any) – the object to be type checked or converted into
cls
- Returns
- the classes requested to perform a dynamic alteration
to the
obj
- Return type
List[Alter]
- alter_obj(cls, obj)
Potentially perform a dynamic alteration to an object
- Parameters
cls (Type) – a type that you want to check or convert the
objintoobj (Any) – the object to be type checked or converted into
cls
- Returns
- Either an unaltered
objis returned, when no :class`~adorn.alter.alter.Alter` in
alterscontains the givenclsandobj, an alteredobjis returned when the givenclsandobjis contained by an :class`~adorn.alter.alter.Alter` inalters, or aTypeCheckError, when there was an issue performing a dynamic alteration to theobj
- Either an unaltered
- Return type
Union[Any, TypeCheckError]
- from_obj(cls, obj)
Generate an instance of type cls from obj
First, the code gets the
Unitthat containscls. Then the instantiating is delegated to the relevantUnit.- Parameters
cls (Type) – the type
objwould be converted intoobj (Any) – an instance to be converted into type
cls
- Returns
an instance of type
cls, that was created fromobj- Return type
Any
- Raises
obj – obj is a
TypeCheckErrorindicating there was an issue applying a dynamic alteration toobj
- get(cls)
Finds the
Unitassociated with cls- Parameters
cls (Type) – a type that you want the associated
Unitof- Returns
The collection of types that contains
cls- Return type
- Raises
TypeCheckError –
clscannot be represented by any of theUnitcontained in the orchestrator
- log_instance(cls, obj, instance)
Potentially perform a dynamic logging of instantiated instances
- Parameters
cls (Type) – a type that you converted the
objintoobj (Any) – the object converted into
clsinstance (Any) – the object created from converting
objinto an instance ofcls
- Return type
None
- type_check(cls, obj)
Check if obj can be converted to type of cls
First, the code gets the
Unitthat containscls. Then the type checking is delegated to the relevantUnit.- Parameters
cls (Type) – the type
objwould be converted intoobj (Any) – an instance to be converted into type
cls
- Returns
- if
None,objcan be converted to an instance of
cls, otherwise an error is returned explaining why anobjcannot be converted to an instance ofcls
- if
- Return type
Optional[TypeCheckError]
- units: List[adorn.unit.unit.Unit]
a collection of collection of types