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(item, default=None, *args, **kwargs)[source]

Return the value for key if key is in the dictionary, else default.

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. If you don’t need to do that, use SimpleLazyObject.

class dynaconf.utils.functional.Promise[source]

Bases: object

This is just a base class for the proxy class created in the closure of the lazy function. It can be used to recognize promises in code.

class dynaconf.utils.functional.SimpleLazyObject(func)[source]

Bases: dynaconf.utils.functional.LazyObject

A lazy object initialized from any function.

dynaconf.utils.functional.allow_lazy(func, *resultclasses)[source]

A decorator that allows a function to be called with one or more lazy arguments. If none of the args are lazy, the function is evaluated immediately, otherwise a __proxy__ is returned that will evaluate the function when needed.

class dynaconf.utils.functional.cached_property(func, name=None)[source]

Bases: object

Decorator that converts a method with a single self argument into a property cached on the instance.

Optional name argument allows you to make cached properties of other methods. (e.g. url = cached_property(get_absolute_url, name=’url’) )

dynaconf.utils.functional.curry(_curried_func, *args, **kwargs)[source]
dynaconf.utils.functional.lazy(func, *resultclasses)[source]

Turns any callable into a lazy evaluated callable. You need to give result classes or types – at least one is needed so that the automatic forcing of the lazy evaluation code is triggered. Results are not memoized; the function is evaluated on every access.

class dynaconf.utils.functional.lazy_property[source]

Bases: property

A property that works with subclasses by wrapping the decorated functions of the base class.

dynaconf.utils.functional.new_method_proxy(func)[source]
dynaconf.utils.functional.partition(predicate, values)[source]

Splits the values into two sets, based on the return value of the function (True/False). e.g.:

>>> partition(lambda x: x > 3, range(5))
[0, 1, 2, 3], [4]

dynaconf.utils.parse_conf module

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', raise_error_if_not_found=False, usecwd=True, project_root=None)[source]

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

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

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.compat_kwargs(kwargs)[source]

To keep backwards compat change the kwargs to new names

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

Recursively merge two data structures

dynaconf.utils.raw_logger()[source]

Get or create inner logger