{ "info": { "author": "Benjamin Fogle", "author_email": "benfogle@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.1", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development" ], "description": ".. image:: https://travis-ci.org/benfogle/configlines.svg?branch=master\n :target: https://travis-ci.org/benfogle/configlines\n\n.. image:: https://codecov.io/gh/benfogle/configlines/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/benfogle/configlines\n\n\nDescription\n-----------\nThis module is an extension to Python's standard `configparser`_ module\nthat adds file and line number information to each stored option. This\nis primarily useful in reporting error messages: you can point your user\nto exactly where a bad value occurred:\n\n.. code:: python\n\n try:\n timeout = config.getint('connection', 'retry')\n except ValueError:\n filename, line = config.get_location('connection', 'retry')\n logging.error(\"retry must be an integer (%s:%d)\", filename, line)\n ...\n\nThis package is compatible with both Python 2 and 3.\n\nInstallation\n------------\n\nInstall with pip::\n\n $ pip install configlines\n\nUsage\n-----\n\nGiven the following two configuration files:\n\n.. code:: ini\n\n # Line one of data1.cfg\n [some_section]\n foo = 1\n\n [DEFAULT]\n bar = 2\n\n.. code:: ini\n\n # Line one of data2.cfg\n [some_section]\n baz = 3\n\nYou can read and manipulate them exactly the same as the standard module:\n\n.. code:: python\n\n >>> from configlines import ConfigParser\n >>> cfg = ConfigParser()\n >>> cfg.read(['data1.cfg', 'data2.cfg'])\n >>> cfg.get('some_section', 'foo')\n '1'\n\nYou can also access file and line information:\n\n.. code:: python\n\n >>> cfg.get_location('some_section', 'foo')\n ('data1.cfg', 3)\n >>> cfg.get_location('some_section', 'bar')\n ('data1.cfg', 6)\n >>> cfg.get_location('some_section', 'baz')\n ('data2.cfg', 3)\n\nIn addition to ``get_location``, this module also provides ``get_line`` and\n``get_filename`` functions for convenience.\n\nIf an option didn't come from a file, (i.e., you set it programmatically,) then\nline number information will not be present:\n\n.. code:: python\n\n >>> cfg.set('some_section', 'qwerty', '1234')\n >>> cfg.get_location('some_section', 'qwerty')\n None\n\nOverwriting options programmatically will erase line number information:\n\n.. code:: python\n\n >>> cfg.get_location('some_section', 'foo')\n ('data1.cfg', 3)\n >>> cfg.set('some_section', 'foo', '1234')\n >>> cfg.get_location('some_section', 'foo')\n None\n\nLine number information can be set explicitly:\n\n.. code:: python\n\n >>> cfg.set('some_section', 'foo', '1234', location=('somefile.cfg',10))\n >>> cfg.get_location('some_section', 'foo')\n ('somefile.cfg', 10)\n >>> cfg.set('some_section', 'foo', '1234', location='preserve')\n >>> cfg.get_location('some_section', 'foo')\n ('somefile.cfg', 10)\n >>> cfg.set_location('some_section', 'foo', ('otherfile.cfg', 50))\n >>> cfg.get_location('some_section', 'foo')\n ('otherfile.cfg', 50)\n\n.. _configparser: https://docs.python.org/3/library/configparser.html\n\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/benfogle/configlines", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "configlines", "package_url": "https://pypi.org/project/configlines/", "platform": "", "project_url": "https://pypi.org/project/configlines/", "project_urls": { "Homepage": "https://github.com/benfogle/configlines" }, "release_url": "https://pypi.org/project/configlines/0.3/", "requires_dist": [ "six" ], "requires_python": "", "summary": "Add line number information to ConfigParser options", "version": "0.3" }, "last_serial": 3839645, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "70a3e353064e2274f081fa418066235e", "sha256": "6d9fddf67ec5a905c01ee774f2112a157188d01fa65d0fe65ac5797bf575db0d" }, "downloads": -1, "filename": "configlines-0.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "70a3e353064e2274f081fa418066235e", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6090, "upload_time": "2018-05-06T19:47:38", "url": "https://files.pythonhosted.org/packages/f2/d6/fb587f4d644e4a3de1995573b91994c92c308932c8a43a40dd512a815475/configlines-0.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c4830513153138795c7e51b689f0d479", "sha256": "f131fb7bbba20bc4112f0530a16d3bcbb05d9c9f486b27281fbca612a7ef2fe4" }, "downloads": -1, "filename": "configlines-0.1.tar.gz", "has_sig": false, "md5_digest": "c4830513153138795c7e51b689f0d479", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5765, "upload_time": "2018-05-06T19:47:39", "url": "https://files.pythonhosted.org/packages/38/eb/c5a2c07aee1afc41d53dcadf6f08cccce23719ea627efd0cffa74a58d91d/configlines-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "9f3cd2e197a00d7ef422d784e7d24bfb", "sha256": "c58d0596053204201993ab058c0b02d2aec0ce62f55965eaf4d537448f2b54fd" }, "downloads": -1, "filename": "configlines-0.2-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "9f3cd2e197a00d7ef422d784e7d24bfb", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6090, "upload_time": "2018-05-07T00:14:18", "url": "https://files.pythonhosted.org/packages/d0/4b/fecb2e1305b630dd250e73184add5c305dafd9eaa4335ccccf6e0f5984cd/configlines-0.2-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e3e5eaf2095d72e75a1c10b22127eeda", "sha256": "844a69fb0e2de416f6cd4a46fdcf5f3253a6bbd4a01b3ee356a3567de1c7a855" }, "downloads": -1, "filename": "configlines-0.2.tar.gz", "has_sig": false, "md5_digest": "e3e5eaf2095d72e75a1c10b22127eeda", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5515, "upload_time": "2018-05-07T00:14:19", "url": "https://files.pythonhosted.org/packages/03/a6/e95031738b742576e155aada1195fddfce3063ca872825c560e75eff3152/configlines-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "90988ba1357b5011ee769585f6c56cdc", "sha256": "7a6c69ae312abfb15655460f6c041b6fcbf91633ce90c5ca2b0bcc0194f1d15f" }, "downloads": -1, "filename": "configlines-0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "90988ba1357b5011ee769585f6c56cdc", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6683, "upload_time": "2018-05-07T01:18:30", "url": "https://files.pythonhosted.org/packages/7c/3c/7d22bf62d9e8ab89b342b06c78b854aa79ee2d4ebdb07a04e2c5bd5c580a/configlines-0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "231ace1f99d29a86ddf5ee9d2fd45438", "sha256": "34cc93eaf89479a58e6b6afe53ad25a7e27bdbdeee894650d8925fa65af748d5" }, "downloads": -1, "filename": "configlines-0.3.tar.gz", "has_sig": false, "md5_digest": "231ace1f99d29a86ddf5ee9d2fd45438", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6110, "upload_time": "2018-05-07T01:18:31", "url": "https://files.pythonhosted.org/packages/3f/2a/3dc97e0c846579475ab59335ab30f098ee1e98eed783dc9c2800b337f4c3/configlines-0.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "90988ba1357b5011ee769585f6c56cdc", "sha256": "7a6c69ae312abfb15655460f6c041b6fcbf91633ce90c5ca2b0bcc0194f1d15f" }, "downloads": -1, "filename": "configlines-0.3-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "90988ba1357b5011ee769585f6c56cdc", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 6683, "upload_time": "2018-05-07T01:18:30", "url": "https://files.pythonhosted.org/packages/7c/3c/7d22bf62d9e8ab89b342b06c78b854aa79ee2d4ebdb07a04e2c5bd5c580a/configlines-0.3-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "231ace1f99d29a86ddf5ee9d2fd45438", "sha256": "34cc93eaf89479a58e6b6afe53ad25a7e27bdbdeee894650d8925fa65af748d5" }, "downloads": -1, "filename": "configlines-0.3.tar.gz", "has_sig": false, "md5_digest": "231ace1f99d29a86ddf5ee9d2fd45438", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6110, "upload_time": "2018-05-07T01:18:31", "url": "https://files.pythonhosted.org/packages/3f/2a/3dc97e0c846579475ab59335ab30f098ee1e98eed783dc9c2800b337f4c3/configlines-0.3.tar.gz" } ] }