Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/delgan/config-formatter
An automatic formatter for .ini and .cfg configuration files
https://github.com/delgan/config-formatter
cfg config configuration formatter ini python
Last synced: 26 days ago
JSON representation
An automatic formatter for .ini and .cfg configuration files
- Host: GitHub
- URL: https://github.com/delgan/config-formatter
- Owner: Delgan
- License: mit
- Created: 2022-06-24T11:51:20.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-27T17:38:31.000Z (about 1 year ago)
- Last Synced: 2024-12-30T01:42:00.515Z (about 1 month ago)
- Topics: cfg, config, configuration, formatter, ini, python
- Language: Python
- Homepage:
- Size: 28.3 KB
- Stars: 12
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
# config-formatter
[![Pypi version](https://img.shields.io/pypi/v/config-formatter.svg)](https://pypi.python.org/pypi/config-formatter) [![Python version](https://img.shields.io/badge/python-3.6%2B-blue.svg)](https://pypi.python.org/pypi/config-formatter) [![Build status](https://img.shields.io/github/actions/workflow/status/Delgan/config-formatter/tests.yml?branch=main)](https://github.com/Delgan/config-formatter/actions/workflows/tests.yml?query=branch:main) [![License](https://img.shields.io/github/license/delgan/config-formatter.svg)](https://github.com/Delgan/config-formatter/blob/main/LICENSE)
An automatic formatter for .ini and .cfg configuration files.
## Installation
```shell
pip install config-formatter
```## Usage
```python
from config_formatter import ConfigFormatterwith open("config.ini", "r") as file:
formatter = ConfigFormatter()
formatted = formatter.prettify(file.read())
print(formatted)
```## Example
Before:
```ini
[main] # Comments are preserved.# Error-prone indentation is removed.
[section1]
key1: value1
key2=value2 # Value assignment is normalized.[section2]
lists =
are
indented
# including
commentsmultiline = text that spans
on several lines
is properly aligned.
```After:
```ini
[main] # Comments are preserved.# Error-prone indentation is removed.
[section1]
key1 = value1
key2 = value2 # Value assignment is normalized.[section2]
lists =
are
indented
# including
commentsmultiline = text that spans
on several lines
is properly aligned.
```