Module that loads configuration settings from a yaml file.
import config_loader
import logging
CONFIG = config_loader.load(
'path/to/config_file.yaml',
'path/to/schema_file.yaml'
)
logging.config.dictConfig(CONFIG['logging'])
# Optionally:
CONFIG = config_loader.freeze(CONFIG)
This package comes with an example YAML schema file schema_example.yaml
that contains, among other things, a schema definition for a dict that can be passed into logging.config.dictConfig.
To get your development environment up and running:
# Clone the repository:
git clone git@github.com:Amsterdam/config_loader.git
cd config_loader
# Create and activate a virtual environment, for example:
python3.6 -m venv --copies --prompt authz_admin .venv
source ./.venv/bin/activate
make # defaults to `make dist`
make dist
make release # Don't forget to version bump in setup.py first.
make build
make test
make testcov
make clean
- We use PyTest for tests.
- PyTest can be integrated with SetupTools (see https://docs.pytest.org/en/latest/goodpractices.html). We don’t do this.
- Common commands for builds, distributing, packaging, documentation etcetera are in
Makefile
andsphinx/Makefile
. - RST files and docstrings are indented with 4 spaces.
- Globals must be immutable.
- We follow Google’s formatting standard in docstrings.
Docstrings are formatted like this:
"""This is a one-line docstring.""" """One line description, terminated with a period. More info, with a trailing empty line. """