biopipen.core.config
Provides the envs from configuration files
ConfigItems— Provides the envs from configuration files and defaults thenon-existing values to None. </>
biopipen.core.config.ConfigItems(*args, **kwargs)
Provides the envs from configuration files and defaults thenon-existing values to None.
*args— Anything that can be sent to dict construct**kwargs— keyword argument that can be sent to dict constructSome diot configurations can also be passed, including: diot_nest: Types to nestly convert values diot_transform: The transforms for keys diot_frozen: Whether to generate a frozen diot. True: freeze the object recursively if there are Diot objects in descendants False: Don'f freeze 'shallow': Only freeze at depth = 1 diot_missing: How to deal with missing keys when accessing them - An exception class or object to raise - A custom function with first argument the key and second the diot object. - Other values will be used as the default value directly
__contains__(name)(bool) — True if the dictionary has the specified key, else False.</>__delitem__(name)— Delete self[key].</>__getitem__(name)(Any) — x.getitem(y) <==> x[y]</>__ior__(other)(Diot) — Return self|=value.</>__setitem__(name,value)— Set self[key] to value.</>accessible_keys()(Iterable) — Get the converted keys</>clear()— Clear the object</>copy()(Diot) — Shallow copy the object</>freeze(frozen)— Freeze the diot object</>from_namespace(namespace,recursive,diot_nest,diot_transform,diot_frozen,diot_missing)(Diot) — Get a Diot object from an argparse namespace</>get(name,value)(Any) — Get the value of a key name</>pop(name,*value)(Any) — Pop a key from the object and return the value. If key does notexist, return the given default value </>popitem()(Tuple) — Pop last item from the object</>setdefault(name,value)(Any) — Set a default value to a key</>thaw(recursive)— A context manager for temporarily change the diot</>to_dict()(Dict) — Turn the Box and sub Boxes back into a nativepython dictionary. </>to_json(filename,encoding,errors,**json_kwargs)(Optional) — Convert to a json string or save it to json file</>to_toml(filename,encoding,errors)(Optional) — Convert to a toml string or save it to toml file</>to_yaml(filename,default_flow_style,encoding,errors,**yaml_kwargs)(Optional) — Convert to a yaml string or save it to yaml file</>unfreeze(recursive)— Unfreeze the diot object</>update(*value,**kwargs)— Update the object. Shortcut:|=</>update_recursively(*value,**kwargs)— Update the object. Shortcut:|=</>
from_namespace(namespace, recursive=True, diot_nest=True, diot_transform='safe', diot_frozen=False, diot_missing=<diot.diot._DiotMissingDefault object at 0x7f270fc21a60>)
Get a Diot object from an argparse namespace
>>> from argparse import Namespace>>> Diot.from_namespace(Namespace(a=1, b=2))
namespace(Namespace) — The namespace objectrecursive(bool, optional) — Do it recursively?diot_nest(Union, optional) — Types to nestly convert valuesdiot_transform(Union, optional) — The transforms for keysdiot_frozen(Union, optional) — Whether to generate a frozen diot.- - True: freeze the object recursively if there are Diot objects
- - False: Don'f freeze
- -
shallow: Only freeze at depth = 1
diot_missing(Any, optional) — How to deal with missing keys when accessing them- - An exception class or object to raise
- - A custom function with first argument the key and second
the diot object. - - Other values will be used as the default value directly
The converted diot object.
__setitem__(name, value)
Set self[key] to value.
pop(name, *value)
Pop a key from the object and return the value. If key does notexist, return the given default value
name(str) — The key
The value corresponding to the name or the default value
DiotFrozenError— when try to pop from a frozen diot
popitem()
Pop last item from the object
A tuple of key and value
DiotFrozenError— when try to pop from a frozen diot
update(*value, **kwargs)
Update the object. Shortcut: |=
DiotFrozenError— when try to update a frozen diot
update_recursively(*value, **kwargs)
Update the object. Shortcut: |=
DiotFrozenError— when try to update a frozen diot
__ior__(other) → Diot
Return self|=value.
__delitem__(name)
Delete self[key].
freeze(frozen='shallow')
Freeze the diot object
frozen(Union, optional) — The frozen argument indicating how to freeze:shallow: only freeze at depth=1 True: freeze recursively if there are diot objects in children False: Disable freezing
unfreeze(recursive=False)
Unfreeze the diot object
recursive(bool, optional) — Whether unfreeze all diot objects recursively
thaw(recursive=False)
A context manager for temporarily change the diot
recursive(bool, optional) — Whether unfreeze all diot objects recursively
self, the reference to this diot.
setdefault(name, value)
Set a default value to a key
name(str) — The key namevalue(Any) — The default value
The existing value or the value passed in
DiotFrozenError— when try to set default to a frozen diot
accessible_keys()
Get the converted keys
The accessible (transformed) keys
get(name, value=None)
Get the value of a key name
name(str) — The key namevalue(Any, optional) — The value to return if the key does not exist
The corresponding value or the value passed in if the key doesnot exist
__contains__(name) → bool
True if the dictionary has the specified key, else False.
clear()
Clear the object
copy()
Shallow copy the object
The copied object
to_dict()
Turn the Box and sub Boxes back into a nativepython dictionary.
The converted python dictionary
to_json(filename=None, encoding='utf-8', errors='strict', **json_kwargs)
Convert to a json string or save it to json file
filename(Union, optional) — The filename to save the json to, if not given a jsonstring will be returnedencoding(str, optional) — The encoding for saving to fileerrors(str, optional) — The errors handling for saveing to fileSee python's open function**json_kwargs— Other kwargs for json.dumps
The json string with filename is not given
to_yaml(filename=None, default_flow_style=False, encoding='utf-8', errors='strict', **yaml_kwargs)
Convert to a yaml string or save it to yaml file
filename(Union, optional) — The filename to save the yaml to, if not given a yamlstring will be returneddefault_flow_style(bool, optional) — The default flow style for yaml dumpingSeeyaml.dumpencoding(str, optional) — The encoding for saving to fileerrors(str, optional) — The errors handling for saveing to fileSee python's open function**yaml_kwargs— Other kwargs foryaml.dump
The yaml string with filename is not given
to_toml(filename=None, encoding='utf-8', errors='strict')
Convert to a toml string or save it to toml file
filename(Union, optional) — The filename to save the toml to, if not given a tomlstring will be returnedencoding(str, optional) — The encoding for saving to fileerrors(str, optional) — The errors handling for saveing to fileSee python's open function
The toml string with filename is not given
__getitem__(name) → Any
x.getitem(y) <==> x[y]