Last updated:
0 purchases
appconfigpy 2.0.1
appconfigpy
Summary
Installation
Install from PyPI
Install from PPA (for Ubuntu)
Usage
Create a configuration file from user inputs
Load a configuration file
Dependencies
Optional Dependencies
Summary
A Python library to create/load an application configuration file.
Installation
Install from PyPI
pip install appconfigpy
Install from PPA (for Ubuntu)
sudo add-apt-repository ppa:thombashi/ppa
sudo apt update
sudo apt install python3-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_items=[
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_items=[
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 3.7+
Optional Dependencies
click
loguru
Used for logging if the package installed
pathvalidate
typepy
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.