{"id":26105796,"url":"https://github.com/preocts/commented-configparser","last_synced_at":"2025-04-12T19:21:50.588Z","repository":{"id":104431452,"uuid":"560575864","full_name":"Preocts/commented-configparser","owner":"Preocts","description":"Custom ConfigParser class that preserves comments in file when writing","archived":false,"fork":false,"pushed_at":"2025-03-04T02:42:27.000Z","size":128,"stargazers_count":6,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-03T19:16:18.263Z","etag":null,"topics":["configparser","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Preocts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-01T19:53:11.000Z","updated_at":"2025-03-04T02:42:30.000Z","dependencies_parsed_at":"2024-04-09T03:31:06.986Z","dependency_job_id":"fe89f782-304c-4d35-89c7-a0ead7ee7d78","html_url":"https://github.com/Preocts/commented-configparser","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Preocts%2Fcommented-configparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Preocts%2Fcommented-configparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Preocts%2Fcommented-configparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Preocts%2Fcommented-configparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Preocts","download_url":"https://codeload.github.com/Preocts/commented-configparser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248618714,"owners_count":21134285,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configparser","python3"],"created_at":"2025-03-09T21:54:04.709Z","updated_at":"2025-04-12T19:21:50.545Z","avatar_url":"https://github.com/Preocts.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Python 3.8 | 3.9 | 3.10 | 3.11 | 3.12 | 3.13](https://img.shields.io/badge/Python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)](https://www.python.org/downloads)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\u0026logoColor=white)](https://github.com/pre-commit/pre-commit)\n\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/Preocts/commented-configparser/main.svg)](https://results.pre-commit.ci/latest/github/Preocts/commented-configparser/main)\n[![Python tests](https://github.com/Preocts/commented-configparser/actions/workflows/python-tests.yml/badge.svg?branch=main)](https://github.com/Preocts/commented-configparser/actions/workflows/python-tests.yml)\n\n# commented-configparser\n\nA custom ConfigParser class that preserves comments and option casing when writing loaded config out.\n\nThis library gives you a custom class of the standard library's `configparser.ConfigParger` which will preserve the comments of a loaded config file when writing that file back out.\n\n---\n\n## Install via pip\n\nFrom pypi:\n\n```bash\npython -m pip install commented-configparser\n```\n\nFrom github:\n\n```bash\npython -m pip install commented-configparser@git+https://github.com/Preocts/commented-configparser@x.x.x\n```\n\n**Note:** Replace `x.x.x` with the desired tag or branch.\n\n---\n\n## Example use\n\n```py\nfrom commentedconfigparser import CommentedConfigParser\n\n# Load the config like normal\nconfig = CommentedConfigParser()\nconfig.read(\"myconfig.ini\")\n\n# Use the config like normal\n...\n\n# Update the config like normal\n...\n\n# Save the config back to the file\nwith open(\"myconfig.ini\", \"w\") as savefile:\n    config.write(savefile)\n```\n\n## Results\n\nWe favor the line spacing choices of the `ConfigParser` class so the input format may not be preserved completely. However, the comments will be preserved.\n\n### Before\n\n```ini\n# Welcome to our config\n[DEFAULT]\n# This value has some meaning to someone\nfoo=bar\n# Make sure to add this when you need it\ntrace=false\nlogging=true\n; This is a comment as well\n\n    # so we need to track all of them\n\n\t; and many could be between things\n[NEW SECTION]\n# Another comment\nmulti-line=\n\tvalue01\n\tvalue02\n\tvalue03\nclosing=0\n# Trailing comment\n\n```\n\n### After\n\n```ini\n# Welcome to our config\n[DEFAULT]\n# This value has some meaning to someone\nfoo = bar\n# Make sure to add this when you need it\ntrace = false\nlogging = true\n; This is a comment as well\n# so we need to track all of them\n; and many could be between things\n\n[NEW SECTION]\n# Another comment\nmulti-line =\n\tvalue01\n\tvalue02\n\tvalue03\nclosing = 0\n# Trailing comment\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreocts%2Fcommented-configparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpreocts%2Fcommented-configparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpreocts%2Fcommented-configparser/lists"}