Metadata-Version: 2.4
Name: dictconf
Version: 0.1.0
Summary: A simple, file-composition-based configuration library.
Author-email: Philip Hierhager <philip.hierhager@googlemail.com>
License: MIT License
Project-URL: Homepage, https://github.com/user/dictconf
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: PyYAML>=6.0
Provides-Extra: dacite
Requires-Dist: dacite>=1.8.0; extra == "dacite"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: mypy>=1.5.0; extra == "dev"
Requires-Dist: build; extra == "dev"
Requires-Dist: twine; extra == "dev"

Of course. Here is a very simple, clean Markdown README that you can copy and paste directly.

-----

# dictconf

A simple, file-composition-based configuration library for Python, inspired by Hydra.

## Installation

Install the library using pip:

```bash
pip install dictconf
```

To include optional features like `dacite` support, install with the extra:

```bash
pip install "dictconf[dacite]"
```

For development, install all tools with:

```bash
pip install -e ".[dev]"
```

-----

## Quick Start

This library works by composing configuration from multiple YAML files.

### 1\. Create Your Config Files

Create a directory structure like this:

```
your_project/
├── conf/
│   ├── config.yaml
│   └── db/
│       ├── mysql.yaml
│       └── sqlite.yaml
└── main.py
```

**`conf/config.yaml`**

This is your main entry point. It defines the default components to use and can override any value.

```yaml
# Define the default components to load
defaults:
  - db: sqlite

# Define or override configuration values
server:
  host: 127.0.0.1
  port: 8080
  url: "http://${server.host}:${server.port}" # Variable interpolation
```

**`conf/db/sqlite.yaml`** (The default database)

```yaml
db:
  driver: sqlite
  path: /var/data/app.db
  timeout: 5000
```

**`conf/db/mysql.yaml`** (An alternative database)

```yaml
db:
  driver: mysql
  host: db.prod.local
  user: root
  password: "changeme"
```

### 2\. Load the Configuration in Python

**`main.py`**

```python
from config import load_config
import sys

# Load config from the 'conf' directory.
# CLI arguments are automatically used for overrides.
cfg = load_config("conf")

# Access values with dot notation
print(f"Database Driver: {cfg.db.driver}")
print(f"Server URL: {cfg.server.url}")

if cfg.db.driver == "mysql":
    print(f"Database User: {cfg.db.user}")
```

### 3\. Run Your Application

**Run with default settings:**

```bash
$ python main.py
Database Driver: sqlite
Server URL: http://127.0.0.1:8080
```

**Run with command-line overrides:**

You can swap components (`db=mysql`) and override specific values (`server.port=9000`).

```bash
$ python main.py db=mysql server.port=9000 db.user=admin
Database Driver: mysql
Server URL: http://127.0.0.1:9000
Database User: admin
```

-----

## Key Features

  * **YAML Composition**: Build your configuration from small, reusable files.
  * **CLI Overrides**: Easily swap components or change any value from the command line.
  * **Variable Interpolation**: Reference other config values using `${...}` syntax.
  * **Dot-Notation Access**: Access nested configuration values easily (e.g., `cfg.db.host`).
