Skip to main content

A Python library to create/load an application configuration file.

Project description

Summary

A Python library to create/load an application configuration file.

PyPI package version Supported Python versions Supported Python implementations

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.5+

Optional Dependencies

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for appconfigpy, version 1.0.1
Filename, size File type Python version Upload date Hashes
Filename, size appconfigpy-1.0.1-py3-none-any.whl (7.9 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size appconfigpy-1.0.1.tar.gz (7.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page