Skip to main content
This package on the Python Package Index 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)

mapping = {
    'section.key': 'args_attribute'
}

A python dictionary (dictonary):

{
    'section':  {
        'key': 'value'
    }
}

Environment variables (environ):

export prefix__section__key=value

INI file (ini):

[section]
key = value
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,
)

Metadata

Release files for conf2levels 0.5.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for conf2levels 0.5.1
File Size Uploaded
conf2levels-0.5.1.tar.gz 6.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for conf2levels 0.5.1
File Interpreter ABI Platform
conf2levels-0.5.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.7 kB

Release files / conf2levels-0.5.1.tar.gz

Download URL conf2levels-0.5.1.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
7e25fca08766d57d5eae86e0b7420734a83a87c410e9cf6bdbfddf96a3feb8ac
BLAKE2b-256 checksum
How to use checksums
f76b78fa304698d9a2a3029c4448d730da6c977b9892f23c39a9d2854a693280
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1019-azure

Release files / conf2levels-0.5.1-py3-none-any.whl

Download URL conf2levels-0.5.1-py3-none-any.whl
Size 9.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64f4920e412309e98fc920e5343a78759ced21de4d985ff143cffc95017883f5
BLAKE2b-256 checksum
How to use checksums
37bdf103751cbb7b06960f20d42f934b8d8be6d54de41664c7ad2bbaa7290cb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1019-azure

Release history Release notifications | RSS feed

This release

0.5.1 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page