Skip to main content

A Python to class to hold configuration values.

Project description

configclass - A Python to class to hold configuration values

https://travis-ci.org/schettino72/configclass.png?branch=master https://coveralls.io/repos/schettino72/configclass/badge.png

A Config is a dict with a where:

  • existing items can be modified but no items can not be added

  • has make() method so you can easily created derived configs

  • make() has the same API as dict.update()

  • make() will merge values according to mergedict.ConfigDict.merge()

  • for convenience, make can take a None to perform a simple copy

>>> from configclass import Config

>>> c1 = Config({'a': 1, 'b': ['foo']})

# can't add new items to config
>>> c1.make({'a':2, 'c': [2]})
Traceback (most recent call last):
KeyError: 'New items can not be added to Config, invalid key:c'

# new config object created
>>> c2 = c1.make({'a':2})
>>> c2
Config({'a': 2, 'b': ['foo']})

# original object is not modified
>>> c1
Config({'a': 1, 'b': ['foo']})

# make() can take keyword arguments, note how lists are merged
>>> c2.make(b=['bar'])
Config({'a': 2, 'b': ['foo', 'bar']})

configclass.ConfigMixin can be used to create a Config class that is not based on mergedict.ConfigDict. Check unittests for usage.

Project Details

license

The MIT License Copyright (c) 2014 Eduardo Naufel Schettino

see LICENSE file

developers / contributors

  • Eduardo Naufel Schettino

install

$ pip install configclass

or download and:

$ python setup.py install

tests

Install dependencies in dev_requirements.txt.

To run the tests:

$ py.test

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

configclass-0.1.0.tar.gz (3.2 kB view details)

Uploaded Source

File details

Details for the file configclass-0.1.0.tar.gz.

File metadata

  • Download URL: configclass-0.1.0.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for configclass-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e10b26d2476089d3c98e7dd3b535a93df86a3c6c86a3d08ec047f4d730f9dd1c
MD5 e49798a7ddba6f7c198639c0721082ef
BLAKE2b-256 8dbdc408897e93e150f1108bdca05cd1e19fac96ab4c6f41c138fc2be93397c3

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