A Python library to create/load an application configuration file.
Project description
Summary
A Python library to create/load an application configuration file.
Installation
pip install appconfigpy
Usage
Create a configuration file from user inputs
# configure.py
from appconfigpy import ConfigItem, ConfigManager, DefaultDisplayStyle
app_config_mgr = ConfigManager(
config_name="example",
config_item_list=[
ConfigItem(
name="token",
initial_value=None,
prompt_text="API Token",
default_display_style=DefaultDisplayStyle.PART_VISIBLE,
),
ConfigItem(name="path", prompt_text="ABC Path", initial_value="."),
],
)
app_config_mgr.configure()
$ ./configure.py
API Token: abcdefghijklmn
ABC Path [.]:
$ cat ~/.example
{
"path": ".",
"token": "abcdefghijklmn"
}
Load a configuration file
# load.py
from appconfigpy import ConfigItem, ConfigManager, DefaultDisplayStyle
app_config_mgr = ConfigManager(
config_name="example",
config_item_list=[
ConfigItem(
name="token",
initial_value=None,
prompt_text="API Token",
default_display_style=DefaultDisplayStyle.PART_VISIBLE,
),
ConfigItem(name="path", prompt_text="ABC Path", initial_value="."),
],
)
print(app_config_mgr.load())
$ ./load.py
{'token': 'abcdefghijklmn', 'path': '.'}
Dependencies
Python 2.7+ or 3.4+
Optional Dependencies
- logbook
Logging using logbook if the package installed
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
appconfigpy-0.3.0.tar.gz
(6.9 kB
view hashes)
Built Distribution
Close
Hashes for appconfigpy-0.3.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6110d9869aab558e1bd6578c5d67c98281bee887783df0d33085898f29ce1339 |
|
MD5 | 63c2064e31ca2370ff466a14f7ac4687 |
|
BLAKE2b-256 | bcd909c0776925a2fb4495cc9262cf7eb9e9ebb06df677ee1a29afba831108d7 |