Giter Club home page Giter Club logo

bearlib's Introduction

bearlib

A simple collection of helper routines that I use in a lot of projects.

Build Status Requirements Status Wheel Status CodeCov Report

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 handlers 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

bearlib's People

Contributors

bear avatar lewiscowles1986 avatar movermeyer avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.