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
- loguru
Used for logging if the package installed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
appconfigpy-2.0.1.tar.gz
(8.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file appconfigpy-2.0.1.tar.gz.
File metadata
- Download URL: appconfigpy-2.0.1.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
82e459d20e0f89fad8330395960ba2b16e4ebb9d7cfb42f26a077d4a88b8d4a2
|
|
| MD5 |
c1589ab6d7711f3f0bf861ecd3ac55b4
|
|
| BLAKE2b-256 |
51a05dbaf3c8b45b67350635d0e298913ea020efbd0474cdb13cbeb7aebfadb6
|
File details
Details for the file appconfigpy-2.0.1-py3-none-any.whl.
File metadata
- Download URL: appconfigpy-2.0.1-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ba7ce752f76622d0bde01ea501892858da27e8be1a5d9936f163452522038b8
|
|
| MD5 |
b065f505919ba0db1b341ad2eafc3142
|
|
| BLAKE2b-256 |
795818541de6b0a912b5cdeee21c88fb4c5a5013fa62568411a4b28e500d20ff
|