adorn.alter.dict_alter module
Apply an alteration to an object based off a dict
- class adorn.alter.dict_alter.EnvDictAlter
Bases:
adorn.alter.dict_alter.UserDictAlter
Inject values from the environment
- Return type
None
- class adorn.alter.dict_alter.UserDictAlter(user_dict)
Bases:
adorn.alter.alter.Alter
Inject a value from a user provided
dict
- Parameters
user_dict (Dict[str, Any]) – dictionary which contains values to be injected
- Return type
None
- a_contains(target_cls, orchestrator, obj)
Check if a value in
user_dict
has been requested- Parameters
target_cls (Type) – the target Type, the given
obj
will be converted into or checked againstorchestrator (Orchestrator) – container of all types, typically used to recurse down nested types
obj (Any) – an instance, that will be checked to see if it can be converted into the
target_cls
or will be converted to an instance oftarget_cls
- Returns
- if
True
then a value in the user dict has been requested else
False
- if
- Return type
bool
- a_get(target_cls, orchestrator, obj)
Return this
Alter
if the associated with the arguments are requesting it- Parameters
target_cls (Type) – the target Type, the given
obj
will be converted into or checked againstorchestrator (Orchestrator) – container of all types, typically used to recurse down nested types
obj (Any) – an instance, that will be checked to see if it can be converted into the
target_cls
or will be converted to an instance oftarget_cls
- Returns
- if the provided arguments are contained by this
Alter
return it, otherwise
None
- if the provided arguments are contained by this
- Return type
Optional[Alter]
- alter_obj(target_cls, orchestrator, obj)
Swap
obj
with a value inuser_dict
- Parameters
target_cls (Type) – the target Type, the given
obj
will be converted into or checked againstorchestrator (Orchestrator) – container of all types, typically used to recurse down nested types
obj (Any) – an instance, that will be checked to see if it can be converted into the
target_cls
or will be converted to an instance oftarget_cls
- Returns
- a value from
user_dict
or a TypeCheckError
providing a reason why a value fromuser_dict
couldn’t be provided
- a value from
- Return type
Union[Any, TypeCheckError]
- log_instance(target_cls, orchestrator, obj, instance)
Apply logging to an instantiate object
- Parameters
target_cls (Type) – the target Type, the given
obj
was converted intoorchestrator (Orchestrator) – container of all types, typically used to recurse down nested types
obj (Any) – an instance, that was converted to an instance of
target_cls
instance (Any) – the output of converting
obj
into an instance oftarget_cls
- Returns
nothing is returned, this is a logging event
- Return type
None