bear's toolkit
Project description
bearlib
A simple collection of helper routines that I use in a lot of projects.
I used to just copy the directory into each project…
yes, a build/release person was breaking all the rules - sigh
Config
A dictionary based config class:
c = Config({ 'a': 1, 'b': 2, 'c': {'d': 1}} print("c.a =", c.a) print("c.c.d" =", c.c.d)
generates:
c.a = 1 c.c.d = 1
It also has three helper methods:
fromDict(dictionary) fromJson(filename) fromEtcd(host='127.0.0.1', port=4001, base='/')
fromDict() walks thru the keys of the given dictionary recursively and adds them to the object. Any key found that has a list or dictionary value is handled with instances of Config created as needed.
fromJson() uses json.load() to process the given filename and then calls fromDict() to store the values.
fromEtcd() walks the directory tree at the base location in the etcd server, builds a dictionary and then passes that to fromDict() for storage.
Install
from PyPI:
pip install bearlib
from git:
cd /base/of/your/virtualenv pip install -e git+https://github.com/bear/bearlib.git#egg=bearlib
to update the from-git install:
cd /base/of/your/virtualenv pip install –upgrade -e git+https://github.com/bear/bearlib.git#egg=bearlib
Tests
From the source directory:
make test
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
File details
Details for the file bearlib-0.6.0.tar.gz
.
File metadata
- Download URL: bearlib-0.6.0.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccd21783c4e362fad8850cbfc85845f8404d18d2c5b07550a4b3d7b71f006b8f |
|
MD5 | cd6f74fe9ae052209d03c417e9964379 |
|
BLAKE2b-256 | 37d76721141295185fb7d4abe8297ac1f82aa8fae3988d331128ec157c6e61c3 |