Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (pypi.python.org).
Help us improve Python packaging - Donate today!

Programmatic configuration library for Python 3.

Project Description

ConfigMaster

What is ConfigMaster?

ConfigMaster is a simple library for accessing config files programmatically. No longer will you have to mess with list lookups and dict lookups when you wish to load a config file.
Instead, objects in the file are accessed as simple class attributes.

What is supported

ConfigMaster supports the following formats built-in:

  • YAML Config Files (through the PyYAML module)
  • JSON Config Files (through json)
  • INI Config Files (through ConfigParser)
  • Networked versions of YAML/JSON files.

Support for different types of config files grows all the time - feel free to fork and add support!

TODO

  • [STRIKEOUT:Add in support for python ConfigParser formats] Added in version 1.4.0
  • [STRIKEOUT:Add in networked JSON support] Added in version 1.3.0
  • Add more docstrings
  • Make proper documentation
  • [STRIKEOUT:Add tests] Added in version 1.3.1

How to install

For the latest stable version uploaded to PyPI, use:
pip install configmaster
For the latest stable version uploaded to git, use:
pip install git+ssh://cloning@git.sundwarf.me/SunDwarf/configmaster
For the latest dev version, use:
pip install git+ssh://cloning@git.sundwarf.me/SunDwarf/configmaster@develop

After installing, running the tests is recommended.

py.test -rfEsxXw -v --strict test.py

How to use

ConfigMaster handles everything for you. Simply specify the location of your file, and the values will be automatically loaded for you.

>>> from configmaster import YAMLConfigFile
>>> cfg = YAMLConfigFile.YAMLConfigFile("test.yml") # Created automatically if it doesn't exist

Networked config files are supported too.

>>> from configmaster import JSONConfigFile
>>> cfg = JSONConfigFile.NetworkedJSONConfigFile("http://example.com/data.json")

To access config values, get the attribute you want from the config object stored.

# YAML data is {"a": 1, "b": [1, 2], "c": {"d": 3}}
>>> cfg.config.a
1
>>> cfg.config.b[1]
2
>>> cfg.config.c.d
3

To populate your config data, just pass a dict to initial_populate. If the file is empty, this gives it default values, and returns True. If it isn’t, nothing happens. Note: This will fail with an exc.NetworkedFileException on networked files!

>>> pop = cfg.initial_populate({"a": 1, "b": [1, 2], "c": {"d": 3})
>>> if pop: cfg.dump() and cfg.reload() # Dump data and reload from disk.

To save your data, run .dump().

>>> cfg.dump()

Have a networked file that you need to save? Use the method save_to_file.

>>> cfg.save_to_file("example.json")

Need to get the raw dict form of a ConfigKey? Use .dump() on that!

>>> cfg.config.dump()
{"a": 1, "b": [1, 2], "c": {"d": 3}
>>> cfg.config.c.dump()
{"d": 3}
Release History

Release History

This version
History Node

2.3.6

History Node

2.3.5.post1

History Node

2.3.5

History Node

2.3.4.post1

History Node

2.3.3

History Node

2.3.2

History Node

2.3.1

History Node

2.3.0

History Node

2.2.2.post2

History Node

2.2.1

History Node

2.2.0

History Node

2.1.0

History Node

2.0.4.post2

History Node

2.0.4.post1

History Node

2.0.4

History Node

2.0.3

History Node

2.0.2

History Node

1.5.0

History Node

1.4.0

History Node

1.3.3.post2

History Node

1.3.2

History Node

1.3.1

History Node

1.3.0

History Node

1.2.2

History Node

1.2.0

History Node

1.1.4

History Node

1.1.3.post3

History Node

1.1.3.post2

History Node

1.1.3.post1

History Node

1.1.3

History Node

1.1.2

History Node

1.1.1

Download Files

Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
ConfigMaster-2.3.6-py3.2.egg (24.6 kB) Copy SHA256 Checksum SHA256 3.2 Egg Sep 6, 2015
ConfigMaster-2.3.6-py3.3.egg (25.0 kB) Copy SHA256 Checksum SHA256 3.3 Egg Sep 6, 2015
ConfigMaster-2.3.6-py3.4.egg (24.7 kB) Copy SHA256 Checksum SHA256 3.4 Egg Sep 6, 2015
ConfigMaster-2.3.6-py3.5.egg (24.7 kB) Copy SHA256 Checksum SHA256 3.5 Egg Sep 19, 2015
ConfigMaster-2.3.6.tar.gz (8.8 kB) Copy SHA256 Checksum SHA256 Source Sep 6, 2015

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting