GithubHelp home page GithubHelp logo

configureme's Introduction

configureme

Build Status Code style: black codecov Total alerts Language grade: Python GitHub license

Set up configuration for your application or library with ease.

Features

configureme gives you a few key features that make your life easy when creating libraries or applications:

  • Easily create configuration following the config.py pattern
  • Use environment variables in your configuration and change them dynamically at runtime
  • Use a .env file and follow the twelve-factor app methodology

Example

Get up and running with full configuration quickly:

from configureme import Config

class Config(object):
    DEBUG = False

config = Config()
# load from a simple object
config.from_object(Config)
# add and watch environment variables
config.from_envar("DEBUG")
# use a dotenv file
config.from_dotenv("/path/to/.env/")
# config works like a dict!
config["DEBUG"] # True

Installation

Installation is easy using pip:

pip install configureme

Advanced Usage

Usage with pipenv

If your using a dev workflow tool like Pipenv, you can easily pair configureme with it. Pipenv will automatically load .env files for you out of the box. To track variables loaded from a .env file when using Pipenv, simply use this pattern:

# .env file
DEBUG=true
from configureme import Config
config = Config()
# watch each variable loaded by Pipenv
config.from_envar("DEBUG")
config["DEBUG"]  # True

Usage with python-dotenv

python-dotenv is a useful tool for managing .env files in multiple environments. As with the previous example, it's easy to pair with configureme.

# .env file
DEBUG=true
from dotenv import load_dotenv
from configureme import Config

load_dotenv()
config = Config()
# watch each variable loaded by python-dotenv
config.from_envar("DEBUG")
config["DEBUG"]  # True

How to contribute

  1. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug.

  2. Fork the repository on GitHub to start making your changes to the master branch (or branch off of it).

  3. Write a test which shows that the bug was fixed or that the feature works as expected. Make sure to use pre-commit too!

  4. Send a pull request and bug the maintainer until it gets merged and published. Make sure to add yourself to AUTHORS.

configureme's People

Contributors

bradleygolden avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar f1x3d avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

f1x3d

configureme's Issues

lgtm gives C code rating

Some investigation needs to be done to figure out how to bump the lgtm code rating from C to an A.

Rename still uses original env value when it shouldn't

Say "ENV_FOO=BAR" is set in the environment. config.from_envar("ENV_FOO", rename="FOO") should work like this when used throughout a project:

config["FOO"]  # returns "BAR"
config["ENV_FOOR"]  # raises KeyError

Right now however, both of these work:

config["FOO"]  # returns "BAR"
config["ENV_FOO"]  # returns "BAR"

This is a problem!

Added better contributing documentation

The contributing documentation is lacking in some areas. There should be steps that explicitly tell contributors to do at least the following:

  1. update CONTRIBUTING.md
  2. update versions.py if relevant
  3. update CHANGELOG.md

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.