glorpen.config API Documentation



Current package version.


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

Config validator and normalizer.


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().


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.


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.




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.