yaml_configuration
This module offers easy configuration for a other modules or startup scripts. It offers an easy way to load and save config files and read and write config values to it. Also trying to read a config value by passing an optional default value if the real config value is not present is supported.
Usage
The class DefaultConfig provides the basic functionality of the package. A custom configuration class is meant to derive from it.
import os
import logging
from pytest import raises
from yaml_configuration.config import DefaultConfig, ConfigError
def read_file(file_path, filename):
file_path = os.path.join(file_path, filename)
with open(file_path, 'r') as file_pointer:
file_content = file_pointer.read()
return file_content
class BasicConfig(DefaultConfig):
def __init__(self, config_string, config_file, logger_object=None):
super(BasicConfig, self).__init__(config_string, logger_object)
# this is already done in the init
# self.load(config_file, path=os.path.dirname(__file__))
if __name__ == '__main__':
config_file = "basic_config.yaml"
config_string = read_file(os.path.dirname(__file__), config_file)
basic_config = BasicConfig(config_string, config_file, logging.getLogger("TestLogger"))
basic_config.set_config_value("number_value", 10)
basic_config.set_config_value("string_value", "test_string")
assert basic_config.get_config_value("string_value") == "test_string"
assert basic_config.get_config_value("not_existing_config_value", default=42) == 42
with raises(ConfigError):
if not basic_config.get_config_value("value_that_should_exist"):
raise ConfigError("The config value with key 'value_that_should_exist' should exist")
Metadata
Release files for yaml-configuration 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| yaml_configuration-0.3.2.tar.gz | 6.8 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| yaml_configuration-0.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 13.9 kB
Release files / yaml_configuration-0.3.2.tar.gz
| Download URL | yaml_configuration-0.3.2.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
507377ecd6a7347557f3ae4caabcfa79a106d7b75e5acead11a91b2c0b878a9f
|
|
BLAKE2b-256 checksum How to use checksums |
4c7e101ab7c470b4c0255f679524f2fa83dd6162d0cef2a3be32f5c4bae724e5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.13
|
Release files / yaml_configuration-0.3.2-py3-none-any.whl
| Download URL | yaml_configuration-0.3.2-py3-none-any.whl |
|---|---|
| Size | 7.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0fc0c10a8b0b9535d2617ad8b2f30711f33c802baa6b38b5c125630d407164a3
|
|
BLAKE2b-256 checksum How to use checksums |
8f4ec0f575587c9f89d3bcb1cb64be352f0fd818531d21b225dd7ba3ab24d2ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.13
|
Security for yaml-configuration 0.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.