Parser for configuration from multiple sources
Project description
multiconfparse
multiconfparse
is a Python3 library for specifying and reading configuration
data from multiple sources.
Installation
python -m pip install git+https://github.com/jonathanhaigh/multiconfparse
Quickstart
-
Import the
multiconfparse
module:import multiconfparse.multiconfparse as mcp
-
Create a
ConfigParser
object:import multiconfparse.multiconfparse as mcp config_parser = mcp.ConfigParser()
ConfigParser
s:- contain the specifications of your configuration items;
- have
source
s - objects that can obtain configuration values from different sources; - coordinate the parsing done by
source
s; - merge configuration values from
source
s into a single set of values.
-
Add specifications of your config items:
# Add config items config_parser.add_config("config_item1", required=True) config_parser.add_config("config_item2", default="default_value")
-
Add
source
s:config_parser.add_source(mcp.SimpleArgparseSource) config_parser.add_source(mcp.JsonSource, "/path/to/config/file.json")
-
Parse config from all
source
s:config = config_parser.parse_config()
ConfigParser.parse_config()
returns amulticonfparse.Namespace
object which is essentially just a plain object with attributes for each config item. -
Use the config
item1 = config.config_item1 item2 = config.config_item2
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
multiconfparse-0.0.1.tar.gz
(8.9 kB
view hashes)
Built Distribution
Close
Hashes for multiconfparse-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c36b94b6a5325cf29d65d0d2dedc78d30301787621545fa3f8223049b0581d99 |
|
MD5 | 1f4aa7637df7ca855e850f0bab44af4c |
|
BLAKE2b-256 | 4c50d600c8c7e41eee203a14c3f52beda510ed5d799ad1679242b14911179442 |