conf_d
read configuration files, conf.d style
Requirements
Python 2.6+ or Python 3.4+
Installation
Using PIP:
From Github:
pip install git+git://github.com/josegonzalez/conf_d.git#egg=conf_d
From PyPI:
pip install conf_d==0.1.0
Usage
usage:
# in your /etc/derp/conf file
[derp]
no: sleep
til: brooklyn
[herp]
sleep: 1
wait: 5.0
timeout: seventy
# From your fictional derp module
from conf_d import Configuration
def digitize(config):
for key in config:
if not config[key].isdigit():
try:
config[key] = float(config[key])
except ValueError:
pass
else:
try:
config[key] = int(config[key])
except ValueError:
pass
return config
# All defaults must be strings
conf = Configuration(
name="derp",
path="/etc/derp/conf",
main_defaults={
"no": "one",
"expected": "the spanish inquisition",
"cats": "1",
},
section_parser=digitize
)
what_not_to_do = conf.get(section='derp', key='no', default="jumping")
# "sleep"
until_when = conf.get(section='derp', key='til')
# "brooklyn"
cats = conf.get(section='derp', key='cats')
# "1"
dogs = conf.get(section='derp', key='dogs')
# None
sleep = conf.get(section='herp', key='sleep')
# 1
wait = conf.get(section='herp', key='wait')
# 5.0
timeout = conf.get(section='herp', key='timeout')
# "seventy"
section_exists = conf.has(section='derp')
# True
section_exists = conf.has(section='derp', key='no')
# True
raw_data = conf.raw()
# {
# 'sections': {
# 'herp': {
# 'sleep': 1,
# 'wait': 5.0,
# 'timeout': 'seventy'
# }
# },
# 'derp': {
# 'expected': 'the spanish inquisition',
# 'til': 'brooklyn',
# 'cats': '1',
# 'no': 'sleep'
# }
# }
Changelog
0.1.0 (2018-12-12)
Feat: add release script. [Jose Diaz-Gonzalez]
Add support for Python 3 (up to Python 3.7) [Xavier Hardy]
Add tox.ini file Add gitignore
0.0.4 (2013-12-13)
Change assertDictEquals to assertEquals. [Clay Pence]
Allow using custom config parser. [Clay Pence]
Instead of using ConfigParser.ConfigParser, let the user pass in a parser.
0.0.3 (2013-05-23)
Allow overriding the confd_path from an entry in the main config. [Jose Diaz-Gonzalez]
0.0.2 (2013-04-18)
Fix issue where main section was not always created. [Jose Diaz- Gonzalez]
0.0.1 (2013-04-14)
Initial commit. [Jose Diaz-Gonzalez]
Metadata
Release files for conf_d 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| conf_d-0.1.0.tar.gz | 4.6 kB | Without provenance | Details for conf_d-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| conf_d-0.1.0-py2-none-any.whl | Python 2 | none | any | Details for conf_d-0.1.0-py2-none-any.whl |
Total release size: 9.1 kB
Release files / conf_d-0.1.0.tar.gz
| Download URL | conf_d-0.1.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6230053efae4631350ef7892e6145d7d967bdb7e6e8ca74251a828ecbc5645c6
|
|
BLAKE2b-256 checksum How to use checksums |
78b8f096e604ae7d2e1116891d83bda96de3f9e68003c5a443216011d8c32038
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/2.7
|
Release files / conf_d-0.1.0-py2-none-any.whl
| Download URL | conf_d-0.1.0-py2-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 2 |
|
SHA-256 checksum How to use checksums |
fe44e8b00b1acca59956949e2fbd83629550e6fbfb55b70106ba07b1451751b7
|
|
BLAKE2b-256 checksum How to use checksums |
9908bbe0de699a79fb1a10c108556cf9b936cb8673e15949ea6ba6fc45069786
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
Python-urllib/2.7
|
Security for conf_d 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.