appconfigpy-2.0.0
توضیحات
A Python library to create/load an application configuration file.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | OS Independent |
| نام فایل | appconfigpy-2.0.0 |
| نام | appconfigpy |
| نسخه کتابخانه | 2.0.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | Tsuyoshi Hombashi |
| ایمیل نویسنده | tsuyoshi.hombashi@gmail.com |
| آدرس صفحه اصلی | https://github.com/thombashi/appconfigpy |
| آدرس اینترنتی | https://pypi.org/project/appconfigpy/ |
| مجوز | MIT License |
.. 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/Windows
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
-------------------------------------------------------
.. 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 <https://palletsprojects.com/p/click/>`__
- `loguru <https://github.com/Delgan/loguru>`__
- Used for logging if the package installed
- `pathvalidate <https://github.com/thombashi/pathvalidate>`__
- `typepy <https://github.com/thombashi/typepy>`__
نیازمندی
| مقدار | نام |
|---|---|
| <1,>=0.4.1 | loguru |
| - | pytest |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.7 | Python |
نحوه نصب
نصب پکیج whl appconfigpy-2.0.0:
pip install appconfigpy-2.0.0.whl
نصب پکیج tar.gz appconfigpy-2.0.0:
pip install appconfigpy-2.0.0.tar.gz