Name | conf2levels JSON |
Version |
0.5.1
JSON |
| download |
home_page | |
Summary | A configuration reader which reads values stored in two key levels. The first key level is named “section” and the second level “key”. |
upload_time | 2024-02-16 22:05:00 |
maintainer | |
docs_url | None |
author | Josef Friedrich |
requires_python | >=3.10,<4.0 |
license | MIT |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
.. image:: http://img.shields.io/pypi/v/conf2levels.svg
:target: https://pypi.org/project/conf2levels
:alt: This package on the Python Package Index
.. image:: https://github.com/Josef-Friedrich/conf2levels/actions/workflows/tests.yml/badge.svg
:target: https://github.com/Josef-Friedrich/conf2levels/actions/workflows/tests.yml
:alt: Tests
A configuration reader which reads values stored in two key levels.
The first key level is named ``section`` and the second level ``key``.
argparse arguments (`argparse`): (You have to specify a mapping)
.. code:: python
mapping = {
'section.key': 'args_attribute'
}
A python dictionary (`dictonary`):
.. code:: python
{
'section': {
'key': 'value'
}
}
Environment variables (`environ`):
.. code:: shell
export prefix__section__key=value
INI file (`ini`):
.. code:: ini
[section]
key = value
.. code:: python
CONF_DEFAULTS = {
'email': {
'subject_prefix': 'command_watcher',
},
'nsca': {
'port': 5667,
},
}
CONFIG_READER_SPEC: Spec = {
'email': {
'from_addr': {
'description': 'The email address of the sender.',
},
'to_addr': {
'description': 'The email address of the recipient.',
'not_empty': True,
},
'to_addr_critical': {
'description': 'The email address of the recipient to send '
'critical messages to.',
'default': None,
},
'smtp_login': {
'description': 'The SMTP login name.',
'not_empty': True,
},
'smtp_password': {
'description': 'The SMTP password.',
'not_empty': True,
},
'smtp_server': {
'description': 'The URL of the SMTP server, for example: '
'`smtp.example.com:587`.',
'not_empty': True,
},
},
'icinga': {
'url': {
'description': 'The HTTP URL. /v1/actions/process-check-result '
'is appended.',
'not_empty': True,
},
'user': {
'description': 'The user for the HTTP authentification.',
'not_empty': True,
},
'password': {
'description': 'The password for the HTTP authentification.',
'not_empty': True,
},
},
'beep': {
'activated': {
'description': 'Activate the beep channel to report auditive '
'messages.',
'default': False,
}
}
}
config_reader = ConfigReader(
spec=CONFIG_READER_SPEC,
ini=config_file,
dictionary=CONF_DEFAULTS,
)
Raw data
{
"_id": null,
"home_page": "",
"name": "conf2levels",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.10,<4.0",
"maintainer_email": "",
"keywords": "",
"author": "Josef Friedrich",
"author_email": "josef@friedrich.rocks",
"download_url": "https://files.pythonhosted.org/packages/f7/6b/78fa304698d9a2a3029c4448d730da6c977b9892f23c39a9d2854a693280/conf2levels-0.5.1.tar.gz",
"platform": null,
"description": ".. image:: http://img.shields.io/pypi/v/conf2levels.svg\n :target: https://pypi.org/project/conf2levels\n :alt: This package on the Python Package Index\n\n.. image:: https://github.com/Josef-Friedrich/conf2levels/actions/workflows/tests.yml/badge.svg\n :target: https://github.com/Josef-Friedrich/conf2levels/actions/workflows/tests.yml\n :alt: Tests\n\nA configuration reader which reads values stored in two key levels.\nThe first key level is named ``section`` and the second level ``key``.\n\nargparse arguments (`argparse`): (You have to specify a mapping)\n\n.. code:: python\n\n mapping = {\n 'section.key': 'args_attribute'\n }\n\nA python dictionary (`dictonary`):\n\n.. code:: python\n\n {\n 'section': {\n 'key': 'value'\n }\n }\n\nEnvironment variables (`environ`):\n\n.. code:: shell\n\n export prefix__section__key=value\n\nINI file (`ini`):\n\n.. code:: ini\n\n [section]\n key = value\n\n\n.. code:: python\n\n CONF_DEFAULTS = {\n 'email': {\n 'subject_prefix': 'command_watcher',\n },\n 'nsca': {\n 'port': 5667,\n },\n }\n\n CONFIG_READER_SPEC: Spec = {\n 'email': {\n 'from_addr': {\n 'description': 'The email address of the sender.',\n },\n 'to_addr': {\n 'description': 'The email address of the recipient.',\n 'not_empty': True,\n },\n 'to_addr_critical': {\n 'description': 'The email address of the recipient to send '\n 'critical messages to.',\n 'default': None,\n },\n 'smtp_login': {\n 'description': 'The SMTP login name.',\n 'not_empty': True,\n },\n 'smtp_password': {\n 'description': 'The SMTP password.',\n 'not_empty': True,\n },\n 'smtp_server': {\n 'description': 'The URL of the SMTP server, for example: '\n '`smtp.example.com:587`.',\n 'not_empty': True,\n },\n },\n 'icinga': {\n 'url': {\n 'description': 'The HTTP URL. /v1/actions/process-check-result '\n 'is appended.',\n 'not_empty': True,\n },\n 'user': {\n 'description': 'The user for the HTTP authentification.',\n 'not_empty': True,\n },\n 'password': {\n 'description': 'The password for the HTTP authentification.',\n 'not_empty': True,\n },\n },\n 'beep': {\n 'activated': {\n 'description': 'Activate the beep channel to report auditive '\n 'messages.',\n 'default': False,\n }\n }\n }\n\n config_reader = ConfigReader(\n spec=CONFIG_READER_SPEC,\n ini=config_file,\n dictionary=CONF_DEFAULTS,\n )\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A configuration reader which reads values stored in two key levels. The first key level is named \u201csection\u201d and the second level \u201ckey\u201d.",
"version": "0.5.1",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "37bdf103751cbb7b06960f20d42f934b8d8be6d54de41664c7ad2bbaa7290cb1",
"md5": "58992fdcafe1499a38641b1ae83ee6f1",
"sha256": "64f4920e412309e98fc920e5343a78759ced21de4d985ff143cffc95017883f5"
},
"downloads": -1,
"filename": "conf2levels-0.5.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "58992fdcafe1499a38641b1ae83ee6f1",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.10,<4.0",
"size": 9842,
"upload_time": "2024-02-16T22:04:59",
"upload_time_iso_8601": "2024-02-16T22:04:59.524222Z",
"url": "https://files.pythonhosted.org/packages/37/bd/f103751cbb7b06960f20d42f934b8d8be6d54de41664c7ad2bbaa7290cb1/conf2levels-0.5.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f76b78fa304698d9a2a3029c4448d730da6c977b9892f23c39a9d2854a693280",
"md5": "713a346c60a2b0c3abe5b9967e76dde3",
"sha256": "7e25fca08766d57d5eae86e0b7420734a83a87c410e9cf6bdbfddf96a3feb8ac"
},
"downloads": -1,
"filename": "conf2levels-0.5.1.tar.gz",
"has_sig": false,
"md5_digest": "713a346c60a2b0c3abe5b9967e76dde3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10,<4.0",
"size": 6854,
"upload_time": "2024-02-16T22:05:00",
"upload_time_iso_8601": "2024-02-16T22:05:00.953909Z",
"url": "https://files.pythonhosted.org/packages/f7/6b/78fa304698d9a2a3029c4448d730da6c977b9892f23c39a9d2854a693280/conf2levels-0.5.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-02-16 22:05:00",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "conf2levels"
}