semvec/pypi-packages huggingface dataset:
conflib 1.0.0
Manage configuration hierarchies
License: MIT License

conflib
=========

[![Latest Version](https://img.shields.io/pypi/v/conflib.svg)](https://pypi.python.org/pypi/conflib/)
[![Coverage Status](https://img.shields.io/coveralls/akerl/conflib.svg)](https://coveralls.io/r/akerl/conflib)
[![Build Status](https://img.shields.io/travis/akerl/conflib.svg)](https://travis-ci.org/akerl/conflib)
[![MIT Licensed](https://img.shields.io/badge/license-MIT-green.svg)](https://tldrlegal.com/license/mit-license)

Simplifies configuration stacking. Primarily, this was written to allow stacking of default, global, and local settings. It allows for validation so that you can enforce contraints on supplied options.

## Usage

Using conflib is just a matter of importing it and giving it some dictionaries to stack:

```
>>> import conflib
>>> Default = {'hello': 'world', 'alpha': 5}
>>> Global = {'wat': 'wut', 'fancy': (20, 'fish')}
>>> Local = {'hello': 'everybody', 'beta': 'qwerty'}
>>> Config = conflib.Config(Default, Global, Local)
>>> print(Config.options)
{'alpha': 5, 'wat': 'wut', 'beta': 'qwerty', 'hello': 'everybody', 'fancy': (20, 'fish')}
```

If you need to stack on new configs later, go for it:

```
>>> Config.stack({'wat': 'new_value', 'extra': 10})
>>> print(Config.options)
{'alpha': 5, 'wat': 'new_value', 'beta': 'qwerty', 'hello': 'everybody', 'fancy': (20, 'fish'), 'extra': 10}
```

Pass in a validation dictionary if you want to check the provided arguments:

```
Validator = {
    'alpha': lambda x: x < 10,
    'fancy': tuple,
    'beta': [('asdf', 'qwerty'), ('fizz','buzz')]
}
Config.validate(Validator)
```

Alternately, you can pass in a validation\_dict when creating a Config object. Validation failures raise ValueError with a message indicating the specific failure. There are several available options for the Validation dictionary:

* `bool`: Converts 'y', 'yes', '1', 1, and True to True, and 'n', 'no', '0', 0 and False to False
* `int`: Casts provided value as an integer
* A list of tuples: looks for the provided value as a member of any of the tuples, and returns the first item in that tuple
* A list: looks for the provided value in the list
* Any type (`str`, `float`, etc): validates that the provided value is of the specified type (does not try to cast it)
* A callable: Runs the provided function, which should either return the validated value or raise TypeError

## Installation

    pip install conflib

## License

conflib is released under the MIT License. See the bundled LICENSE file for details.
modlib 1.0.0
Dynamic module loader
License: MIT License

modlib
=========

[![Latest Version](https://img.shields.io/pypi/v/modlib.svg?style=flat)](https://pypi.python.org/pypi/modlib/)
[![Coverage Status](https://img.shields.io/coveralls/akerl/modlib.svg?style=flat)](https://coveralls.io/r/akerl/modlib)
[![Build Status](https://img.shields.io/travis/akerl/modlib.svg?style=flat)](https://travis-ci.org/akerl/modlib)
[![MIT Licensed](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](https://tldrlegal.com/license/mit-license)

Simplifies importing dynamic modules. It exposes the Modstack class, which collects modules as you import them. If you need the same module again, it will return the existing module from the stack rather than reimporting it. It also supports getting a specific item from the modules rather than the full module

## Usage

The basic usage is pretty straightforward:

```
import modlib

stack = modlib.Modstack
names = ['foo.bar', 'alpha', 'hello.world']
modules = { x: stack.get(x) for x in names }
```

It's possible to use a custom formula for your module path. The default is `'{0}'`, which takes the name you pass to `.get()` directly. This is useful if your modules follow a common pattern. For instance, if your modules are stored in `./modules/{kind}/{name}`, you can pass that parameter to Modstack:

```
import modlib

stack = modlib.Modstack(formula='modules.{kind}.{name}')
fruits = ['apple', 'orange', 'tomato']
fruit_modules = { x: stack.get(kind='fruit', name=x) for x in fruits }
```

You can also specify a target object, and only that object will be pulled from the module. For instance, if you want to pull the run() method from each of your modules:

```
import modlib

stack = modlib.Modstack(target='run')
actions = ['jump', 'swim', 'bike']
action_methods = { x: stack.get(x) for x in names }
```

## Installation

    pip install modlib

## License

modlib is released under the MIT License. See the bundled LICENSE file for details.