Metadata-Version: 2.4
Name: dd-config
Version: 0.1.0
Summary: Unified configuration management for the dd-* ecosystem
Project-URL: Homepage, https://github.com/digital-duck/dd-config
Project-URL: Repository, https://github.com/digital-duck/dd-config
Author-email: Digital Duck <p2p2learn@outlook.com>
License: MIT License
        
        Copyright (c) 2026 digital-duck
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Keywords: config,configuration,env,ini,json,toml,yaml
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.9
Requires-Dist: pydantic>=2.0.0
Provides-Extra: all
Requires-Dist: pyyaml>=6.0; extra == 'all'
Requires-Dist: tomli>=2.0; (python_version < '3.11') and extra == 'all'
Provides-Extra: dev
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Requires-Dist: pyyaml>=6.0; extra == 'dev'
Requires-Dist: tomli-w>=1.0; extra == 'dev'
Requires-Dist: tomli>=2.0; (python_version < '3.11') and extra == 'dev'
Provides-Extra: toml
Requires-Dist: tomli>=2.0; (python_version < '3.11') and extra == 'toml'
Provides-Extra: yaml
Requires-Dist: pyyaml>=6.0; extra == 'yaml'
Description-Content-Type: text/markdown

# dd-config

Unified configuration management for the `dd-*` ecosystem — load, merge, validate and
convert config files across multiple formats with a single clean API.

## Install

```bash
pip install dd-config                    # JSON + INI + .env support (stdlib only)
pip install "dd-config[yaml]"            # + YAML support
pip install "dd-config[all]"             # all formats including TOML
```

## Quick start

```python
from dd_config import Config

# Load a YAML config
cfg = Config.load("splflow.yaml")

# Plain key access
adapter = cfg["llm_adapter"]            # "ollama"

# Dot-path access for nested keys
host = cfg["database.host"]

# Safe get with default
port = cfg.get("database.port", 5432)

# Layer overrides on top (later files win)
cfg = Config.load("base.yaml", overrides=["local.yaml", ".env"])
```

## Supported formats

| Format | Extension | Extra required |
|--------|-----------|----------------|
| JSON   | `.json`   | none (stdlib)  |
| YAML   | `.yaml`, `.yml` | `pip install "dd-config[yaml]"` |
| TOML   | `.toml`   | `pip install "dd-config[all]"` |
| INI    | `.ini`, `.cfg` | none (stdlib) |
| Env    | `.env`    | none (stdlib)  |

## Features

- **Multi-format** — one API for JSON, YAML, TOML, INI, `.env`
- **Auto-detection** — format inferred from file extension
- **Layered loading** — base config + multiple override files; last writer wins
- **Dot-path access** — `cfg["server.port"]` instead of `cfg["server"]["port"]`
- **Env interpolation** — `${VAR:-default}` tokens expanded on load
- **Format conversion** — `Config.convert("app.yaml", "app.json")`
- **Validation** — required-key and type checks raise `ValidationError`
- **Plain dict** — `cfg.to_dict()` returns a plain Python dict; no magic objects
- **Lazy deps** — YAML/TOML libraries only imported when actually used

## Validation

```python
cfg.validate(required=["llm_adapter", "database.host"])
cfg.validate(schema={"database.port": int, "debug": bool})
```

## Saving & converting

```python
cfg["llm_adapter"] = "openrouter"
cfg.save("splflow.yaml")               # write back to YAML
Config.convert("splflow.yaml", "splflow.json")   # one-liner format conversion
```

## Environment variable interpolation

Values like `${OPENROUTER_API_KEY:-}` in config files are expanded from the
environment at load time. Useful for secrets that must not be committed to VCS:

```yaml
openrouter:
  api_key: ${OPENROUTER_API_KEY}
  base_url: https://openrouter.ai/api/v1
```

## Merge

```python
base = Config.load("base.yaml")
local = Config.load("local.yaml")
merged = base.merge(local)             # local wins on conflict; non-destructive
```

## License

MIT © 2026 digital-duck
