Skip to main content

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

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

Uploaded Source

File details

Details for the file ybconfig-0.1.3.tar.gz.

File metadata

  • Download URL: ybconfig-0.1.3.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.10

File hashes

Hashes for ybconfig-0.1.3.tar.gz
Algorithm Hash digest
SHA256 65bf88f120700affb2829128bc48a41e0a06c0f1f78006f8859e5d2619866290
MD5 0db35a8795dfdf3df3b0e0b5c03242a9
BLAKE2b-256 ac7b46a2c908897cdb3d283783e874d1428cac6cb35f51e35799d8bef5ade8b9

See more details on using hashes here.

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