https://github.com/sc4rfurry/load_xl
load_xl is a versatile Python library for parsing various configuration file formats, including .env, .ini, .yaml, .json, .toml, and .xml.
https://github.com/sc4rfurry/load_xl
config-parser env parser python3
Last synced: 6 months ago
JSON representation
load_xl is a versatile Python library for parsing various configuration file formats, including .env, .ini, .yaml, .json, .toml, and .xml.
- Host: GitHub
- URL: https://github.com/sc4rfurry/load_xl
- Owner: sc4rfurry
- License: mit
- Created: 2023-02-06T16:17:39.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-09-14T18:46:30.000Z (almost 2 years ago)
- Last Synced: 2024-11-29T11:55:13.669Z (over 1 year ago)
- Topics: config-parser, env, parser, python3
- Language: Python
- Homepage: https://sc4rfurry.github.io/get_load_xl
- Size: 21.5 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
```
_ _ _
| | ___ __ _ __| | __ _| |
| | / _ \ / _` |/ _` | \ \/ / |
| |__| (_) | (_| | (_| | > <| |
|_____\___/ \__,_|\__,_| /_/\_\_|
Configuration Parser Extraordinaire
```
# load_xl
[](https://badge.fury.io/py/load-xl)
[](https://opensource.org/licenses/MIT)
[](https://pypi.org/project/load-xl/)
`load_xl` is a versatile Python library for parsing various configuration file formats, including `.env`, `.ini`, `.yaml`, `.json`, `.toml`, and `.xml`. It provides a unified interface for loading and validating configuration data, making it easy to work with different file formats in your projects.
## ✨ Features
```
┌─────────────────────────────────────────────┐
│ ⚙️ Multiple configuration file formats │
│ 🔄 Automatic environment variable substition │
│ 🛡️ JSON Schema validation │
│ 🔍 File watching for auto config reloading │
│ 🖥️ Command-line interface (CLI) │
│ 🐍 Compatible with Python 3.6+ │
└─────────────────────────────────────────────┘
```
## 🚀 Installation
Install `load_xl` using pip:
```bash
pip install load-xl
```
## 💻 Usage
### As a Library
```python
from load_xl import load_config
# Load a configuration file
config = load_config('path/to/your/config.yaml')
# Load with schema validation
schema = {...} # Your JSON schema
config = load_config('path/to/your/config.json', schema=schema)
# Access configuration data
print(config['some_key'])
```
### Command-line Interface
```bash
load_xl path/to/your/config.yaml --output
load_xl path/to/your/config.json --validate --schema path/to/schema.json
```
## 📁 Supported File Formats
```
┌─────┬───────────────────────────────┐
│.env │ Environment variables │
│.ini │ INI configuration files │
│.yaml│ YAML configuration files │
│.json│ JSON configuration files │
│.toml│ TOML configuration files │
│.xml │ XML configuration files │
└─────┴───────────────────────────────┘
```
## 🔬 Testing
The `load_xl` library includes a comprehensive test suite. You can find the test script in the `test` directory. Here's a snippet of the `test.py` file:
```python
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from load_xl import load_config, FileParsingError
# Test .env file parsing and loading
try:
print("\n[+] Loading .env file...")
env_config = load_config(".env")
print(env_config.get("TEST"))
print(env_config.get("TEST_ENV"))
except FileParsingError as e:
print(f"Error in parsing .env file: {e}")
# ... (tests for other file formats)
# Test .xml file parsing and returning as dict
try:
print("\n[+] Loading .xml file...")
xml_config = load_config("test.xml")
print(xml_config)
except FileParsingError as e:
print(f"Error in parsing .xml file: {e}")
```
To run the tests, navigate to the `test` directory and execute:
```bash
python test.py
```
## 🔧 Advanced Features
### Environment Variable Substitution
`load_xl` automatically replaces `${VAR}` patterns in your configuration files with the corresponding environment variable values.
### File Watching
```python
from load_xl import ConfigFileWatcher, YamlFileParser
watcher = ConfigFileWatcher('config.yaml', YamlFileParser)
watcher.start()
# Your application logic here
watcher.stop()
```
##
> **Note:** There are example schema files provided in **schemas** folder.
##
## 🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## 📜 License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## 👨💻 Author
- **sc4rfurry** - [GitHub](https://github.com/sc4rfurry)
## 🙏 Acknowledgments
- Thanks to all contributors and users of `load_xl`
- Inspired by the need for a unified configuration parsing solution
- This project was developed with some assistance from **ChatGPT 4.0** , showcasing the potential of AI-assisted coding and for my peronal experience too
---
For more information and updates, please visit the [GitHub repository](https://github.com/sc4rfurry/load_xl).
```
______________________________
< Thank you for using load_xl! >
------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
```