# 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/papermerge/configula",
"name": "configula",
"maintainer": "Eugen Ciur",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "eugen@papermerge.com",
"keywords": "configurations,config,environment variables,toml",
"author": "Eugen Ciur",
"author_email": "eugen@papermerge.com",
"download_url": "https://files.pythonhosted.org/packages/6b/f4/264ae6661d49eab4ab5e7a7571cf95fcfc0226316785525292b30124b74f/configula-0.5.4.tar.gz",
"platform": null,
"description": "# Configula\n\nCreates a single configuration by merging settings defined in:\n 1. in environment variables\n 2. in toml file\n\nValues provided in **environment variables have priority** over values from \ntoml configuration file.\n\nBy default all environment variables are prefixed with 'PAPERMERGE'.\nBy default `__` (two underscores) is used as delimiter in environment variables\nnames. For example, given following toml file:\n\n [main]\n secret_key = 1234\n [ocr]\n default_language = 'deu'\n\ncorespondent environment variables names are PAPERMERGE__MAIN__SECRET_KEY and\nPAPERMERGE__OCR__DEFAULT_LANGUAGE - notice two underscores separate section name\nfrom prefix and variable name.\nEnvironment variable name format is (all in uppercase):\n\n <prefix><delimiter><section_name><delimiter><variable_name>\n\n\nAlthough in toml files you can place variable names outside sections, in Papermerge\nall variables **must be placed in sections**.\n\nBy default Configula looks up for following toml file:\n\n- /etc/papermerge/papermerge.toml\n- /etc/papermerge.toml\n- papermerge.toml\n\nIf you have custom location (or custom file name), use ``PAPERMERGE__CONFIG``\n(notice double underscores) environment variable to point to it:\n\n PAPERMERGE__CONFIG=/app/config/pm.toml\n\n\n## Installation\n\n $ poetry add configula\n\n## Usage\n\n from configula import Configula\n \n config = Configula()\n \n default_language = config.get('ocr', 'default_language')\n secret_key = config.get('main', 'secret_key')\n\nWhere ``papermerge.toml`` has the following content:\n\n [main]\n secret_key = 5432\n\n [ocr]\n default_language = 'deu'\n\nDefault language can be overwritten by environment\nvariable `PAPERMERGE__OCR__DEFAULT_LANGUAGE` and secret_key can overwritten\nby environment variable `PAPERMERGE__MAIN__SECRET_KEY`\n\nIf you want to read variable from a section use\n`configula.get(section, var_name, default_value)` method.\n",
"bugtrack_url": null,
"license": "Apache-2.0",
"summary": "Merges configuration from toml file and environment variables",
"version": "0.5.4",
"project_urls": {
"Homepage": "https://github.com/papermerge/configula",
"Repository": "https://github.com/papermerge/configula"
},
"split_keywords": [
"configurations",
"config",
"environment variables",
"toml"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "ffccda8d04e7a138bb4d7a64c2f32c2bc2fd145864311d34b2a1d9694f146e02",
"md5": "4ad2d469d60c93f0fb2519337a57a431",
"sha256": "acfb69fa1d86e40acec09c8822d518790f7d15ddfc0926939f1e40d2759234d8"
},
"downloads": -1,
"filename": "configula-0.5.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "4ad2d469d60c93f0fb2519337a57a431",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 13252,
"upload_time": "2023-07-31T06:03:51",
"upload_time_iso_8601": "2023-07-31T06:03:51.393590Z",
"url": "https://files.pythonhosted.org/packages/ff/cc/da8d04e7a138bb4d7a64c2f32c2bc2fd145864311d34b2a1d9694f146e02/configula-0.5.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "6bf4264ae6661d49eab4ab5e7a7571cf95fcfc0226316785525292b30124b74f",
"md5": "ed71c3a1a85df7e586586c7362927087",
"sha256": "a1d9d4f6dc48d024a4fcd0d5de2751cf1765ba9c9adeb0530c9ad1f8eed5cf79"
},
"downloads": -1,
"filename": "configula-0.5.4.tar.gz",
"has_sig": false,
"md5_digest": "ed71c3a1a85df7e586586c7362927087",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 7399,
"upload_time": "2023-07-31T06:03:52",
"upload_time_iso_8601": "2023-07-31T06:03:52.876911Z",
"url": "https://files.pythonhosted.org/packages/6b/f4/264ae6661d49eab4ab5e7a7571cf95fcfc0226316785525292b30124b74f/configula-0.5.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-31 06:03:52",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "papermerge",
"github_project": "configula",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "configula"
}