ConfigFramework.loaders package¶
Submodules¶
-
class
CompositeLoader
(*loaders: ConfigFramework.abstract.abc_loader.AbstractConfigLoader, defaults: Dict)¶ Bases:
ConfigFramework.abstract.abc_loader.AbstractConfigLoader
-
dump
(include_defaults: bool = False) → NoReturn¶ Dumps updated variables.
- Parameters
include_defaults – specifies if you want to have default variables to be dumped.
- Returns
-
dump_to
(other_loader: ConfigFramework.abstract.abc_loader.AbstractConfigLoader, include_defaults: bool = False) → NoReturn¶ 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] = None)¶ 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.
-
-
class
EnvLoader
(data: Union[Dict, collections.ChainMap, collections.abc.Mapping], defaults: Dict, include_defaults_to_dumps: Optional[bool] = None, *args, **kwargs)¶ Bases:
ConfigFramework.abstract.abc_loader.AbstractConfigLoader
-
classmethod
load
(defaults: Optional[Dict] = None)¶ 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¶ 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
-
classmethod
-
class
JsonLoader
(data: Union[Dict, collections.ChainMap, collections.abc.Mapping], defaults: Dict, config_path: pathlib.Path)¶ Bases:
ConfigFramework.abstract.abc_loader.AbstractConfigLoader
-
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[AnyStr, pathlib.Path, os.PathLike], defaults: Optional[Dict] = None, **json_kwargs)¶ 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) → NoReturn¶ Dumps updated variables.
- Parameters
include_defaults – specifies if you want to have default variables to be dumped.
- Returns
-
-
class
JsonStringLoader
(data: Union[Dict, collections.ChainMap, collections.abc.Mapping], defaults: Dict)¶ Bases:
ConfigFramework.abstract.abc_loader.AbstractConfigLoader
-
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
(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: AnyStr, defaults: Optional[Dict] = None, **json_kwargs)¶ 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) → AnyStr¶ Dumps updated variables.
- Parameters
include_defaults – specifies if you want to have default variables to be dumped.
- Returns
-
-
class
YAMLLoader
(data: Union[Dict, collections.ChainMap, collections.abc.Mapping], defaults: Dict, config_path: pathlib.Path)¶ Bases:
ConfigFramework.abstract.abc_loader.AbstractConfigLoader
-
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[AnyStr, pathlib.Path, os.PathLike], defaults: Optional[Dict] = None)¶ 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¶ Dumps updated variables.
- Parameters
include_defaults – specifies if you want to have default variables to be dumped.
- Returns
-