Metadata-Version: 2.4
Name: org.slashlib.py.configloader
Version: 0.1.0
Summary: json-based configuration manager with placeholder resolution, environment variable injection, and dynamic DLL path loading
Author-email: Dirk Brenckmann <db.developer@gmx.de>
License-Expression: MIT
Project-URL: Homepage, https://github.com/org-slashlib/org.slashlib.py.configloader
Keywords: config,environment,json,placeholders,dll,path
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: colorlog>=6.0.0
Dynamic: license-file

[Bottom](#requirements) [AI](AI.md) [CHANGELOG](CHANGELOG.md) [LICENSE](LICENSE.md)

[![PyPI version](https://img.shields.io/pypi/v/org.slashlib.py.configloader.svg)](https://pypi.org/project/org.slashlib.py.agent/)[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
# org.slashlib.py.configloader

A lightweight, JSON-based configuration manager for Python projects. It automatically locates your project root, resolves nested placeholders, injects environment variables, and manages system paths.

---
## Features

- **Root Discovery**: Automatically finds the project root based on a marker file (default: `pyproject.json`).
- **Placeholder Resolution**: Supports recursive interpolation of settings using the `{path.to.key}` syntax.
- **Environment Injection**: Automatically sets environment variables defined in the configuration.
- **Path Management**: Dynamically updates the system `PATH` and registers DLL directories (Windows).
- **Asset Helper**: Built-in utility to read mandatory file assets defined in your config.
- [[docs|Developer Documentation]]

---
## Installation

Install the package (maybe in editable mode: -e) within your project directory.
This will automatically resolve and install the required dependencies:

```bash
pip install .
```

---
## Configuration Example (pyproject.json)

```json
{
  "env": {
    "path": [
      "./bin",
      "./tools/external"
    ],
    "dllpath": [
      "./libs/native"
    ],
    "vars": {
      "DATABASE_URL": "postgres://user:pass@localhost/db",
      "LOG_LEVEL": "DEBUG"
    }
  },
  "paths": {
    "data_dir": "{ROOT}/data",
    "raw_files": "{paths.data_dir}/raw"
  },
  "assets": {
    "schema": "./assets/schema.sql"
  }
}
```

---
## Usage

The `ConfigLoader` follows a "setup-and-forget" philosophy. Upon import, the library automatically creates a singleton instance that handles root discovery, placeholder resolution, and environment injection.
```python
import logging
import org.slashlib.py.configloader

# 1. Automatic Initialization
# The 'configloader' is already initialized and has processed your 'pyproject.json'.
# Environment variables and PATH/DLL paths are already updated.

# 2. Optional: Setup Logging
# Uses the 'assets.logging' path from your JSON to initialize colorlog/logging.
# Defaults to "assets.logging" if no path is provided.
org.slashlib.py.configloader.setup_logging()

# 3. Access the processed configuration
# Placeholders like {ROOT} or {paths.data_dir} can be resolved.
data_dir = org.slashlib.py.configloader.config['paths']['data_dir']

# 4. Use the Resolve Helper (Recommended)
# Safely access nested nodes with dot-notation and optional default values.
db_port = org.slashlib.py.configloader.resolve("env.vars.DATABASE_PORT", default=5432)

# 5. Use the Asset Helper
# Conveniently read file contents using keys defined in your 'assets' section.
schema_content = org.slashlib.py.configloader.read_asset("schema")

# 6. Native Integration
# Environment variables are already accessible via the standard 'os' module.
import os
print(f"Database URL: {os.environ.get('DATABASE_URL')}")

# 7. Logging is ready to use
logger = logging.getLogger(__name__)
logger.info("Application started successfully.")
```

---
## Requirements

- **Python 3.8+**
- **Dependencies**: 
  - `colorlog`: Used for optional colored console output in `setup_logging()`.

---
## Documentation & Obsidian

The project root is pre-configured as an **Obsidian Vault**. If you open this folder directly in Obsidian, all settings and documentation links will be available immediately via the included `.obsidian` directory.

The following community plugins are pre-configured in the vault to enhance the documentation experience:

* **[File Include](https://github.com/tillahoffmann/obsidian-file-include)**: Embed code files directly into your markdown documentation.
* **[Folder Notes](https://github.com/LostPaul/obsidian-folder-notes)**: Add descriptions at the folder level.
* **[Front Matter Title](https://github.com/snezhig/obsidian-front-matter-title)**: Use metadata for descriptive file titles.
* **[Hide Folders](https://github.com/JonasDoesThings/obsidian-hide-folders)**: Keeps the structure clean by hiding internal directories.
* **[Iconic](https://github.com/gfxholo/iconic)** & **[Icons](https://github.com/visini/obsidian-icons-plugin)**: Improved visual navigation.

[More docs](docs/docs.md)

---
## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE.md) file for details.

---
© 2026 org.slashlib

[TOP](#org-slashlib-py-configloader) [AI](AI.md) [CHANGELOG](CHANGELOG.md) [LICENSE](LICENSE.md)
