From ff646e40b6223dac5ccc74ef869edc21081d6b89 Mon Sep 17 00:00:00 2001 From: Jakob Scheid Date: Mon, 2 Feb 2026 13:43:19 +0100 Subject: [PATCH] =?UTF-8?q?=09ge=C3=A4ndert:=20=20=20=20=20=20=20README.md?= =?UTF-8?q?=20=09ge=C3=A4ndert:=20=20=20=20=20=20=20config=5Fparser.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 37 ++++++++++++++++++++++++++++++++++++- config_parser.py | 2 +- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 256af98..aa79b47 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,38 @@ # config-parser -A library to parse configuration files. \ No newline at end of file +A library to parse configuration files. Currently it supports only INI format, but support for other formats is planned. + +## Installation +You can install the library using pip: + +```bash +pip install config-parser --index-url https://jcloud-services.ddns.net/simple/ +``` + +## Usage +Here's a simple example of how to use the `config-parser` library to read an INI configuration file: + +```python +from config_parser import parse_ini + +with open('config.conf', 'r') as file: + config_content = file.read() + +parsed = parse_ini(config_content) +print(parsed) +``` + +If the configuration file content is: +```ini +[section1] +key1=value1 +key2=value2 + +[section2] +hello=world + +[section3] +key=value +``` + +the result will be `{'section1': {'key1': 'value1', 'key2': 'value2'}, 'section2': {'hello': 'world'}, 'section3': {'key': 'value'}}` \ No newline at end of file diff --git a/config_parser.py b/config_parser.py index 18ea417..f87b28c 100644 --- a/config_parser.py +++ b/config_parser.py @@ -31,7 +31,7 @@ def compress_conf(conf): conf = conf.replace('\n\n', '\n') return conf.strip() -def parse_conf(conf): +def parse_ini(conf): conf = compress_conf(conf) result = {} current_group = {}