A Python library to create/load an application configuration file.
Project description
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.5+
Optional Dependencies
- loguru
Used for logging 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-1.0.0.tar.gz
(7.5 kB
view hashes)
Built Distribution
Close
Hashes for appconfigpy-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06b6edea6408295482ba4e7adfbfc618fc80126c7b2ca4a16e596f5cd57ca17d |
|
MD5 | 8b2be6e77cbcdeb5e8b0ae5cc330f4e3 |
|
BLAKE2b-256 | 1ef88fc05477d612a039082f75772088f7930dc4521ce35a701e20acc3ff096c |