bear
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.
Events
Right now I’m going to use a very simple “plugin” style for event hanlders where any .py file found in a directory is imported as a module.
This will, I think, let me use the event plugins via the command line, but also via WebHooks because I can create a Flask listener for WebHook urls and then call the defined handler for a given event.
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.9.tar.gz
.
File metadata
- Download URL: bearlib-0.9.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05d4f6c6b68e6beca742f52cc60fea7e93cea354a75b0c39831d509f33d6d893 |
|
MD5 | db908ab6d1856d649b587e0810ec7dda |
|
BLAKE2b-256 | 0140d418bef29db67d2a2a67000c47895d243faa416a49deeb0b86cd950e9a2b |
File details
Details for the file bearlib-0.9-py2-none-any.whl
.
File metadata
- Download URL: bearlib-0.9-py2-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 154b3b63006e91ff6d313d75ea49a64a6ac0b4798e8a4939043274e78bc0e636 |
|
MD5 | f9fad1c2ee7148dfdda03eaec3a4646c |
|
BLAKE2b-256 | a034d258b92bdbe247255a6fcc76c9abba3cf05ebcebdd23389b3a87e21db799 |