config utility.
Project description
# os-config
[![Build Status](https://www.travis-ci.org/cfhamlet/os-config.svg?branch=master)](https://www.travis-ci.org/cfhamlet/os-config)
[![codecov](https://codecov.io/gh/cfhamlet/os-config/branch/master/graph/badge.svg)](https://codecov.io/gh/cfhamlet/os-config)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/os-config.svg)](https://pypi.python.org/pypi/os-config)
[![PyPI](https://img.shields.io/pypi/v/os-config.svg)](https://pypi.python.org/pypi/os-config)
Config utility.
In python world, it is common to use an object as config. But normal object lacks of some useful features for config purpose. This library offers an ``Config`` object which support create, update, attribute access, etc. Consider the usability and complexity in real programming work, config attribute types are limited into: ``int``, ``long``, ``float``, ``NoneType``, ``bool``, ``str``, ``unicode``, ``tuple`` and ``Config``. ``list``, ``dict`` will convert to ``tuple`` and ``Config``.
# Install
`pip install os-config`
# Usage
* create an empty config
```
from os_config import Config
config = Config.create()
```
* create from params
```
config = Config.create(a=1, b=2)
assert config.a == 1
assert config.b == 2
```
* create from dict
```
config = Config.from_dict({'a':1, 'b':2})
```
* create from json
```
json_string = '{"a": 1, "b": 2}'
config = Config.from_json(json_string)
```
* update from another config/dict
```
config1 = Config.create(a=1)
config2 = Config.create(a=2, b=3)
Config.update(config2, config1)
```
# Unit Tests
`$ tox`
# License
MIT licensed.
[![Build Status](https://www.travis-ci.org/cfhamlet/os-config.svg?branch=master)](https://www.travis-ci.org/cfhamlet/os-config)
[![codecov](https://codecov.io/gh/cfhamlet/os-config/branch/master/graph/badge.svg)](https://codecov.io/gh/cfhamlet/os-config)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/os-config.svg)](https://pypi.python.org/pypi/os-config)
[![PyPI](https://img.shields.io/pypi/v/os-config.svg)](https://pypi.python.org/pypi/os-config)
Config utility.
In python world, it is common to use an object as config. But normal object lacks of some useful features for config purpose. This library offers an ``Config`` object which support create, update, attribute access, etc. Consider the usability and complexity in real programming work, config attribute types are limited into: ``int``, ``long``, ``float``, ``NoneType``, ``bool``, ``str``, ``unicode``, ``tuple`` and ``Config``. ``list``, ``dict`` will convert to ``tuple`` and ``Config``.
# Install
`pip install os-config`
# Usage
* create an empty config
```
from os_config import Config
config = Config.create()
```
* create from params
```
config = Config.create(a=1, b=2)
assert config.a == 1
assert config.b == 2
```
* create from dict
```
config = Config.from_dict({'a':1, 'b':2})
```
* create from json
```
json_string = '{"a": 1, "b": 2}'
config = Config.from_json(json_string)
```
* update from another config/dict
```
config1 = Config.create(a=1)
config2 = Config.create(a=2, b=3)
Config.update(config2, config1)
```
# Unit Tests
`$ tox`
# License
MIT licensed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
os-config-0.2.3.tar.gz
(6.1 kB
view details)
File details
Details for the file os-config-0.2.3.tar.gz
.
File metadata
- Download URL: os-config-0.2.3.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.5.0 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/2.7.14
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb5fa6a45f1d37f06dc81df7804e04d0d04256df82889e9cdfed66c3260e280e |
|
MD5 | ffcb25f2e1a56640ec17d274ffccc2a4 |
|
BLAKE2b-256 | c647772f3336b5736f63ece58e22a5fc2ba762659d1a1de3e1ffaa0817734c17 |