adorn.orchestrator.base module
Vanilla coordinator
- class adorn.orchestrator.base.Base(units, alters=None)
Bases:
adorn.orchestrator.orchestrator.Orchestrator
Vanilla coordinator between different
Unit
Base
finds the firstUnit
specified in the list ofUnit
that contains a type and delegates the action to the givenUnit
. Therefore, the earlier aUnit
appears inunits
the higher priority it has in the orchestrator.- Parameters
- Return type
None
- a_get(cls, obj)
Finds all the
Alter
associated with cls- Parameters
cls (Type) – a type that you want to check or convert the
obj
intoobj (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
obj
intoobj (Any) – the object to be type checked or converted into
cls
- Returns
- Either an unaltered
obj
is returned, when no :class`~adorn.alter.alter.Alter` in
alters
contains the givencls
andobj
, an alteredobj
is returned when the givencls
andobj
is 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
Unit
that containscls
. Then the instantiating is delegated to the relevantUnit
.- Parameters
cls (Type) – the type
obj
would 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
TypeCheckError
indicating there was an issue applying a dynamic alteration toobj
- get(cls)
Finds the
Unit
associated with cls- Parameters
cls (Type) – a type that you want the associated
Unit
of- Returns
The collection of types that contains
cls
- Return type
- Raises
TypeCheckError –
cls
cannot be represented by any of theUnit
contained 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
obj
intoobj (Any) – the object converted into
cls
instance (Any) – the object created from converting
obj
into 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
Unit
that containscls
. Then the type checking is delegated to the relevantUnit
.- Parameters
cls (Type) – the type
obj
would be converted intoobj (Any) – an instance to be converted into type
cls
- Returns
- if
None
,obj
can be converted to an instance of
cls
, otherwise an error is returned explaining why anobj
cannot be converted to an instance ofcls
- if
- Return type
Optional[TypeCheckError]
- units: List[adorn.unit.unit.Unit]
a collection of collection of types