dynaconf.utils package

Submodules

dynaconf.utils.boxing module

class dynaconf.utils.boxing.DynaBox(*args, **kwargs)[source]

Bases: box.Box

Specialized Box for dynaconf it allows items/attrs to be found both in upper or lower case

copy() → a shallow copy of D[source]
get(k[, d]) → D[k] if k in D, else d. d defaults to None.[source]

dynaconf.utils.functional module

class dynaconf.utils.functional.LazyObject[source]

Bases: object

A wrapper for another class that can be used to delay instantiation of the wrapped class.

By subclassing, you have the opportunity to intercept and alter the instantiation.

dynaconf.utils.functional.new_method_proxy(func)[source]
dynaconf.utils.functional.unpickle_lazyobject(wrapped)[source]

Used to unpickle lazy objects. Just return its argument, which will be the wrapped object.

dynaconf.utils.parse_conf module

class dynaconf.utils.parse_conf.Del(value)[source]

Bases: dynaconf.utils.parse_conf.MetaValue

Triggers an existing key to be deleted

dynaconf_del = True
class dynaconf.utils.parse_conf.LazyFormat(value, formatter=<method 'format' of 'str' objects>)[source]

Bases: object

Holds data to format lazily.

context

Builds a context for formatting.

dynaconf_lazy_format = True
class dynaconf.utils.parse_conf.Merge(value)[source]

Bases: dynaconf.utils.parse_conf.MetaValue

Triggers an existing key to be merged

dynaconf_merge = True
class dynaconf.utils.parse_conf.MetaValue(value)[source]

Bases: object

A Marker to trigger specific actions on set and object_merge

meta_value = True
class dynaconf.utils.parse_conf.Reset(value)[source]

Bases: dynaconf.utils.parse_conf.MetaValue

Triggers an existing key to be reset to its value

dynaconf_reset = True
dynaconf.utils.parse_conf.evaluate_lazy_format(f)[source]

Marks a method on Settings instance to lazily evaluate LazyFormat objects upon access.

dynaconf.utils.parse_conf.jinja_formatter(value, **context)[source]
dynaconf.utils.parse_conf.parse_conf_data(data, tomlfy=False)[source]
dynaconf.utils.parse_conf.parse_with_toml(data)[source]

Uses TOML syntax to parse data

dynaconf.utils.parse_conf.unparse_conf_data(value)[source]

dynaconf.utils.files module

dynaconf.utils.files.find_file(filename='.env', project_root=None, skip_files=None, **kwargs)[source]

Search in increasingly higher folders for the given file Returns path to the file if found, or an empty string otherwise.

This function will build a search_tree based on:

  • Project_root if specified
  • Invoked script location and its parents until root
  • Current working directory

For each path in the search_tree it will also look for an aditional ./config folder.

dynaconf.utils.files.get_local_filename(filename)[source]

Takes a filename like settings.toml and returns settings.local.toml

Arguments:
filename {str} – The filename or complete path
Returns:
[str] – The same name or path with .local. added.
dynaconf.utils.files.read_file(path, **kwargs)[source]

Module contents

class dynaconf.utils.DynaconfDict(*args, **kwargs)[source]

Bases: dict

A dict representing en empty Dynaconf object useful to run loaders in to a dict for testing

exists(key, **kwargs)[source]
static get_environ(key, default=None)[source]
logger
set(key, value, *args, **kwargs)[source]
class dynaconf.utils.Missing[source]

Bases: object

Sentinel value object/singleton used to differentiate between ambiguous situations where None is a valid value.

dynaconf.utils.build_env_list(obj, env)[source]

Build env list for loaders to iterate.

Arguments:
obj {LazySettings} – A Dynaconf settings instance env {str} – The current env to be loaded
Returns:
[str] – A list of string names of the envs to load.
dynaconf.utils.compat_kwargs(kwargs)[source]

To keep backwards compat change the kwargs to new names

dynaconf.utils.deduplicate(list_object)[source]

Rebuild list_object removing duplicated and keeping order

dynaconf.utils.ensure_a_list(data)[source]

Ensure data is a list or wrap it in a list

dynaconf.utils.object_merge(old, new, unique=False)[source]

Recursively merge two data structures.

Parameters:unique – When set to True existing list items are not set.
dynaconf.utils.raw_logger(level=None)[source]

Get or create inner logger

dynaconf.utils.trimmed_split(s, seps=(';', ', '))[source]

Given a string s, split is by one of one of the seps.

dynaconf.utils.upperfy(key)[source]

Receive a string key and returns its upper version.

Example:

input: foo output: FOO

input: foo_bar output: FOO_BAR

input: foo__bar__ZAZ output: FOO__bar__ZAZ

Arguments:
key {str} – A string key that may contain dunders __
Returns:
The key as upper case but keeping the nested elements.
dynaconf.utils.warn_deprecations(data)[source]