appconfigpy


Nameappconfigpy JSON
Version 2.0.1 PyPI version JSON
download
home_pagehttps://github.com/thombashi/appconfigpy
SummaryA Python library to create/load an application configuration file.
upload_time2023-07-16 10:14:03
maintainer
docs_urlNone
authorTsuyoshi Hombashi
requires_python>=3.7
licenseMIT License
keywords configuration
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            .. 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>`__

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/thombashi/appconfigpy",
    "name": "appconfigpy",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "configuration",
    "author": "Tsuyoshi Hombashi",
    "author_email": "tsuyoshi.hombashi@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/51/a0/5dbaf3c8b45b67350635d0e298913ea020efbd0474cdb13cbeb7aebfadb6/appconfigpy-2.0.1.tar.gz",
    "platform": null,
    "description": ".. contents:: **appconfigpy**\n   :backlinks: top\n   :local:\n\n\nSummary\n=======\nA Python library to create/load an application configuration file.\n\n\n.. image:: https://badge.fury.io/py/appconfigpy.svg\n    :target: https://badge.fury.io/py/appconfigpy\n    :alt: PyPI package version\n\n.. image:: https://img.shields.io/pypi/pyversions/appconfigpy.svg\n    :target: https://pypi.org/project/appconfigpy\n    :alt: Supported Python versions\n\n.. image:: https://img.shields.io/pypi/implementation/appconfigpy.svg\n    :target: https://pypi.org/project/appconfigpy\n    :alt: Supported Python implementations\n\n.. image:: https://github.com/thombashi/appconfigpy/actions/workflows/lint_and_test.yml/badge.svg\n    :target: https://github.com/thombashi/appconfigpy/actions/workflows/lint_and_test.yml\n    :alt: CI status of Linux/macOS/Windows\n\n\nInstallation\n============\n\nInstall from PyPI\n------------------------------\n::\n\n    pip install appconfigpy\n\nInstall from PPA (for Ubuntu)\n------------------------------\n::\n\n    sudo add-apt-repository ppa:thombashi/ppa\n    sudo apt update\n    sudo apt install python3-appconfigpy\n\n\nUsage\n=====\n\nCreate a configuration file from user inputs\n-------------------------------------------------------\n.. code:: python\n\n    # configure.py\n\n    from appconfigpy import ConfigItem, ConfigManager, DefaultDisplayStyle\n\n    app_config_mgr = ConfigManager(\n        config_name=\"example\",\n        config_items=[\n            ConfigItem(\n                name=\"token\",\n                initial_value=None,\n                prompt_text=\"API Token\",\n                default_display_style=DefaultDisplayStyle.PART_VISIBLE,\n            ),\n            ConfigItem(name=\"path\", prompt_text=\"ABC Path\", initial_value=\".\"),\n        ],\n    )\n\n    app_config_mgr.configure()\n\n\n.. code::\n\n    $ ./configure.py\n    API Token: abcdefghijklmn\n    ABC Path [.]:\n    $ cat ~/.example\n    {\n        \"path\": \".\",\n        \"token\": \"abcdefghijklmn\"\n    }\n\nLoad a configuration file\n-------------------------------------------------------\n.. code:: python\n\n    # load.py\n\n    from appconfigpy import ConfigItem, ConfigManager, DefaultDisplayStyle\n\n    app_config_mgr = ConfigManager(\n        config_name=\"example\",\n        config_items=[\n            ConfigItem(\n                name=\"token\",\n                initial_value=None,\n                prompt_text=\"API Token\",\n                default_display_style=DefaultDisplayStyle.PART_VISIBLE,\n            ),\n            ConfigItem(name=\"path\", prompt_text=\"ABC Path\", initial_value=\".\"),\n        ],\n    )\n\n    print(app_config_mgr.load())\n\n.. code::\n\n    $ ./load.py\n    {'token': 'abcdefghijklmn', 'path': '.'}\n\n\nDependencies\n============\nPython 3.7+\n\nOptional Dependencies\n------------------------------------\n- `click <https://palletsprojects.com/p/click/>`__\n- `loguru <https://github.com/Delgan/loguru>`__\n    - Used for logging if the package installed\n- `pathvalidate <https://github.com/thombashi/pathvalidate>`__\n- `typepy <https://github.com/thombashi/typepy>`__\n",
    "bugtrack_url": null,
    "license": "MIT License",
    "summary": "A Python library to create/load an application configuration file.",
    "version": "2.0.1",
    "project_urls": {
        "Homepage": "https://github.com/thombashi/appconfigpy",
        "Source": "https://github.com/thombashi/appconfigpy",
        "Tracker": "https://github.com/thombashi/appconfigpy/issues"
    },
    "split_keywords": [
        "configuration"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "795818541de6b0a912b5cdeee21c88fb4c5a5013fa62568411a4b28e500d20ff",
                "md5": "b065f505919ba0db1b341ad2eafc3142",
                "sha256": "5ba7ce752f76622d0bde01ea501892858da27e8be1a5d9936f163452522038b8"
            },
            "downloads": -1,
            "filename": "appconfigpy-2.0.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b065f505919ba0db1b341ad2eafc3142",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 8120,
            "upload_time": "2023-07-16T10:14:00",
            "upload_time_iso_8601": "2023-07-16T10:14:00.915661Z",
            "url": "https://files.pythonhosted.org/packages/79/58/18541de6b0a912b5cdeee21c88fb4c5a5013fa62568411a4b28e500d20ff/appconfigpy-2.0.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "51a05dbaf3c8b45b67350635d0e298913ea020efbd0474cdb13cbeb7aebfadb6",
                "md5": "c1589ab6d7711f3f0bf861ecd3ac55b4",
                "sha256": "82e459d20e0f89fad8330395960ba2b16e4ebb9d7cfb42f26a077d4a88b8d4a2"
            },
            "downloads": -1,
            "filename": "appconfigpy-2.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "c1589ab6d7711f3f0bf861ecd3ac55b4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 8629,
            "upload_time": "2023-07-16T10:14:03",
            "upload_time_iso_8601": "2023-07-16T10:14:03.050145Z",
            "url": "https://files.pythonhosted.org/packages/51/a0/5dbaf3c8b45b67350635d0e298913ea020efbd0474cdb13cbeb7aebfadb6/appconfigpy-2.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-16 10:14:03",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "thombashi",
    "github_project": "appconfigpy",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "appconfigpy"
}
        
Elapsed time: 0.10475s