Loads configurations from different files with ease
Project description
c3a3‑config‑loader
Seamless, pluggable configuration for modern Python apps — merge CLI/ENV/RC, validate & decrypt secrets in one line.
Why?
Reading configuration shouldn’t require boilerplate. c3a3‑config‑loader lets you declare a tiny TOML‑like spec and automatically:
- Parse command‑line arguments (
--db.password) with positional support. - Pull values from environment variables (
C3A3_DB_PASSWORD). - Fall back to a per‑user rc‑file (
~/.c3a3rc) in TOML or INI. - Respect a deterministic precedence order you choose.
- Validate types, required flags, allowed values & numeric ranges.
- Obfuscate or reveal sensitive values using AES‑256.
- Extend via plugins (e.g.
vault://secret) with size/charset constraints.
All in a 100% type‑annotated, 80%+ test‑covered library.
Installation
pip install c3a3-config-loader
Requires Python≥3.9. Binary wheels ship with [cryptography] so no external libs.
Quick start
Automatic Configuration Loading (New!)
The easiest way to get started is with automatic configuration loading:
from config_loader.main import load_config_auto
# Automatically loads script_name.json or script_name.yaml
cfg = load_config_auto()
result = cfg.process() # auto‑reads sys.argv, os.environ, ~/.c3a3rc
print(result.db.password) # ➔ "obfuscated:..."
print(cfg.reveal(result.db.password)) # ➔ "my‑secret"
print(result.mode) # ➔ "prod"
Create a configuration file named after your script (e.g., myapp.json for myapp.py):
{
"schema_version": "1.0",
"app_name": "myapp",
"precedence": ["args", "env", "rc"],
"parameters": [
{"namespace": "db", "name": "password", "type": "string", "required": true, "obfuscated": true},
{"namespace": null, "name": "mode", "type": "string", "default": "prod", "accepts": ["dev", "prod"]},
{"namespace": "app", "name": "timeout", "type": "number", "min": 1, "max": 60, "default": 30}
]
}
Manual Configuration (Traditional)
from config_loader.main import Configuration
spec = {
"app_name": "c3a3", # affects env‑var prefix & rc file name
"precedence": ["args", "env", "rc"], # CLI wins, env next, then rc
"parameters": [
{"namespace": "db", "name": "password", "type": "string", "required": True, "obfuscated": True},
{"namespace": None, "name": "mode", "type": "string", "default": "prod", "accepts": ["dev", "prod"]},
{"namespace": "app", "name": "timeout", "type": "number", "min": 1, "max": 60, "default": 30},
],
}
cfg = Configuration(spec)
result = cfg.process() # auto‑reads sys.argv, os.environ, ~/.c3a3rc
print(result.db.password) # ➔ "obfuscated:..."
print(cfg.reveal(result.db.password)) # ➔ "my‑secret"
print(result.mode) # ➔ "prod"
Command‑line invocation
python app.py --db.password my‑secret --mode dev
Environment variables
export C3A3_DB_PASSWORD=my‑secret
RC file (~/.c3a3rc)
[default]
mode = "dev"
New Features
YAML Support
Configuration files can now be written in YAML format alongside JSON:
schema_version: "1.0"
app_name: myapp
precedence:
- args
- env
- rc
parameters:
- namespace: db
name: password
type: string
required: true
obfuscated: true
- namespace: null
name: mode
type: string
default: prod
accepts:
- dev
- prod
The system automatically detects and loads .json, .yaml, or .yml files.
Schema Validation
All configuration files must now include a schema_version field and conform to the defined JSON schema. This ensures:
- Structure validation: Required fields, correct data types, valid enum values
- Version compatibility: Forward/backward compatibility handling
- Error reporting: Clear validation error messages
Supported schema versions: 1.0, 1.0.0
Plugins
Implement ConfigPlugin to fetch protocol values from anywhere:
from config_loader.plugin_interface import ConfigPlugin, PluginManifest
class VaultPlugin(ConfigPlugin):
@property
def manifest(self):
return PluginManifest(protocol="vault", type="string")
def load_value(self, protocol_value: str):
# e.g. call HashiCorp Vault
return vault_client.read(protocol_value)
Register at Configuration(..., plugins=[VaultPlugin()]) and list protocol:"vault" in a parameter.
Coverage & quality
- Tests: 40+pytest cases, 80% overall coverage
- Type‑checking:
mypy --strict -p config_loader - Lint:
ruff check --fix
Development
git clone https://github.com/your‑org/c3a3‑config_loader.git
cd c3a3‑config_loader
python -m pip install -e .[dev]
pytest -q # run test suite
Pull requests welcome — please include tests and pass CI.
License
SPDX-License-Identifier: Prosperity-3.0.0 © 2025 ã — see LICENSE.md for terms.
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 c3a3_config_loader-1.1.0.tar.gz.
File metadata
- Download URL: c3a3_config_loader-1.1.0.tar.gz
- Upload date:
- Size: 23.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de4463404c9d9f23f0073b9ae8957ff430f44aa2553b5bb4022231baeb224b03
|
|
| MD5 |
01dd39d92c1e452fd57eb02a2762d56d
|
|
| BLAKE2b-256 |
ae5907ff72cda6f02a38eaae5e1df94eb9cd65968596ace886973dce3422c5c1
|
Provenance
The following attestation bundles were made for c3a3_config_loader-1.1.0.tar.gz:
Publisher:
ci.yml on mrtu/c3a3-config_loader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
c3a3_config_loader-1.1.0.tar.gz -
Subject digest:
de4463404c9d9f23f0073b9ae8957ff430f44aa2553b5bb4022231baeb224b03 - Sigstore transparency entry: 368094216
- Sigstore integration time:
-
Permalink:
mrtu/c3a3-config_loader@b5c97d595ced25a1c4587116d7e3a16f9eae7d68 -
Branch / Tag:
refs/tags/1.1.0 - Owner: https://github.com/mrtu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@b5c97d595ced25a1c4587116d7e3a16f9eae7d68 -
Trigger Event:
release
-
Statement type:
File details
Details for the file c3a3_config_loader-1.1.0-py3-none-any.whl.
File metadata
- Download URL: c3a3_config_loader-1.1.0-py3-none-any.whl
- Upload date:
- Size: 20.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0ae5836667c97805424017c367b2848783bbf6d9d6fbc92abda611a56084e245
|
|
| MD5 |
2a0feaa553cfb1905f7a466fe5594b07
|
|
| BLAKE2b-256 |
39bea6b45be95d7e605ab7fb2266fe6eec0df00392706d300e876b137ee66b85
|
Provenance
The following attestation bundles were made for c3a3_config_loader-1.1.0-py3-none-any.whl:
Publisher:
ci.yml on mrtu/c3a3-config_loader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
c3a3_config_loader-1.1.0-py3-none-any.whl -
Subject digest:
0ae5836667c97805424017c367b2848783bbf6d9d6fbc92abda611a56084e245 - Sigstore transparency entry: 368094239
- Sigstore integration time:
-
Permalink:
mrtu/c3a3-config_loader@b5c97d595ced25a1c4587116d7e3a16f9eae7d68 -
Branch / Tag:
refs/tags/1.1.0 - Owner: https://github.com/mrtu
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@b5c97d595ced25a1c4587116d7e3a16f9eae7d68 -
Trigger Event:
release
-
Statement type: