{"id":15297425,"url":"https://github.com/omushpapa/pyconfigreader","last_synced_at":"2026-02-26T22:03:58.984Z","repository":{"id":29813305,"uuid":"121251818","full_name":"omushpapa/pyconfigreader","owner":"omushpapa","description":"A python module for handling configuration files","archived":false,"fork":false,"pushed_at":"2022-12-08T03:11:31.000Z","size":147,"stargazers_count":1,"open_issues_count":3,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-27T02:58:53.738Z","etag":null,"topics":["config","configparser","python","python-configparser","python2","python3","reader"],"latest_commit_sha":null,"homepage":"https://pyconfigreader.readthedocs.io","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/omushpapa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-12T13:46:54.000Z","updated_at":"2025-10-04T13:57:41.000Z","dependencies_parsed_at":"2023-01-14T15:45:26.334Z","dependency_job_id":null,"html_url":"https://github.com/omushpapa/pyconfigreader","commit_stats":null,"previous_names":["giantas/pyconfigreader"],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/omushpapa/pyconfigreader","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omushpapa%2Fpyconfigreader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omushpapa%2Fpyconfigreader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omushpapa%2Fpyconfigreader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omushpapa%2Fpyconfigreader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/omushpapa","download_url":"https://codeload.github.com/omushpapa/pyconfigreader/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/omushpapa%2Fpyconfigreader/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29874496,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-26T21:05:00.265Z","status":"ssl_error","status_checked_at":"2026-02-26T20:57:13.669Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["config","configparser","python","python-configparser","python2","python3","reader"],"created_at":"2024-09-30T19:17:25.773Z","updated_at":"2026-02-26T22:03:58.940Z","avatar_url":"https://github.com/omushpapa.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pyconfigreader\n\n[![Travis-CI](https://img.shields.io/travis/giantas/pyconfigreader.svg?maxAge=220)](https://travis-ci.org/giantas/pyconfigreader)\n[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/5f3132cafe78478dbdeb081b53d3661d)](https://www.codacy.com/app/giantas/pyconfigreader?utm_source=github.com\u0026utm_medium=referral\u0026utm_content=giantas/pyconfigreader\u0026utm_campaign=Badge_Coverage)\n[![Issues](https://img.shields.io/github/issues-raw/giantas/pyconfigreader/website.svg)](https://github.com/giantas/pyconfigreader/issues)\n[![Python](https://img.shields.io/pypi/pyversions/pyconfigreader.svg)](https://img.shields.io/pypi/pyversions/pyconfigreader.svg)\n\nA configuration file handler for the most basic stuff in ini files that will get you up and running in no time.\n\npyconfigreader's `ConfigReader` uses Python's ConfigParser to parse config files.\n\n***PS***: This is just to get you working on other stuff and not focus on config files. \nIf you need advanced features head to [Python's ConfigParser](https://docs.python.org/3/library/configparser.html) or \nread [pyconfigreader's documentation](https://pyconfigreader.readthedocs.io/).\n\n# Usage\n\n## Installation\n```\n$ pip install pyconfigreader\n```\n\n## Setting Values\n\n`ConfigReader` creates a default `main` section in which key-value pairs are inserted if no section is specified.\n\n```python\nfrom pyconfigreader import ConfigReader\nconfig = ConfigReader(filename='config.ini')\nconfig.set('version', '2')  # Saved to section `main`\nconfig.set('Key', 'Value', section='Section')   # Creates a section `Section` on-the-fly\nconfig.set('name', 'main')\nconfig.close(save=True)  # Save on close\n# Or explicitly call\n# config.save()\n# config.close()\n```\n\nBy default, changes are not immediately written to the file on disk but are kept in memory.\n`commit=True` writes the changes to the file on disk.\n\n```python\nfrom pyconfigreader import ConfigReader\nconfig = ConfigReader(filename='config.ini')\nconfig.set('okay', 'True', commit=True)\n```\n\n## Getting values\n\nGetting values only requires specifying the key. If the key does not exist then None is returned. No exception is raised.\n\n```python\nfrom pyconfigreader import ConfigReader\nconfig = ConfigReader(filename='config.ini')\nname = config.get('name')\nokay = config.get('okay')\nsection = config.get('Key', section='Section')  # Get from the section `Section`\n\nagency = config.get('agency')  # Raises NoOptionError\n\nprint(config.sections)  # Get a list of sections\n\nkey, value, section = config.search('config')   # Search for the parameters of a value. Returns a tuple\n\nhelp(config)\nconfig.close()  # Don't forget to close the file object\n```\n\nSometimes, if a key is not available a return value may be added using the `default` argument\n```python\nfrom pyconfigreader import ConfigReader\nconfig = ConfigReader(filename='config.ini')\nname = config.get('country', default='Kenya')   # Returns Kenya since key was not available in config file\nconfig.close()\n```\n\nThe return value, by default, is not saved to file but this can be enabled by \nsetting `default_commit`=True\n```python\nfrom pyconfigreader import ConfigReader\nconfig = ConfigReader(filename='config.ini')\nname = config.get('name', default='Kenya', default_commit=True)\nconfig.close()\n```\n\nAny call to `commit` saves all the in-memory changes to the file on disk.\n\n## Options\n\nOptions can be remove permanently\n\n```python\nfrom pyconfigreader import ConfigReader\nconfig = ConfigReader(filename='config.ini')\nconfig.remove_option('reader')  # the reader option is always set by default\n# or config.remove_key('reader')\nconfig.set('name', 'first', section='Details')\nconfig.remove_option('name', section='Details')\nconfig.close(save=True)\n```\n\n## Sections\nSections are created when keys and values are added to them.\n\n```python\nfrom pyconfigreader import ConfigReader\nconfig = ConfigReader(filename='config.ini')\nconfig.set('name', 'first', section='Details')  # Save key `name` with value `first` in section `Details`\nconfig.close()\n```\n\nSections can be removed explicitly.\n```python\nfrom pyconfigreader import ConfigReader\nconfig = ConfigReader(filename='config.ini')\nconfig.set('name', 'first', section='Details') # Creates section `Details`\nconfig.remove_section('Details')    # Removes section `Details` plus all the keys and values\nconfig.close(save=True)\n```\n\nSection items can be acquired as dictionary values\n```python\nfrom pyconfigreader import ConfigReader\nconfig = ConfigReader(filename='config.ini')\nconfig.set('name', 'first', section='Details')\n\nconfig.get_items('Details')\n# OrderedDict([('name', 'first')])\nconfig.close()  # Or config.close(save=True)\n```\n\n## Environment Variables\nConfiguration values can be save to the environment (`os.environ`)\n\n```python\nimport os\nfrom pyconfigreader import ConfigReader\nconfig = ConfigReader(filename='config.ini')\nconfig.set('name', 'first', section='Details')\nconfig.to_env()\nos.environ['DETAILS_NAME']\n# first\nos.environ['MAIN_READER']\n# configreader\nconfig.close()\n```\n\nThe environment keys are formed from the section name and the key name.\n\n## Saving\n\nChanges are not written to disk unless `commit` is set to True.\n\nAnother alternative is calling `to_file`\n\n```python\nfrom pyconfigreader import ConfigReader\nconfig = ConfigReader(filename='config.ini')\nconfig.set('name', 'first', section='Details')\nconfig.save()\nconfig.close()\n```\n\nAs a context, the changes are saved when the object is closed.\n\n```python\nfrom pyconfigreader import ConfigReader\nwith ConfigReader(filename='config.ini') as config:\n    config.set('name', 'first', section='Details')\n```\n\nThe contents of the config file can also be dumped to a JSON file.\n```python\nfrom pyconfigreader import ConfigReader\nreader = ConfigReader()\nreader.set('name', 'first', section='Details')\nwith open('config.json', 'w') as f:\n    reader.to_json(f)\n    \nreader.close()\n```\n\nA lot more on `help(config)`\n\n# More\nSee [pyconfigreader documentation](https://pyconfigreader.readthedocs.io/).\n\n# License\nDistributed under [MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomushpapa%2Fpyconfigreader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fomushpapa%2Fpyconfigreader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fomushpapa%2Fpyconfigreader/lists"}