flexiconf-1.0.4
توضیحات
Simple and flexible separation settings from code
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | flexiconf-1.0.4 |
| نام | flexiconf |
| نسخه کتابخانه | 1.0.4 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Ivan Chernousov |
| ایمیل نویسنده | krusnik.viers@gmail.com |
| آدرس صفحه اصلی | https://github.com/KrusnikViers/flexiconf |
| آدرس اینترنتی | https://pypi.org/project/flexiconf/ |
| مجوز | - |
# flexiconf
Simple and flexible separation settings from code
[](https://travis-ci.org/KrusnikViers/flexiconf)
[](https://codecov.io/gh/KrusnikViers/flexiconf)
[](https://badge.fury.io/py/flexiconf)
[](https://codeclimate.com/github/KrusnikViers/flexiconf/maintainability)
Install: `pip install flexiconf`
## How to use:
### Config creation:
```
import flexiconf
config = flexiconf.Configuration([ ...loaders... ])
```
Configuration is being read at the moment of an object creation, all `get` are fast and read-only operations. Sources of the configuration are defined by loaders list, that will be described later.
You may also create multiple configurations with different sources - for example, parse command line parameters first, to define configuration files to be read as a full config later.
### Accessing parameters:
Configuration is treated as a tree of dicts and lists. For best compatibility, recommended to use only alphanumeric symbols and `_` as a key. Point `.` inside the key is treated as a divider between nested sections during both parsing ang getting.
After being parsed, tree could be received directly by `Configuration.as_dict()` method.
Different parameters could be received via get operators: with auto cast (`config.get_bool(...)`, `config.get_int(...)`, etc) or by generic `get` method. `get` methods receive `key_path` parameter (e.g. `section_1.subsection.key_name`) and optional `default` parameter of any type, including `None`. `KeyError` will be raised, if key was not found and default option was not provided.
### Loaders:
Loaders are objects, that read configuration from different sources. Loaders are executed in direct order, later loaders will override previously parsed options with the same keys.
`JsonLoader` and `IniLoader` are both take optional `config_files_pattern` parameter, describing `glob` pattern to files with configuration. If not provided, parser will look for all `*.json/*.ini` files in the caller directory recursively.
`EnvLoader` takes optional `pattern` parameter, to define keys to be added in configuration.
`ArgsLoader` looks for all command line parameters with `key=value` format, with optional number of `-` as a prefix.
### Custom loaders:
If you want to write your own loader, you could simply inherit from `flexiconf.BaseLoader` class and implement `load` method.
### Contribution:
If you have some improvements, bug fixes or think, that your loader will be useful for other people, feel free to create pull request!
نحوه نصب
نصب پکیج whl flexiconf-1.0.4:
pip install flexiconf-1.0.4.whl
نصب پکیج tar.gz flexiconf-1.0.4:
pip install flexiconf-1.0.4.tar.gz