Basic configuration management for YB
Project description
yb_config
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 some_file.py ./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
File details
Details for the file ybconfig-0.1.2.tar.gz
.
File metadata
- Download URL: ybconfig-0.1.2.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e6c4be8f37a98e71d76dd2bc0a8eecd9c49f3d38f3e4072a5173e134b523cf3 |
|
MD5 | cbc1d05f4685c59f7159836780a0fc88 |
|
BLAKE2b-256 | dfee7d79aa3c0ec7db2df1e2a9c5ef81c7a55d385ad4ee3ad68c2f7cbd608cbc |