{ "info": { "author": "Tarek Ziade", "author_email": "tarek@mozilla.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)", "Programming Language :: Python" ], "description": "======\nKonfig\n======\n\nYet another configuration object. Compatible with the updated `configparser\n`_.\n\n|travis| |master-coverage|\n\n\n.. |master-coverage| image::\n https://coveralls.io/repos/mozilla-services/konfig/badge.svg?branch=master\n :alt: Coverage\n :target: https://coveralls.io/r/mozilla-services/konfig\n\n.. |travis| image:: https://travis-ci.org/mozilla-services/konfig.svg?branch=master\n :target: https://travis-ci.org/mozilla-services/konfig\n\n\nUsage\n=====\n\n.. code-block:: python\n\n >>> from konfig import Config\n >>> c = Config('myconfig.ini')\n\n\nThen read `configparser's documentation\n`_ for the APIs.\n\nKonfig as some extra APIs like **as_args()**, which will return\nthe config file as argparse compatible arguments::\n\n >>> c.as_args()\n ['--other-stuff', '10', '--httpd', '--statsd-endpoint', 'http://ok']\n\n\nFor automatic filtering, you can also pass an argparse parser object\nto **scan_args()**. I will iterate over the arguments you've defined in the\nparser and look for them in the config file, then return a list of args\nlike **as_args()**. You can then use this list directly\nwith **parser.parse_args()** - or complete it with sys.argv or whatever.\n\n >>> import argparse\n >>> parser = argparse.ArgumentParser()\n >>> parser.add_argument('--log-level', dest='loglevel')\n >>> parser.add_argument('--log-output', dest='logoutput')\n >>> parser.add_argument('--daemon', dest='daemonize', action='store_true')\n\n >>> config = Config('myconfig.ini')\n >>> args_from_config = config.scan_args(parser)\n\n >>> parser.parse_args(args=sys.argv[1:]+args_from_config)\n\n\nSyntax Definition\n=================\n\nThe configuration file is a ini-based file. (See\nhttp://en.wikipedia.org/wiki/INI_file for more details.) Variables name can be\nassigned values, and grouped into sections. A line that starts with \"#\" is\ncommented out. Empty lines are also removed.\n\nExample:\n\n.. code-block:: ini\n\n [section1]\n # comment\n name = value\n name2 = \"other value\"\n\n [section2]\n foo = bar\n\nIni readers in Python, PHP and other languages understand this syntax.\nAlthough, there are subtle differences in the way they interpret values and in\nparticular if/how they convert them.\n\nValues conversion\n=================\n\nHere are a set of rules for converting values:\n\n- If value is quoted with \" chars, it's a string. This notation is useful to\n include \"=\" characters in the value. In case the value contains a \" character,\n it must be escaped with a \"\\\" character.\n\n- When the value is composed of digits and optionally prefixed by \"-\", it's\n tentatively converted to an integer or a long depending on the language. If the\n number exceeds the range available in the language, it's left as a string.\n\n- If the value is \"true\" or \"false\", it's converted to a boolean, or 0 and 1\n when the language does not have a boolean type.\n\n- A value can be an environment variable : \"${VAR}\" is replaced by the value of\n VAR if found in the environment. If the variable is not found, an error must be\n raised.\n\n- A value can contains multiple lines. When read, lines are converted into a\n sequence of values. Each new line for a multiple lines value must start with a\n least one space or tab character.\n\nExamples:\n\n.. code-block:: ini\n\n [section1]\n # comment\n a_flag = True\n a_number = 1\n a_string = \"other=value\"\n another_string = other value\n a_list = one\n two\n three\n user = ${USERNAME}\n\n\nExtending a file\n================\n\nAn INI file can extend another file. For this, a \"DEFAULT\" section must contain\nan \"extends\" variable that can point to one or several INI files which will be\nmerged to the current file by adding new sections and values.\n\nIf the file pointed in \"extends\" contains section/variable names that already\nexist in the original file, they will not override existing ones.\n\nHere's an example: you have a public config file and want to keep some database\npasswords private. You can have those password in a separate file.\n\npublic.ini:\n\n.. code-block:: ini\n\n [database]\n user = tarek\n password = PUBLIC\n\n [section2]\n foo = baz\n bas = bar\n\n\nAnd then in private.ini:\n\n.. code-block:: ini\n\n [DEFAULT]\n extends = public.ini\n\n [database]\n password = secret\n\nNow if you use *private.ini* you will get:\n\n.. code-block:: ini\n\n [database]\n user = tarek\n password = secret\n\n [section2]\n foo = baz\n bas = bar\n\n\n\nTo point several files, the multi-line notation can be used:\n\n.. code-block:: ini\n\n [DEFAULT]\n extends = public1.ini\n public2.ini\n\n\nWhen several files are provided, they are processed sequentially. So if the\nfirst one has a value that is also present in the second, the second one will\nbe ignored. This means that the configuration goes from the most specialized to\nthe most common.\n\nOverride mode\n=============\n\nIf you want to extend a file and have existing values overridden,\nyou can use \"overrides\" instead of \"extends\".\n\nHere's an example. file2.ini:\n\n.. code-block:: ini\n\n [section1]\n name2 = \"other value\"\n\n [section2]\n foo = baz\n bas = bar\n\n\nfile1.ini:\n\n.. code-block:: ini\n\n [DEFAULT]\n overrides = file2.ini\n\n [section2]\n foo = bar\n\n\nResult if you use *file1.ini*:\n\n.. code-block:: ini\n\n [section1]\n name2 = \"other value\"\n\n [section2]\n foo = baz\n bas = bar\n\nIn *section2*, notice that *foo* is now *baz*.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mozilla-services/konfig", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "konfig", "package_url": "https://pypi.org/project/konfig/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/konfig/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/mozilla-services/konfig" }, "release_url": "https://pypi.org/project/konfig/1.1/", "requires_dist": null, "requires_python": null, "summary": "Yet Another Config Parser.", "version": "1.1" }, "last_serial": 2552137, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "67e8ac0849f667e3ceeab27c6ae02b17", "sha256": "e073da2f7e1062f6839d58377145a5bce82ed803a3e5582c47deab1c249667fd" }, "downloads": -1, "filename": "konfig-0.1.tar.gz", "has_sig": false, "md5_digest": "67e8ac0849f667e3ceeab27c6ae02b17", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5780, "upload_time": "2013-02-28T15:51:19", "url": "https://files.pythonhosted.org/packages/8b/98/5a41e639353037d1f6f97f1b4650123045dda58c850e2ac2bd44a70ce020/konfig-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "01fbedf1a2a413541b269f4534d42714", "sha256": "6f0d66c1c7809d1583edf80db8cdbf9c13b6934758b190716195536364a1609a" }, "downloads": -1, "filename": "konfig-0.2.tar.gz", "has_sig": false, "md5_digest": "01fbedf1a2a413541b269f4534d42714", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6583, "upload_time": "2013-03-07T12:32:46", "url": "https://files.pythonhosted.org/packages/cf/1b/c5f847c813caeba7b07cac60bf3c583d25a19bfcd78feaf0d73375683874/konfig-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "cdba9f27a231894ec9a74c7ad3d0b629", "sha256": "ff951daddb4a0484c0cf16f7a6900b56c63bbd3d38961f55f66bf7ae23fb230a" }, "downloads": -1, "filename": "konfig-0.3.tar.gz", "has_sig": false, "md5_digest": "cdba9f27a231894ec9a74c7ad3d0b629", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6645, "upload_time": "2013-05-02T15:46:19", "url": "https://files.pythonhosted.org/packages/f5/c3/47e15970d799e344570e9605e5a1cc85c818ae40585e447631d64f4e8d8a/konfig-0.3.tar.gz" } ], "0.4": [ { "comment_text": "", "digests": { "md5": "e3a836f99641f5688b23d60849741ce9", "sha256": "31eff05cf493273d2b7a941a9b7bd96fdc1070ed3fb06f76329bd37236abbfcd" }, "downloads": -1, "filename": "konfig-0.4.tar.gz", "has_sig": false, "md5_digest": "e3a836f99641f5688b23d60849741ce9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6688, "upload_time": "2013-05-02T16:11:42", "url": "https://files.pythonhosted.org/packages/00/16/6e820bda52fee3e22a6080d9ecac5e0693b4c1c42e11a4422f0b8b25b59b/konfig-0.4.tar.gz" } ], "0.5": [ { "comment_text": "", "digests": { "md5": "250eb2df4c355bd8d794be8a1eb14dff", "sha256": "8addafbd9589e01d00705b6dd056e9609c1ac0b9b14fa685284b383dbd6424cf" }, "downloads": -1, "filename": "konfig-0.5.tar.gz", "has_sig": false, "md5_digest": "250eb2df4c355bd8d794be8a1eb14dff", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6928, "upload_time": "2013-05-23T11:40:27", "url": "https://files.pythonhosted.org/packages/c6/22/845d2ea03a5b049774d98437e0a31fd5a510cc73f5fa84b860c3daad3f55/konfig-0.5.tar.gz" } ], "0.6": [ { "comment_text": "", "digests": { "md5": "3df992dadbbabb3407da0ca2bf10d0f9", "sha256": "35c9840b23092e20df75938e4be35b97cba6babf9d62edd83fdb11784cd2993d" }, "downloads": -1, "filename": "konfig-0.6.tar.gz", "has_sig": false, "md5_digest": "3df992dadbbabb3407da0ca2bf10d0f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8677, "upload_time": "2013-06-19T11:37:24", "url": "https://files.pythonhosted.org/packages/23/6d/ae187b26b7f9847e3a9d00775b1d7f07913562031dca3ce789aa8ca4dad5/konfig-0.6.tar.gz" } ], "0.7": [ { "comment_text": "", "digests": { "md5": "17730516792c79c626fbbbeff25653e1", "sha256": "f1127023d5a7f54dc4885c3a8728d4bb9a1df079676a5cef0a79d104205ce42b" }, "downloads": -1, "filename": "konfig-0.7.tar.gz", "has_sig": false, "md5_digest": "17730516792c79c626fbbbeff25653e1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9388, "upload_time": "2013-07-16T13:48:47", "url": "https://files.pythonhosted.org/packages/83/cf/e48d0b6f799117cde449c2bcb1ec4bc94ef63b3360fa96543079cf37767f/konfig-0.7.tar.gz" } ], "0.8": [ { "comment_text": "", "digests": { "md5": "7bbfa45fb5f084d303745b63551a6db6", "sha256": "9a0157342c1b69004aeeec7bce2b042f4e640e1b456ceb38393697882526a38e" }, "downloads": -1, "filename": "konfig-0.8.tar.gz", "has_sig": false, "md5_digest": "7bbfa45fb5f084d303745b63551a6db6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9476, "upload_time": "2013-07-29T11:10:51", "url": "https://files.pythonhosted.org/packages/06/30/1e25e90839f763fff18d57f2776e691e9b9a20add4eb74b101ed0834d840/konfig-0.8.tar.gz" } ], "0.9": [ { "comment_text": "", "digests": { "md5": "dabc925653161ffaa8bf477488dc6b3f", "sha256": "3e4049faeaf7d980f527486d45cbcf35cd0c98c0d6e5f76100668bca71348241" }, "downloads": -1, "filename": "konfig-0.9.tar.gz", "has_sig": false, "md5_digest": "dabc925653161ffaa8bf477488dc6b3f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8813, "upload_time": "2014-04-28T09:38:32", "url": "https://files.pythonhosted.org/packages/90/73/54c97a09b43917870beda7fb058e2a5ee3fb734fd824de1c16d195e8ed8f/konfig-0.9.tar.gz" } ], "1.0": [ { "comment_text": "", "digests": { "md5": "94f358e00b2dd7557bdb6922df6030ab", "sha256": "02394f5ecf6177ae66e2c92a5fa4b487a93fcee9490008fb12a7746f7f5f5b50" }, "downloads": -1, "filename": "konfig-1.0.tar.gz", "has_sig": false, "md5_digest": "94f358e00b2dd7557bdb6922df6030ab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8891, "upload_time": "2017-01-03T16:01:27", "url": "https://files.pythonhosted.org/packages/e8/da/bf5b03ff37add74396e1d6b80b1b046ab76ee88f5377bcc56c00a702a865/konfig-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "368e7c217d31de6c5918c740da6e8dfb", "sha256": "7aa4c6463d6c13f4c98c02a998cbef4729da9ad69b676627acc8d3b3efb02b57" }, "downloads": -1, "filename": "konfig-1.1.tar.gz", "has_sig": false, "md5_digest": "368e7c217d31de6c5918c740da6e8dfb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9043, "upload_time": "2017-01-03T19:08:35", "url": "https://files.pythonhosted.org/packages/3d/0c/2d61f29390063d9aabd20f1859b846faeb9e82711aae1ad92c5663264b00/konfig-1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "368e7c217d31de6c5918c740da6e8dfb", "sha256": "7aa4c6463d6c13f4c98c02a998cbef4729da9ad69b676627acc8d3b3efb02b57" }, "downloads": -1, "filename": "konfig-1.1.tar.gz", "has_sig": false, "md5_digest": "368e7c217d31de6c5918c740da6e8dfb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9043, "upload_time": "2017-01-03T19:08:35", "url": "https://files.pythonhosted.org/packages/3d/0c/2d61f29390063d9aabd20f1859b846faeb9e82711aae1ad92c5663264b00/konfig-1.1.tar.gz" } ] }