ConfigFramework.loaders package¶
Submodules¶
-
class
CompositeLoader
(*loaders: ConfigFramework.abstract.abc_loader.AbstractConfigLoader, defaults: Optional[Dict[Union[Hashable, str, pathlib.Path], Any]])[source]¶ Bases:
ConfigFramework.abstract.abc_loader.AbstractConfigLoader
Creates new config first_loader with your variables.
- Parameters
data – data from loader.
defaults – default variables that will be used if not found in first_loader.
include_defaults_to_dumps – represents if default values should be dumped to that first_loader.
args – arguments that can be used for your custom loaders.
kwargs – keyword arguments that can be used for your custom loaders.
-
dump
(include_defaults: bool = False) → None[source]¶ Dumps updated variables to loader.
- Parameters
include_defaults – specifies if you want to have default variables to be dumped.
- Returns
nothing.
-
dump_to
(other_loader: ConfigFramework.abstract.abc_loader.AbstractConfigLoader, include_defaults: bool = False) → None[source]¶ Dumps variables to other first_loader that been already initialized.
- Parameters
other_loader – other first_loader that already initialized and where you want to dump stuff.
include_defaults – include_defaults_to_dumps: specifies if you want to have default variables to be.
- Returns
nothing.
-
classmethod
load
(*loaders: ConfigFramework.abstract.abc_loader.AbstractConfigLoader, defaults: Optional[Dict[Union[Hashable, str, pathlib.Path], Any]] = None)[source]¶ Initializes creation of new ConfigLoader. You must provide your arguments that are needed for your first_loader.
- Parameters
args – arguments that can be used for your custom loaders.
kwargs – keyword arguments that can be used for your custom loaders.
-
lookup_data
: Union[ChainMap, MutableMapping[Hashable, Any], Dict[Hashable, Any]]¶
-
include_defaults
: bool¶
-
defaults
: Dict[key_type, Any]¶
-
class
DictLoader
(data: data_type, defaults: defaults_type, include_defaults_to_dumps: bool = False, *args, **kwargs)[source]¶ Bases:
ConfigFramework.abstract.abc_loader.AbstractConfigLoader
Uses dictionaries with same interface as if it was an Loader.
Creates new config first_loader with your variables.
- Parameters
data – data from loader.
defaults – default variables that will be used if not found in first_loader.
include_defaults_to_dumps – represents if default values should be dumped to that first_loader.
args – arguments that can be used for your custom loaders.
kwargs – keyword arguments that can be used for your custom loaders.
-
classmethod
load
(data: Union[collections.ChainMap, collections.abc.MutableMapping, Dict[Hashable, Any]], defaults: Optional[Dict[Union[Hashable, str, pathlib.Path], Any]] = None)[source]¶ Loads dictionary as some loader with same interface.
- Parameters
data – your dictionary with settings.
defaults – default values.
- Returns
instance of DictLoader.
-
dump
(include_defaults: bool = False) → None[source]¶ No need to dump at all since all values instantly being updated. Left only for compatibility purpose.
- Parameters
include_defaults – doesn’t affect anything as stated before.
- Returns
nothing.
-
lookup_data
: Union[ChainMap, MutableMapping[Hashable, Any], Dict[Hashable, Any]]¶
-
include_defaults
: bool¶
-
defaults
: Dict[key_type, Any]¶
-
class
EnvLoader
(data: data_type, defaults: defaults_type, include_defaults_to_dumps: bool = False, *args, **kwargs)[source]¶ Bases:
ConfigFramework.abstract.abc_loader.AbstractConfigLoader
Creates new config first_loader with your variables.
- Parameters
data – data from loader.
defaults – default variables that will be used if not found in first_loader.
include_defaults_to_dumps – represents if default values should be dumped to that first_loader.
args – arguments that can be used for your custom loaders.
kwargs – keyword arguments that can be used for your custom loaders.
-
classmethod
load
(defaults: Optional[Dict[Union[Hashable, str, pathlib.Path], Any]] = None)[source]¶ Initializes creation of new ConfigLoader. You must provide your arguments that are needed for your first_loader.
- Parameters
args – arguments that can be used for your custom loaders.
kwargs – keyword arguments that can be used for your custom loaders.
-
dump
(include_defaults: bool = False) → NoReturn[source]¶ You can not dump values to environ yet because I don’t know a good way to do that or think it’s needed. Left only for compatibility purpose.
- Parameters
include_defaults – doesn’t affect anything as stated before.
- Returns
nothing.
-
lookup_data
: Union[ChainMap, MutableMapping[Hashable, Any], Dict[Hashable, Any]]¶
-
include_defaults
: bool¶
-
defaults
: Dict[key_type, Any]¶
-
class
JsonLoader
(data: Union[collections.ChainMap, collections.abc.MutableMapping, Dict[Hashable, Any]], defaults: Optional[Dict[Union[Hashable, str, pathlib.Path], Any]], config_path: pathlib.Path)[source]¶ Bases:
ConfigFramework.abstract.abc_loader.AbstractConfigLoader
Creates new config first_loader with your variables.
- Parameters
data – data from loader.
defaults – default variables that will be used if not found in first_loader.
include_defaults_to_dumps – represents if default values should be dumped to that first_loader.
args – arguments that can be used for your custom loaders.
kwargs – keyword arguments that can be used for your custom loaders.
-
json_loader
(*, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)¶ Deserialize
fp
(a.read()
-supporting file-like object containing a JSON document) to a Python object.object_hook
is an optional function that will be called with the result of any object literal decode (adict
). The return value ofobject_hook
will be used instead of thedict
. This feature can be used to implement custom decoders (e.g. JSON-RPC class hinting).object_pairs_hook
is an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The return value ofobject_pairs_hook
will be used instead of thedict
. This feature can be used to implement custom decoders. Ifobject_hook
is also defined, theobject_pairs_hook
takes priority.To use a custom
JSONDecoder
subclass, specify it with thecls
kwarg; otherwiseJSONDecoder
is used.
-
json_dumper
(fp, *, skipkeys=False, ensure_ascii=False, check_circular=True, allow_nan=True, cls=None, indent=2, separators=None, default=None, sort_keys=False, **kw)¶ Serialize
obj
as a JSON formatted stream tofp
(a.write()
-supporting file-like object).If
skipkeys
is true thendict
keys that are not basic types (str
,int
,float
,bool
,None
) will be skipped instead of raising aTypeError
.If
ensure_ascii
is false, then the strings written tofp
can contain non-ASCII characters if they appear in strings contained inobj
. Otherwise, all such characters are escaped in JSON strings.If
check_circular
is false, then the circular reference check for container types will be skipped and a circular reference will result in anOverflowError
(or worse).If
allow_nan
is false, then it will be aValueError
to serialize out of rangefloat
values (nan
,inf
,-inf
) in strict compliance of the JSON specification, instead of using the JavaScript equivalents (NaN
,Infinity
,-Infinity
).If
indent
is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines.None
is the most compact representation.If specified,
separators
should be an(item_separator, key_separator)
tuple. The default is(', ', ': ')
if indent isNone
and(',', ': ')
otherwise. To get the most compact JSON representation, you should specify(',', ':')
to eliminate whitespace.default(obj)
is a function that should return a serializable version of obj or raise TypeError. The default simply raises TypeError.If sort_keys is true (default:
False
), then the output of dictionaries will be sorted by key.To use a custom
JSONEncoder
subclass (e.g. one that overrides the.default()
method to serialize additional types), specify it with thecls
kwarg; otherwiseJSONEncoder
is used.
-
classmethod
load
(config_path: Union[str, Path, PathLike[str]], defaults: defaults_type = None, **json_kwargs)[source]¶ Initializes creation of new ConfigLoader. You must provide your arguments that are needed for your first_loader.
- Parameters
args – arguments that can be used for your custom loaders.
kwargs – keyword arguments that can be used for your custom loaders.
-
dump
(include_defaults: bool = False, **json_kwargs) → None[source]¶ Dumps updated variables to loader.
- Parameters
include_defaults – specifies if you want to have default variables to be dumped.
- Returns
nothing.
-
lookup_data
: Union[ChainMap, MutableMapping[Hashable, Any], Dict[Hashable, Any]]¶
-
include_defaults
: bool¶
-
defaults
: Dict[key_type, Any]¶
-
class
JsonStringLoader
(data: Union[collections.ChainMap, collections.abc.MutableMapping, Dict[Hashable, Any]], defaults: Optional[Dict[Union[Hashable, str, pathlib.Path], Any]])[source]¶ Bases:
ConfigFramework.abstract.abc_loader.AbstractConfigLoader
Creates new config first_loader with your variables.
- Parameters
data – data from loader.
defaults – default variables that will be used if not found in first_loader.
include_defaults_to_dumps – represents if default values should be dumped to that first_loader.
args – arguments that can be used for your custom loaders.
kwargs – keyword arguments that can be used for your custom loaders.
-
json_serialized_loader
(*, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)¶ Deserialize
s
(astr
,bytes
orbytearray
instance containing a JSON document) to a Python object.object_hook
is an optional function that will be called with the result of any object literal decode (adict
). The return value ofobject_hook
will be used instead of thedict
. This feature can be used to implement custom decoders (e.g. JSON-RPC class hinting).object_pairs_hook
is an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The return value ofobject_pairs_hook
will be used instead of thedict
. This feature can be used to implement custom decoders. Ifobject_hook
is also defined, theobject_pairs_hook
takes priority.parse_float
, if specified, will be called with the string of every JSON float to be decoded. By default this is equivalent to float(num_str). This can be used to use another datatype or parser for JSON floats (e.g. decimal.Decimal).parse_int
, if specified, will be called with the string of every JSON int to be decoded. By default this is equivalent to int(num_str). This can be used to use another datatype or parser for JSON integers (e.g. float).parse_constant
, if specified, will be called with one of the following strings: -Infinity, Infinity, NaN. This can be used to raise an exception if invalid JSON numbers are encountered.To use a custom
JSONDecoder
subclass, specify it with thecls
kwarg; otherwiseJSONDecoder
is used.The
encoding
argument is ignored and deprecated.
-
json_serialized_dumper
(*, skipkeys=False, ensure_ascii=False, check_circular=True, allow_nan=True, cls=None, indent=2, separators=None, default=None, sort_keys=False, **kw)¶ Serialize
obj
to a JSON formattedstr
.If
skipkeys
is true thendict
keys that are not basic types (str
,int
,float
,bool
,None
) will be skipped instead of raising aTypeError
.If
ensure_ascii
is false, then the return value can contain non-ASCII characters if they appear in strings contained inobj
. Otherwise, all such characters are escaped in JSON strings.If
check_circular
is false, then the circular reference check for container types will be skipped and a circular reference will result in anOverflowError
(or worse).If
allow_nan
is false, then it will be aValueError
to serialize out of rangefloat
values (nan
,inf
,-inf
) in strict compliance of the JSON specification, instead of using the JavaScript equivalents (NaN
,Infinity
,-Infinity
).If
indent
is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines.None
is the most compact representation.If specified,
separators
should be an(item_separator, key_separator)
tuple. The default is(', ', ': ')
if indent isNone
and(',', ': ')
otherwise. To get the most compact JSON representation, you should specify(',', ':')
to eliminate whitespace.default(obj)
is a function that should return a serializable version of obj or raise TypeError. The default simply raises TypeError.If sort_keys is true (default:
False
), then the output of dictionaries will be sorted by key.To use a custom
JSONEncoder
subclass (e.g. one that overrides the.default()
method to serialize additional types), specify it with thecls
kwarg; otherwiseJSONEncoder
is used.
-
classmethod
load
(config: AnyStr, defaults: Optional[Dict[Union[Hashable, str, pathlib.Path], Any]] = None, **json_kwargs)[source]¶ Initializes creation of new ConfigLoader. You must provide your arguments that are needed for your first_loader.
- Parameters
args – arguments that can be used for your custom loaders.
kwargs – keyword arguments that can be used for your custom loaders.
-
dump
(include_defaults: bool = False, **json_kwargs) → str[source]¶ Dumps updated variables to loader.
- Parameters
include_defaults – specifies if you want to have default variables to be dumped.
- Returns
nothing.
-
lookup_data
: Union[ChainMap, MutableMapping[Hashable, Any], Dict[Hashable, Any]]¶
-
include_defaults
: bool¶
-
defaults
: Dict[key_type, Any]¶
-
class
YAMLLoader
(data: Union[collections.ChainMap, collections.abc.MutableMapping, Dict[Hashable, Any]], defaults: Optional[Dict[Union[Hashable, str, pathlib.Path], Any]], config_path: pathlib.Path)[source]¶ Bases:
ConfigFramework.abstract.abc_loader.AbstractConfigLoader
Creates new config first_loader with your variables.
- Parameters
data – data from loader.
defaults – default variables that will be used if not found in first_loader.
include_defaults_to_dumps – represents if default values should be dumped to that first_loader.
args – arguments that can be used for your custom loaders.
kwargs – keyword arguments that can be used for your custom loaders.
-
dumper
(stream=None, *, Dumper=<class 'yaml.cyaml.CDumper'>, **kwds)¶ Serialize a Python object into a YAML stream. If stream is None, return the produced string instead.
-
loader
(*, Loader=<class 'yaml.cyaml.CLoader'>)¶ Parse the first YAML document in a stream and produce the corresponding Python object.
-
classmethod
load
(config_path: Union[str, Path, PathLike[str]], defaults: Optional[Dict] = None)[source]¶ Initializes creation of new ConfigLoader. You must provide your arguments that are needed for your first_loader.
- Parameters
args – arguments that can be used for your custom loaders.
kwargs – keyword arguments that can be used for your custom loaders.
-
dump
(include_defaults: bool = False) → None[source]¶ Dumps updated variables to loader.
- Parameters
include_defaults – specifies if you want to have default variables to be dumped.
- Returns
nothing.
-
lookup_data
: Union[ChainMap, MutableMapping[Hashable, Any], Dict[Hashable, Any]]¶
-
include_defaults
: bool¶
-
defaults
: Dict[key_type, Any]¶