Skip to main content

Forget about configparser, YAML, or JSON parsers. Focus on configuration.

Project description

Update on 2019-05-13: Version 1.35 and above require Python 3.6+.

Update on 2018-10-20: I no longer use this library. It tries to do too many things. It was written in Python 2.7 and made work with Python 3. With type hints, dataclasses, and many other cool features in Python 3.6+ you can express the same things in a much nicer way than this.


https://travis-ci.org/jbasko/configmanager.svg?branch=master

Don’t let standard library’s configparser drive your configuration value access design. Let it do what it does best – parse and write configuration files. And let configmanager do the rest.

Main Features

  • Every configuration item is an object with a type, a default value, a custom value and other metadata

  • No sections required

  • Any depth of sections allowed

  • INI (ConfigParser), JSON, YAML formats

  • click framework integration

Documentation

https://jbasko.github.io/configmanager/

Source Code and Issue Tracking

https://github.com/jbasko/configmanager

Quick Start

Install from Python Package index with pip install configmanager.

Declare your configuration, the sources, and off you go. Remember, every configuration item is an object, not just a plain configuration value. If you don’t need the rich features of configuration items, use configmanager.PlainConfig instead.

import warnings
from configmanager import Config

config = Config({
    'uploads': {
        'threads': 1,
        'enabled': False,
        'db': {
            'user': 'root',
            'password': {
                '@default': 'root',
                '@envvar': 'MY_UPLOADER_DB_PASSWORD',
            },
        }
    }
}, load_sources=[
    '/etc/my-uploader/config.ini',
    '~/.config/my-uploader/config.json',
], auto_load=True)

if config.uploads.db.user.is_default:
    warnings.warn('Using default db user!')

if config.uploads.enabled.get():
    connect_to_database(
        user=config.uploads.db.user.get(),
        password=config.uploads.db.password.get(),
    )

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

configmanager-1.35.1.tar.gz (55.5 kB view details)

Uploaded Source

File details

Details for the file configmanager-1.35.1.tar.gz.

File metadata

  • Download URL: configmanager-1.35.1.tar.gz
  • Upload date:
  • Size: 55.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.1

File hashes

Hashes for configmanager-1.35.1.tar.gz
Algorithm Hash digest
SHA256 2ca23c1f90c5abcc36330589997f98b8aee2353b9c2f113cee96d055c2e65f6f
MD5 912563332e9795853d23ff34c101ee0f
BLAKE2b-256 8b83abd0b5579dae48ab62844dd18ecec425fd1247b9103e3af392e96afc2270

See more details on using hashes here.

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