Skip to main content

Loads configurations from different files with ease

Project description

c3a3‑config‑loader

Coverage Python

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

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"

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
  • Lint: ruff --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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

c3a3_config_loader-1.0.0.tar.gz (20.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

c3a3_config_loader-1.0.0-py3-none-any.whl (17.1 kB view details)

Uploaded Python 3

File details

Details for the file c3a3_config_loader-1.0.0.tar.gz.

File metadata

  • Download URL: c3a3_config_loader-1.0.0.tar.gz
  • Upload date:
  • Size: 20.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for c3a3_config_loader-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7914b4ccef722f2a50e6d014790ec4ec3816df8ab45337f8ad4e60be4b1358d9
MD5 366493abb3c2da87f73bac6c3ff2133e
BLAKE2b-256 c1cb754e5b925c79da8b3e2f8761fc9c6336d9490ecf2c6e80afd2e9e53c2991

See more details on using hashes here.

Provenance

The following attestation bundles were made for c3a3_config_loader-1.0.0.tar.gz:

Publisher: ci.yml on mrtu/c3a3-config_loader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file c3a3_config_loader-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for c3a3_config_loader-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d12004407a954c8b0e32821694971a2dcf1e3c82fe4d79862bf0e0ef7f460205
MD5 57dd9d3eb77e3f339254d612fee232b2
BLAKE2b-256 96d19523d05854354aaa3a140896f17cce9f67628ee317e2dd802883411b5155

See more details on using hashes here.

Provenance

The following attestation bundles were made for c3a3_config_loader-1.0.0-py3-none-any.whl:

Publisher: ci.yml on mrtu/c3a3-config_loader

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page