Skip to main content

Configula

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:

[main]
secret_key = 1234
[ocr]
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):

 <prefix><delimiter><section_name><delimiter><variable_name>

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:

PAPERMERGE__CONFIG=/app/config/pm.toml

Installation

$ poetry add configula

Usage

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:

[main]
secret_key = 5432

[ocr]
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.

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.3.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

configula-0.5.3-py3-none-any.whl (13.3 kB view details)

Uploaded Python 3

File details

Details for the file configula-0.5.3.tar.gz.

File metadata

  • Download URL: configula-0.5.3.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1041-azure

File hashes

Hashes for configula-0.5.3.tar.gz
Algorithm Hash digest
SHA256 ca04917aaae2b28546f2ab3f995f7f94577b01db4945641dc1311941bb07d55d
MD5 3c6a7bb2f5c5307fb07ae1d71d926693
BLAKE2b-256 370d95723bcf15d732f65056b68839c3bea8ab37d29705f04278fd56492a4309

See more details on using hashes here.

File details

Details for the file configula-0.5.3-py3-none-any.whl.

File metadata

  • Download URL: configula-0.5.3-py3-none-any.whl
  • Upload date:
  • Size: 13.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1041-azure

File hashes

Hashes for configula-0.5.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0e5f7eccade1a9ab9b2cd25ba1c7ec84f9767d97b0e74a454c42b2bb7ad5bde5
MD5 00ce368e21e24ff62512deafab513247
BLAKE2b-256 d08c9c401bc54f9eb48103bd5da527b9d3f900f6b19b5b383fb1a77754bbace3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page