Load configuration files and access them with dot-style syntax
Project description
Thumos Configr
A simple Python3 class to facilitate easy loading and access to configuration settings using dot-style syntax, with support for Yaml, JSON, TOML and XML. To clarify, dot-style syntax refers to something such as the following:
Example YAML file:
configuration:
mysql:
host: localhost
port: 3600
Using Configr, the values could be accessed in this way:
cr = Configr("config.yaml")
cr["configuration.mysql.host"]
>> localhost
cr["configuration.mysql.port"]
>> 3600
You may ask why one would want to use this instead of simply using a dictionary. The answer is; why not? Perhaps it's more convenient, more appealing to the eyes, or perhaps you're even coming from something like Spring Boot where this is the way it's usually done.
However, other characters than the dot can be used as a separator.
cr = Configr("config.yaml", separator="/")
cr["configuration/mysql/host"]
>> localhost
It is also possible to set an initial root key, to minimize verbosity when using deep configuration files that may contain settings not pertinent to the script or application you are working on. Take the following example YAML file:
this:
is:
nothingInteresting: Jimmy With A Law Degree Is Like A Chimp With A Machine Gun.
really:
fantastically:
deep: Is it not?
absolutely:
annoying: Indeed
cr = Configr("config.yaml", root_key="this.is.really")
cr["fantastically.deep"]
>> Is it not?
cr["absolutely.annoying"]
>> Indeed
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
Built Distribution
Hashes for thumos_configr-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a10dbe3b8ede7da05c99dc55ac9e096c1b2c8a8ef8f1e1cbb03403706e5b654 |
|
MD5 | 195dad9ca7d015952b01f158b50a0543 |
|
BLAKE2b-256 | 2a64a3ae27803c72044edf7372b1906696272c5212e54b6bc1b7f02272573ed2 |