glorpen.config API Documentation

glorpen.config

glorpen.config.__version__

Current package version.

glorpen.config.config

class glorpen.config.config.Config(spec)[source]

Config validator and normalizer.

glorpen.config.fields.base

class glorpen.config.fields.base.Field(validators=None)[source]

Single field in configuration file.

Custom fields should implement own normalizer/interpolation by overriding corresponding methods.

To add custom validation based on whole config object use validator().

get_dependencies(normalized_value)[source]

Find parts that can be interpolated and return required deps. Should check only own data, no nested fields.

interpolate(normalized_value, values) → None[source]

Should replace data in normalized_value with interpolated one. Called only when get_dependencies finds something.

glorpen.config.fields.simple

class glorpen.config.fields.simple.Any(validators=None)[source]

Field that accepts any value.

class glorpen.config.fields.simple.Dict(schema=None, keys=None, values=None, check_keys=False, **kwargs)[source]

Converts values to collections.OrderedDict

Supports setting whole schema (specific keys and specific values) or just keys type and values type.

Keys can be interpolated if keys param supports it.

__init__(schema=None, keys=None, values=None, check_keys=False, **kwargs)[source]

To set specific schema pass dict to schema argument: {"param1": SomeField()}.

To specify keys and values type use keys and values arguments: Dict(keys=String(), values=Number()).

class glorpen.config.fields.simple.List(schema, check_values=False, **kwargs)[source]

Converts value to list.

class glorpen.config.fields.simple.Number(validators=None)[source]

Converts value to numbers.

class glorpen.config.fields.simple.Path(*args, split_by='.', left_char='{', right_char='}', **kwargs)[source]

Converts given value to disk path.

class glorpen.config.fields.simple.PathObj(*args, split_by='.', left_char='{', right_char='}', **kwargs)[source]

Converts value to pathlib.Path object.

class glorpen.config.fields.simple.String(*args, split_by='.', left_char='{', right_char='}', **kwargs)[source]

Converts value to string.

class glorpen.config.fields.simple.Variant(schema, *args, **kwargs)[source]

Converts value to normalized state using one Field chosen from multiple provided.

To allow blank values you have to pass child field with enabled blank values. First field which supports value (Field.is_value_supported()) will be used to convert it.

glorpen.config.fields.log

glorpen.config.fields.version

glorpen.config.exceptions

exception glorpen.config.exceptions.ConfigException[source]

Base exception for config errors.

exception glorpen.config.exceptions.TraceableConfigException(exception)[source]

Exception for improved readability - uses ValidationError to provide full path to field with error.