Skip to main content

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

Project description

appconfigpy

https://badge.fury.io/py/appconfigpy.svg https://img.shields.io/pypi/pyversions/appconfigpy.svg https://coveralls.io/repos/github/thombashi/appconfigpy/badge.svg?branch=master

Summary

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

Installation

pip install appconfigpy

Usage

Create A Configuration File

# configure.py

import appconfigpy

CONFIG_NAME = "example"
CONFIG_ITEM_LIST = [
    appconfigpy.ConfigItem(
        name="token",
        initial_value=None,
        prompt_text="API Token",
        default_display_style=appconfigpy.DefaultDisplayStyle.PART_VISIBLE
    ),
    appconfigpy.ConfigItem(
        name="path",
        prompt_text="Path",
        initial_value=".",
    ),
]

if __name__ == "__main__":
    app_config_manager = appconfigpy.ConfigManager(
        config_name=CONFIG_NAME, config_item_list=CONFIG_ITEM_LIST)

    app_config_manager.configure()
$ ./configure.py
API Token: abcdefghijklmn
Path [.]:
$ cat ~/.example
{
    "path": ".",
    "token": "abcdefghijklmn"
}

Load A Configuration File

# load.py

import appconfigpy

CONFIG_NAME = "example"
CONFIG_ITEM_LIST = [
    appconfigpy.ConfigItem(
        name="token",
        initial_value=None,
        prompt_text="API Token",
        default_display_style=appconfigpy.DefaultDisplayStyle.PART_VISIBLE
    ),
    appconfigpy.ConfigItem(
        name="path",
        prompt_text="Path",
        initial_value=".",
    ),
]

if __name__ == "__main__":
    app_config_manager = appconfigpy.ConfigManager(
        config_name=CONFIG_NAME, config_item_list=CONFIG_ITEM_LIST)

    print(app_config_manager.load())
$ ./load.py
{'token': 'abcdefghijklmn', 'path': '.'}

Dependencies

Python 2.7+ or 3.3+

Project details


Download files

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

Source Distribution

appconfigpy-0.0.1.tar.gz (5.1 kB view hashes)

Uploaded Source

Built Distribution

appconfigpy-0.0.1-py2.py3-none-any.whl (7.4 kB view hashes)

Uploaded Python 2 Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page