Skip to main content

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

Metadata

Release files for ybconfig 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ybconfig 0.1.3
File Size Uploaded
ybconfig-0.1.3.tar.gz 3.6 kB Details

Release files / ybconfig-0.1.3.tar.gz

Download URL ybconfig-0.1.3.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
65bf88f120700affb2829128bc48a41e0a06c0f1f78006f8859e5d2619866290
BLAKE2b-256 checksum
How to use checksums
ac7b46a2c908897cdb3d283783e874d1428cac6cb35f51e35799d8bef5ade8b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.8.10

Release history Release notifications | RSS feed

This release

0.1.3 This release

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page