A Python library for generating HTML views and diffs for configuration files.
Project description
pyconfviewer
pyconfviewer
is a Python library designed for viewing and comparing configuration files in various formats such as YAML, JSON, INI, and .env. It simplifies the management and review of configuration files by generating visual HTML reports.
Please let me know if you use the other configuration files as issues or pull requests. I will try to add support for them.
Features
- Supports loading configurations in multiple formats: YAML, JSON, INI, and .env
- Generates HTML reports for easy visualization of configurations
- Compares configurations between two directories, highlighting differences in HTML format
- Easily installable and runnable with simple command examples
Requirements
- Python 3.8 or higher(latest version is 3.13 as of now)
Installation
pyconfviewer
is available on PyPI. Install it with:
pip install pyconfviewer
Usage
After installation, use pyconfviewer
in your own scripts to generate configuration reports or compare configuration files.
Please see the example/run_generator.py script below for a demonstration.
1. Generate an HTML report of configuration files
The following example script, rungenerator.py
, reads configuration files from a specified directory and generates an HTML report at config_report.html
.
import os
from pyconfviewer.config_generator import ConfigGenerator
# Define the configuration directory
config_dir = "path/to/config_a"
output_dir = "output"
config_html = os.path.join(output_dir, "config_report.html")
# Create an instance of ConfigGenerator and generate the HTML report
config_generator = ConfigGenerator()
configs = config_generator.load_configs(config_dir)
config_generator.generate_config_html(configs, output_dir=output_dir, output_html_path=config_html)
print(f"Configuration HTML generated at {config_html}")
Example output:
2. Generate an HTML diff report comparing two configuration directories
Compare configuration files in two directories and generate an HTML report at diff_report.html
.
from pyconfviewer.diff_generator import DiffGenerator
# Define the configuration directories to compare
config_a_dir = "path/to/config_a"
config_b_dir = "path/to/config_b"
diff_html = os.path.join(output_dir, "diff_report.html")
# Create an instance of DiffGenerator and generate the HTML diff report
diff_generator = DiffGenerator()
configs_a = config_generator.load_configs(config_a_dir)
configs_b = config_generator.load_configs(config_b_dir)
diffs = diff_generator.generate_diff(configs_a, configs_b)
diff_generator.generate_diff_html(diffs, output_dir=output_dir, output_html_path=diff_html)
print(f"Diff HTML generated at {diff_html}")
Example output:
Contributing
pyconfviewer
is an open-source project, and contributions are welcome!
If you have ideas for improvements or would like to fix bugs, please feel free to submit a pull request.
For more details, see CONTRIBUTION.md.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pyconfviewer-0.1.1.tar.gz
.
File metadata
- Download URL: pyconfviewer-0.1.1.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88f7734b4d4f7e694b0362c96f67255f2b6604581f853aa36de968fd5335c87f |
|
MD5 | 315e51b1c7a2755d638b8c95c593e9f2 |
|
BLAKE2b-256 | 494e89c0db8ec404eba7478734300ebfaa5d4da3e81255de4dd6e79947ff70c1 |
Provenance
File details
Details for the file pyconfviewer-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: pyconfviewer-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.8.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 50a96f6009043ecb76930bd9eb3f105057ce4342c3943cbde7fe171816703b4d |
|
MD5 | c0310abb29f61d8cb1ca1737d49d0357 |
|
BLAKE2b-256 | 18fe03fbf750328eee0147f27bdba687c52576c33ce3d73cf03ca849336820ce |