Skip to main content

Basic configuration management for YB

Project description


This module is for managing configuration data for Python projects.

Web Configuration

This is for general web applications and basic Python programs. Importing the configuration object can be done with the following code:

from ybconfig import WebConfig

config_data = WebConfig()

The WebConfig class is a Singleton meaning that once the WebConfig class is initialized, it will not be initialized again throughout the rest of the program's lifetime. Every call to a WebConfig instance will point to the same memory address so the data will be consistent across all WebConfig instances.

Setting up environment

The WebConfig class can load from either a YML file or environment variables. If we are going to load from a YML file, we need to make sure that the path to the YML file is the last argument passed into the Python file like so:

python ./path/to/config.yml

If we want to not have a YML file but get our config variables from environment variables then the config file path is not needed. Instead, we need to state that the environment variable ENVIRONMENT_CONFIG to TRUE.

Getting variables

Getting variables from the config data is done using the get function with the following parameters:

param key: str the key that the variable is stored under

param file: bool if set to True will force to get data from a yml file despite defaults

param environ bool if set to True will force to get data from the environment variables despite defaults

param strict bool if set to True will throw an error if the key is not present

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

ybconfig-0.1.3.tar.gz (3.6 kB view hashes)

Uploaded source

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