Skip to main content

Merges configuration from toml file and environment variables

Project description


Creates a single configuration by merging settings defined in: 1. in environment variables 2. in toml file

Values provided in environment variables have priority over values from toml configuration file.

By default all environment variables are prefixed with 'PAPERMERGE'. By default __ (two underscores) is used as delimiter in environment variables names. For example, given following toml file:

secret_key = 1234
default_language = 'deu'

corespondent environment variables names are PAPERMERGE__MAIN__SECRET_KEY and PAPERMERGE__OCR__DEFAULT_LANGUAGE - notice two underscores separate section name from prefix and variable name. Environment variable name format is (all in uppercase):


Although in toml files you can place variable names outside sections, in Papermerge all variables must be placed in sections.

By default Configula looks up for following toml file:

  • /etc/papermerge/papermerge.toml
  • /etc/papermerge.toml
  • papermerge.toml

If you have custom location (or custom file name), use PAPERMERGE__CONFIG (notice double underscores) environment variable to point to it:



$ poetry add configula


from configula import Configula

config = Configula()

default_language = config.get('ocr', 'default_language')
secret_key = config.get('main', 'secret_key')

Where papermerge.toml has the following content:

secret_key = 5432

default_language = 'deu'

Default language can be overwritten by environment variable PAPERMERGE__OCR__DEFAULT_LANGUAGE and secret_key can overwritten by environment variable PAPERMERGE__MAIN__SECRET_KEY

If you want to read variable from a section use configula.get(section, var_name, default_value) method.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

configula-0.5.4.tar.gz (7.4 kB view hashes)

Uploaded Source

Built Distribution

configula-0.5.4-py3-none-any.whl (13.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page