Set up configuration for your application or library with ease.
pytailor 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
Get up and running with full configuration quickly:
from pytailor import Tailor
class Config(object):
DEBUG = False
config = Tailor()
# 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 is easy using pip:
pip install pytailor
If your using a dev workflow tool like Pipenv, you can easily pair pytailor 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 pytailor import Tailor
config = Tailor()
# watch each variable loaded by Pipenv
config.from_envar("DEBUG")
config["DEBUG"] # True
python-dotenv is a useful tool for managing .env files in multiple environments. As with the previous example, it's easy to pair with pytailor.
# .env file
DEBUG=true
from dotenv import load_dotenv
from pytailor import Tailor
load_dotenv()
config = Tailor()
# watch each variable loaded by python-dotenv
config.from_envar("DEBUG")
config["DEBUG"] # True
-
Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug.
-
Fork the repository on GitHub to start making your changes to the master branch (or branch off of it).
-
Write a test which shows that the bug was fixed or that the feature works as expected. Make sure to use pre-commit too!
-
Send a pull request and bug the maintainer until it gets merged and published. Make sure to add yourself to AUTHORS.