Skip to main content

Programmatic configuration library for Python 3.

Project description

ConfigMaster

Build Status PyPI version PyPI DailyDownloads

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}

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

ConfigMaster-2.3.5.tar.gz (8.5 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ConfigMaster-2.3.5-py3.4.egg (24.5 kB view details)

Uploaded Egg

ConfigMaster-2.3.5-py3.3.egg (24.8 kB view details)

Uploaded Egg

ConfigMaster-2.3.5-py3.2.egg (24.3 kB view details)

Uploaded Egg

ConfigMaster-2.3.5-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file ConfigMaster-2.3.5.tar.gz.

File metadata

  • Download URL: ConfigMaster-2.3.5.tar.gz
  • Upload date:
  • Size: 8.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for ConfigMaster-2.3.5.tar.gz
Algorithm Hash digest
SHA256 e90f9770038cbbb90907cc3e4fcf31298a607379fd134e34a506d5a8790ada0f
MD5 a8206a7ccb8f1e23bbce2e316d550c5c
BLAKE2b-256 9f74c66cdf87b0b9d14bf2bdbddd0c8aa8f293f7ec2b3f387f4afe3abe551db7

See more details on using hashes here.

File details

Details for the file ConfigMaster-2.3.5-py3.4.egg.

File metadata

File hashes

Hashes for ConfigMaster-2.3.5-py3.4.egg
Algorithm Hash digest
SHA256 22f7ead54d5a505b03ecdb743a1da700402866fbfff8d06d69974eda8199014c
MD5 ac56edaba8a877285f032e8b312683ea
BLAKE2b-256 164fd05702d930015ac465707c8e8532be1a7dff8e8299e2515cf33decbc052c

See more details on using hashes here.

File details

Details for the file ConfigMaster-2.3.5-py3.3.egg.

File metadata

File hashes

Hashes for ConfigMaster-2.3.5-py3.3.egg
Algorithm Hash digest
SHA256 a31ed3f06f3a99f6e4f931cec3f0e227b423110e1a0fc385be3c1a093a92a2a0
MD5 20f4ea8546e7dfabbafa10615a518474
BLAKE2b-256 87e9d8c4861d7c2f45b1c6bff717d7d2df886db6120ebbde40d40bab9749b2bb

See more details on using hashes here.

File details

Details for the file ConfigMaster-2.3.5-py3.2.egg.

File metadata

File hashes

Hashes for ConfigMaster-2.3.5-py3.2.egg
Algorithm Hash digest
SHA256 61f1b64447b017bb5ff8a7764a7833cb1e0b03bf9ac4f82642394469dd836ee2
MD5 a02dc55ed5a59476d87275f3d590c6f3
BLAKE2b-256 e1a6212c0b8713f9faca761cb51b3d00772985ed44b9e485f0acc69d22c4a79b

See more details on using hashes here.

File details

Details for the file ConfigMaster-2.3.5-py3-none-any.whl.

File metadata

File hashes

Hashes for ConfigMaster-2.3.5-py3-none-any.whl
Algorithm Hash digest
SHA256 b7ec60cb2bd3b866135afca59547a65dff5c79453b2a8cdc0f97dad82e4c0b91
MD5 8c05c13413949ab89cb39d435f946ed8
BLAKE2b-256 436fe6ee7f9da314791a629a37cb25544f916c582b59ed2b9af2042984c0b0c8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page