Small package for working with config files
Project description
config manager
Installation:
pip install manageconfig
This library manages config files and exposes them as Python objects. It is super small, basic, and easy to use.
Note: This package currently supports only YAML and JSON configurations, but we will soon add support for other formats (and we are open to suggestions).
Example:
Suppose we want to load the config.py
file attached below. We can do it as follows:
from manageconfig import Config
conf = Config.load_from_yml('config.yml')
print(conf.string2)
print(conf.string1)
# This will print 'localhost'
print(conf.mysqldatabase.hostname)
# i == 3013
i = conf.mysqldatabase.port + 1
# comment syntax
# basic syntax - key and value separated by colon and space before the value
key: value
# Scalar data types
integerValue: 1 # integer value
floatingValue: 1 # floating vale
stringValue: "456" # string with double quotes
stringValue: 'abc' # string with single quotes
stringValue: wer # string without quotes
booleanValue: true # boolean values - true or false
# Multiline string with literal block syntax -preserved new lines
string1: |
Line1
line2
"line3"
line4
# Multiline strings with folded block syntax - new lines are not preserved, leading and trailing spaces are ignore
string2: >
Line1
line2
"line3"
line4
# Collection sequence data types
# sequence arraylist example
arraylist:
- One
- two
- Three
arraylist2: [one, two , three]
mysqldatabase:
hostname: localhost
port: 3012
username: root
password: root
JSON support: In order to use json format - simply use Config.load_from_json('config.json')
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
manageconfig-1.1.0.tar.gz
(3.4 kB
view details)
Built Distribution
File details
Details for the file manageconfig-1.1.0.tar.gz
.
File metadata
- Download URL: manageconfig-1.1.0.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | af0f4248ec08eb8660e74414cc86e3c3fc194882fac156e6c8a8b1dd6273f02c |
|
MD5 | 680a4c12cc5f10b83da9ea4343585c8b |
|
BLAKE2b-256 | 0e2a0f96725c869c77d513af2e4c021a36b5af0a45accefd1404ce87f4721509 |
File details
Details for the file manageconfig-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: manageconfig-1.1.0-py3-none-any.whl
- Upload date:
- Size: 3.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cec850f7de39ea95db2da780f8a0239ba7e7a5b6a275993ed5b47a88c7794bf0 |
|
MD5 | da85ad1618b26bcdfe98681cb30610a9 |
|
BLAKE2b-256 | 6e51bdd8c21944c043cfc4effe26b7adbeed4e9920ed45ac9a841dec5b3236ef |