Skip to main content

Yet Another Python Configuration

Project description

Yapconf

https://img.shields.io/pypi/v/yapconf.svg https://img.shields.io/travis/loganasherjones/yapconf.svg https://codecov.io/gh/loganasherjones/yapconf/branch/master/graph/badge.svg Documentation Status Updates

Yet Another Python Configuration. A simple way to manage configurations for python applications.

Yapconf allows you to easily manage your python application’s configuration. It handles everything involving your application’s configuration. Often times exposing your configuration in sensible ways can be difficult. You have to consider loading order, and lots of boilerplate code to update your configuration correctly. Now what about CLI support? Migrating old configs to the new config? Yapconf can help you.

Features

Yapconf helps manage your python application’s configuration

  • JSON/YAML config file support

  • Argparse integration

  • Environment Loading

  • Bootstrapping

  • Migrate old configurations to new configurations

Quick Start

To install Yapconf, run this command in your terminal:

$ pip install yapconf

Then you can use Yapconf yourself!

from yapconf import YapconfSpec

# First define a specification
my_spec = YapconfSpec({"foo": {"type": "str", "default": "bar"}}, env_prefix='MY_APP_')

# Then load the configuration in whatever order you want!
# load_config will automatically look for the 'foo' value in
# '/path/to/config.yml', then the environment, finally
# falling back to the default if it was not found elsewhere
config = my_spec.load_config('/path/to/config.yml', 'ENVIRONMENT')

print(config.foo)
print(config['foo'])

You can also add these arguments to the command line very easily

import argparse

parser = argparse.ArgumentParser()

# This will add --foo as an argument to your python program
my_spec.add_arguments(parser)

cli_args = vars(parser.parse_args(sys.argv[1:]))

# Now you can load these via load_config:
config = my_spec.load_config(cli_args, '/path/to/config.yml', 'ENVIRONMENT')

For more detailed information and better walkthroughs, checkout the documentation!

Documentation

Documentation is available at https://yapconf.readthedocs.io

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2018-02-01)

  • First release on PyPI.

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

yapconf-0.1.0.tar.gz (40.6 kB view details)

Uploaded Source

Built Distribution

yapconf-0.1.0-py2.py3-none-any.whl (18.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file yapconf-0.1.0.tar.gz.

File metadata

  • Download URL: yapconf-0.1.0.tar.gz
  • Upload date:
  • Size: 40.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for yapconf-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d8fc0c52f283d1422ab1407765bf70a5fd1455d94b57bff83ffe1ae0920b256f
MD5 ff4e330c3ea563ac178bb8123cd981b8
BLAKE2b-256 d48b0d8afcc04eee4dac6f78744d3ae59686b9a40c46fc7a1fa39bbc6427cb41

See more details on using hashes here.

File details

Details for the file yapconf-0.1.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for yapconf-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7dfba31b172a26c0c27393db517466910e88e8a2436c32a2f33fa8ffca6cb5ec
MD5 388248d7a7733e24a55a29dd96ead59b
BLAKE2b-256 48159b24a241d8d0acb5a7facbcbf9e59da08fe5c6d3542f1c631d1906fe5169

See more details on using hashes here.

Supported by

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