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
# configure.py
import appconfigpy
CONFIG_NAME = "example"
CONFIG_ITEM_LIST = [
appconfigpy.ConfigItem(
name="token",
initial_value=None,
prompt_text="API Token",
default_display_style=appconfigpy.DefaultDisplayStyle.PART_VISIBLE
),
appconfigpy.ConfigItem(
name="path",
prompt_text="Path",
initial_value=".",
),
]
if __name__ == "__main__":
app_config_manager = appconfigpy.ConfigManager(
config_name=CONFIG_NAME, config_item_list=CONFIG_ITEM_LIST)
app_config_manager.configure()
$ ./configure.py
API Token: abcdefghijklmn
Path [.]:
$ cat ~/.example
{
"path": ".",
"token": "abcdefghijklmn"
}
Load A Configuration File
# load.py
import appconfigpy
CONFIG_NAME = "example"
CONFIG_ITEM_LIST = [
appconfigpy.ConfigItem(
name="token",
initial_value=None,
prompt_text="API Token",
default_display_style=appconfigpy.DefaultDisplayStyle.PART_VISIBLE
),
appconfigpy.ConfigItem(
name="path",
prompt_text="Path",
initial_value=".",
),
]
if __name__ == "__main__":
app_config_manager = appconfigpy.ConfigManager(
config_name=CONFIG_NAME, config_item_list=CONFIG_ITEM_LIST)
print(app_config_manager.load())
$ ./load.py
{'token': 'abcdefghijklmn', 'path': '.'}
Dependencies
Python 2.7+ or 3.3+
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.0.1.tar.gz
(5.1 kB
view hashes)
Built Distribution
Close
Hashes for appconfigpy-0.0.1-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 91591e06a226bba4663e9ce1d378032b347262715bb04bde230b146e66370fac |
|
MD5 | 897cb9a46b82fbd3570eb1278f65902b |
|
BLAKE2b-256 | a49938b34c9915dd93988a2183b62dae71d40ef6b0ac186208203f0147cca97a |