This general purpose configuration utility library allows your code to use YAML as a configuration language for internal and external parties, allowing configuration to be crafted from multiple sources and merged just before use, using YAML Tags for additional functionality.
Project description
granular-configuration-language – A General Purpose Configuration Utility Library
⚠️ This library is meant for trusted configuration files. ⚠️
How to get started?
See Documentation - Getting Started.
How to install?
From PyPI:
pip install granular-configuration-language
Why does this exist?
This library exists to allow your code to use YAML as a configuration language for internal and external parties, allowing configuration to be crafted from multiple sources and merged just before use, using YAML Tags for additional functionality, and plugin support for creating custom YAML Tags.
Some use cases:
- You are writing a library to help connect to some databases. You want users to easily changes settings and defined databases by name.
- Conceptual Example:
- Library Code:
# database_util/config/config.py CONFIG = LazyLoadConfiguration( Path(__file___).parent / "config.yaml", "./database-util-config.yaml", "~/configs/database-util-config.yaml", base_path="database-util", env_location_var_name="ORG_COMMON_CONFIG_LOCATIONS", )
- Library configuration:
# database_util/config/config.yaml database-util: common_settings: use_decimal: true encryption_type: secure databases: {} # Empty mapping, for users define
- User application configuration:
# ~/configs/database-util-config.yaml database-util: common_settings: use_decimal: false databases: datebase1: location: http://somewhere user: !Mask ${DB_USERNAME} password: !Mask ${DB_PASSWORD}
- Library Code with type annotations:
class CommonSettings(Configuration): use_decimal: bool encryption_type: str # class DatabaseSettings: location: str user: str password: str # class Settings(Configuration): common_settings: CommonSettings databases: Configuration[str, DatabaseSettings] # CONFIG = LazyLoadConfiguration( Path(__file___).parent / "config.yaml", "./database-util-config.yaml", "~/configs/database-util-config.yaml", base_path="database-util", env_location_var_name="ORG_COMMON_CONFIG_LOCATIONS", ).as_typed(Settings)
- Library Code:
- Conceptual Example:
- You are deploying an application that has multiple deployment types with specific settings.
- Conceptual Example:
- Library Code:
# app/config/config.py CONFIG = LazyLoadConfiguration( Path(__file___).parent / "config.yaml", "./database-util-config.yaml", base_path="app", )
- Base configuration:
# app/config/config.yaml app: log_as: really cool app name log_to: nowhere
- AWS Lambda deploy:
# ./database-util-config.yaml app: log_to: std_out
- Server deploy:
# ./database-util-config.yaml app: log_to: !Sub file://var/log/${$.app.log_as}.log
- Library Code:
- Conceptual Example:
- You are writing a
pytestplugin that creates test data using named fixtures configured by the user.- Conceptual Examples:
- Library Code:
# fixture_gen/config/config.py CONFIG = LazyLoadConfiguration( Path(__file___).parent / "fixture_config.yaml", *Path().rglob("fixture_config.yaml"), base_path="fixture-gen", ).config # for name, spec in CONFIG.fixtures: generate_fixture(name, spec)
- Library configuration:
# fixture_gen/config/fixture_config.yaml fixture-gen: fixtures: {} # Empty mapping, for users define
- User application configuration:
# fixture_config.yaml fixture-gen: fixtures: fixture1: api: does something
- Library Code:
- Conceptual Examples:
Why the long name?
- It's "granular" because you can specify settings across multiple files at a fine granularity for overriding values.
- It is meant for trusted "configuration" files.
- Including "language" makes it clear that this is not the source of configuration, but a library for processing generic configuration files.
- Feedback was that "granular-configuration" sounded like it was the source for configuration.
- "Format" sounded weirder than "language".
- Including "YAML" sounded like this was trying to be more than YAML, rather than just using YAML.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file granular_configuration_language-2.4.3.tar.gz.
File metadata
- Download URL: granular_configuration_language-2.4.3.tar.gz
- Upload date:
- Size: 41.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5b766347a01e6496bb11c5e78e3a14d46163ee902f29cf3d0f519d42d128487
|
|
| MD5 |
323a62f8fc72aa276469463c73c0fb1e
|
|
| BLAKE2b-256 |
7d045393eb9ea6d98aa29436513f5527da402e4ed1487ce0711ce64947362683
|
Provenance
The following attestation bundles were made for granular_configuration_language-2.4.3.tar.gz:
Publisher:
release.yaml on lifedox/granular-configuration-language
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
granular_configuration_language-2.4.3.tar.gz -
Subject digest:
f5b766347a01e6496bb11c5e78e3a14d46163ee902f29cf3d0f519d42d128487 - Sigstore transparency entry: 1240555294
- Sigstore integration time:
-
Permalink:
lifedox/granular-configuration-language@ccf8620c5995e40d828ce52cac9d2990c4660f68 -
Branch / Tag:
refs/tags/v2.4.3 - Owner: https://github.com/lifedox
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@ccf8620c5995e40d828ce52cac9d2990c4660f68 -
Trigger Event:
release
-
Statement type:
File details
Details for the file granular_configuration_language-2.4.3-py3-none-any.whl.
File metadata
- Download URL: granular_configuration_language-2.4.3-py3-none-any.whl
- Upload date:
- Size: 70.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38c082f2f41ce1f1e4ebf3761599c64db35ad12a7965d6c29c3e76f983201e7f
|
|
| MD5 |
a9e48aee837124269833728c0e7be5bf
|
|
| BLAKE2b-256 |
b25600cb622233db6ddc819c638997b8697ad8692719c1ba1fcb7ea34ce99e8c
|
Provenance
The following attestation bundles were made for granular_configuration_language-2.4.3-py3-none-any.whl:
Publisher:
release.yaml on lifedox/granular-configuration-language
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
granular_configuration_language-2.4.3-py3-none-any.whl -
Subject digest:
38c082f2f41ce1f1e4ebf3761599c64db35ad12a7965d6c29c3e76f983201e7f - Sigstore transparency entry: 1240555331
- Sigstore integration time:
-
Permalink:
lifedox/granular-configuration-language@ccf8620c5995e40d828ce52cac9d2990c4660f68 -
Branch / Tag:
refs/tags/v2.4.3 - Owner: https://github.com/lifedox
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yaml@ccf8620c5995e40d828ce52cac9d2990c4660f68 -
Trigger Event:
release
-
Statement type: