Yaml Parser

class django_docker_helpers.config.backends.yaml_parser.YamlParser(config=None, path_separator='.', scope=None)[source]

Bases: django_docker_helpers.config.backends.base.BaseParser

Provides a simple interface to read config options from Yaml.

Example:

p = YamlParser('./tests/data/config.yml', scope='development')
assert p.get('up.down.above') == [1, 2, 3]
Parameters:
  • config (Union[str, Textio, None]) – a path to config file, or TextIO object
  • path_separator (str) – specifies which character separates nested variables, default is '.'
  • scope (Optional[str]) – a global namespace-like variable prefix
Raises:

ValueError – if no config specified

__str__()[source]

Return str(self).

get(variable_path, default=None, coerce_type=None, coercer=None, **kwargs)[source]

Inherited method should take all specified arguments.

Parameters:
  • variable_path (str) – a delimiter-separated path to a nested value
  • default (Optional[Any]) – default value if there’s no object by specified path
  • coerce_type (Optional[Type[+CT_co]]) – cast a type of a value to a specified one
  • coercer (Optional[Callable]) – perform a type casting with specified callback
  • kwargs – additional arguments inherited parser may need
Returns:

value or default

get_client()[source]

If your backend needs a client, inherit this method and use client() shortcut.

Returns:an instance of backend-specific client