API Reference

class pymlconf.Mergable(data=None)[source]

Base class for all configuration nodes.

So all configuration nodes are mergable.

Parameters

data (list or dict) – Initial value to constract a mergable instance. It can be yaml string or python dictionary. default: None.

abstract canmerge(data)[source]

Determine whenever can merge with the passed argument or not.

Parameters

data (any) – An object to test.

Returns

bool

abstract dump()[source]

Return a python dictionary or list from current config instance.

abstract copy()[source]

Return a copy of current config instance.

Returns

Mergable

classmethod make_mergable_if_possible(data)[source]

Make an object mergable if possible.

Returns the virgin object if cannot convert it to a mergable instance.

Returns

Mergable or type(data)

merge(*args)[source]

Merge this instance with new instances, in-place.

Parameters

args (iterable) – Configuration values to merge with current instance.

class pymlconf.MergableList(*args, **kwargs)[source]

Bases: list, pymlconf.models.Mergable

Configuration node that represents the python list data.

class pymlconf.MergableDict(*args, **kwargs)[source]

Bases: collections.OrderedDict, pymlconf.models.Mergable

Configuration node that represents python dictionary data.

class pymlconf.ConfigurationNamespace(*args, **kwargs)[source]

Bases: pymlconf.models.MergableDict

Configuration node that represents the configuration namespace node.

class pymlconf.Root(*args, **kwargs)[source]

Bases: pymlconf.models.MergableDict

The main class which exposes pymlconf package.

Example:

from pymlconf import Root
from os import path
config =  Root('''
    server:
        host: localhost
        port: 4455
''')

print config.server.host
print config.server.port
dumps()[source]

Encode the instance as YAML String.

New in version 2.3.

loadfile(filename)[source]

Load yaml configuration file and merge it by current instance.

Parameters

filename – filename to load and merge into existing configuration instance

class pymlconf.DeferredRoot[source]

Bases: object

initialize(init_value, force=False)[source]

Initialize the configuration manager.

Parameters

force – force initialization even if it’s already initialized

Returns

class pymlconf.ConfigurationError[source]

Bases: Exception

class pymlconf.ConfigurationAlreadyInitializedError[source]

Bases: pymlconf.errors.ConfigurationError

class pymlconf.ConfigurationNotInitializedError[source]

Bases: pymlconf.errors.ConfigurationError