A Python library to create/load an application configuration file.
MIT License
.. contents:: appconfigpy :backlinks: top :local:
A Python library to create/load an application configuration file.
.. image:: https://badge.fury.io/py/appconfigpy.svg :target: https://badge.fury.io/py/appconfigpy :alt: PyPI package version
.. image:: https://img.shields.io/pypi/pyversions/appconfigpy.svg :target: https://pypi.org/project/appconfigpy :alt: Supported Python versions
.. image:: https://img.shields.io/pypi/implementation/appconfigpy.svg :target: https://pypi.org/project/appconfigpy :alt: Supported Python implementations
.. image:: https://github.com/thombashi/appconfigpy/actions/workflows/lint_and_test.yml/badge.svg :target: https://github.com/thombashi/appconfigpy/actions/workflows/lint_and_test.yml :alt: CI status of Linux/macOS/Windows
::
pip install appconfigpy
::
sudo add-apt-repository ppa:thombashi/ppa
sudo apt update
sudo apt install python3-appconfigpy
.. code:: python
# 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()
.. code::
$ ./configure.py
API Token: abcdefghijklmn
ABC Path [.]:
$ cat ~/.example
{
"path": ".",
"token": "abcdefghijklmn"
}
.. code:: python
# 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())
.. code::
$ ./load.py
{'token': 'abcdefghijklmn', 'path': '.'}
Python 3.7+
click <https://palletsprojects.com/p/click/>
__loguru <https://github.com/Delgan/loguru>
__
pathvalidate <https://github.com/thombashi/pathvalidate>
__typepy <https://github.com/thombashi/typepy>
__