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
Built Distribution
File details
Details for the file bearlib-0.8.1.tar.gz
.
File metadata
- Download URL: bearlib-0.8.1.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1507e699ee939128a7233c48e1e751b96979a1dc606d4726f018b467db219539 |
|
MD5 | d33e8b75de10422ada3e1faed4ac53a9 |
|
BLAKE2b-256 | 69611822a0b961ac3920f09355f0f11c3fc1c90bbba94dc8a34d185530332787 |
File details
Details for the file bearlib-0.8.1-py2-none-any.whl
.
File metadata
- Download URL: bearlib-0.8.1-py2-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f7b86a87d8ecf421b85a8add09d16be7721e8125adc6195136f4c5b00940826 |
|
MD5 | 1480e46f619ff496fadebe22cd6c3a55 |
|
BLAKE2b-256 | 7fe590498bfe8982dfb82e394fda0905d515d27018bd21afb1855d875b466fd4 |