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 configurations, but we will add support for other formats soon (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
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.0.1.tar.gz
(3.2 kB
view hashes)
Built Distribution
Close
Hashes for manageconfig-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ca187d215e505c2a3ed8a419769034527039eb0370ec5290824094bf1b3e900 |
|
MD5 | 975e9b42a4961a49fe8ebec1af62c909 |
|
BLAKE2b-256 | e5e1ae7e8efd9048fbb4d954bd6cba7f912cdcb8b928ed3b76eae7139069ebc5 |