Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/thombashi/appconfigpy
A Python library to create/load an application configuration file.
https://github.com/thombashi/appconfigpy
application-configuration configuration python-library
Last synced: 4 months ago
JSON representation
A Python library to create/load an application configuration file.
- Host: GitHub
- URL: https://github.com/thombashi/appconfigpy
- Owner: thombashi
- License: mit
- Created: 2017-03-05T09:09:58.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-07-16T10:13:54.000Z (over 1 year ago)
- Last Synced: 2024-05-17T00:01:44.574Z (9 months ago)
- Topics: application-configuration, configuration, python-library
- Language: Python
- Size: 114 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
.. contents:: **appconfigpy**
:backlinks: top
:local:Summary
=======
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/WindowsInstallation
============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-appconfigpyUsage
=====Create a configuration file from user inputs
-------------------------------------------------------
.. 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"
}Load a configuration file
-------------------------------------------------------
.. 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': '.'}Dependencies
============
Python 3.7+Optional Dependencies
------------------------------------
- `click `__
- `loguru `__
- Used for logging if the package installed
- `pathvalidate `__
- `typepy `__