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

property type_value: str

The expected value for the key type in the given Params object

Returns

the value of type for which this Alter is appropriate

Return type

str

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 against

  • orchestrator (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 of target_cls

Returns

if True then a value in the user dict has been

requested else False

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 against

  • orchestrator (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 of target_cls

Returns

if the provided arguments are contained by this Alter

return it, otherwise None

Return type

Optional[Alter]

alter_obj(target_cls, orchestrator, obj)

Swap obj with a value in user_dict

Parameters
  • target_cls (Type) – the target Type, the given obj will be converted into or checked against

  • orchestrator (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 of target_cls

Returns

a value from user_dict or a

TypeCheckError providing a reason why a value from user_dict couldn’t be provided

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 into

  • orchestrator (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 of target_cls

Returns

nothing is returned, this is a logging event

Return type

None

property type_value: str

The expected value for the key type in the given Params object

Returns

the value of type for which this Alter is appropriate

Return type

str