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.5+
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.4.0.tar.gz
(7.3 kB
view hashes)
Built Distribution
Close
Hashes for appconfigpy-0.4.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 18bdd9c24f899f0ab7a7c9da60367ca391a17eedafb5ac8b55e4ebe3a5a61943 |
|
MD5 | b427e417c8ad5d2b25d406548643554e |
|
BLAKE2b-256 | ae27dee966ed5cf14bbddf57e1ee7af0ad095e2c62cf02c8bde73e932a65409d |