A Python library to create/load an application configuration file.
Project description
appconfigpy
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="."),
],
)
try:
app_config_mgr.configure()
except KeyboardInterrupt:
print()
$ ./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
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.2.0.tar.gz
(6.1 kB
view hashes)
Built Distribution
Close
Hashes for appconfigpy-0.2.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 480a60bfb62c58173f1ce4eb9c0122a46f58fa328ccf38442ea3f820e7135558 |
|
MD5 | c4bb4e5291d59fb6b3f122cdf6356fa6 |
|
BLAKE2b-256 | 8819a0e85c55048767270d65497ff0af0fe3bd91a0622dcb701be82188bb3c6b |