{ "info": { "author": "Zmej Serow", "author_email": "zmej.serow@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Topic :: Software Development :: Libraries", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "[![Build Status](https://travis-ci.com/zmej-serow/liteconfig.svg?branch=master)](https://travis-ci.com/zmej-serow/liteconfig)\n[![Coverage Status](https://coveralls.io/repos/github/zmej-serow/liteconfig/badge.svg?branch=master)](https://coveralls.io/github/zmej-serow/liteconfig?branch=master)\n\n# liteconfig\n\nLightweight and configurable .ini config parser with dot notation property access.\n\n## Features\n- dot notation: `value = cfg.section.property`;\n\n- customizable parsing options;\n\n- no dependencies inside, only plain Python;\n\n- can handle text files, multiline strings or lists as input data;\n\n- no singleton, you can use as much Config objects as you want;\n\n- multiple encodings support, including Unicode;\n\n- read/write config files.\n\n## Default parsing options and their meaning\n- `delimiter = '='` \ndelimiter between property and value is \"=\".\n\n- `comment_markers = '#;'` \nempty lines and lines beginning with \"#\" or \";\" are ignored.\n\n- `parse_numbers = True` \nwill try to parse numeric values to int or float.\n\n- `parse_booleans = True` \nwill try to parse boolean values to bool.\n\n- `boolean_true = ('yes', 'true', 'on')` \ncase-insensitive tuple of string values, recognized as boolean \"True\".\n\n- `boolean_false = ('no', 'false', 'off')` \ncase-insensitive tuple of string values, recognized as boolean \"False\".\n\n- `encoding = 'utf-8'` \nparser will try to read and write config files using this encoding.\n\n- `exceptions = False`\nIf True, accessing nonexistent properties (or sections) of config will raise `AttributeError`.\nIf False, nonexistent property will return None. Absent section will return special object Nothing, which can be tested against truth (and it will always return False). So you can use the construction like\n```python\nif cfg.section.property:\n # do something with cfg.section.property\nelse:\n # handle nonexistence\n```\n\n## Public methods of Config object\n- `__init__(input_data [, delimiter, comment_markers, parse_numbers, parse_booleans, boolean_true, boolean_false, encoding, exceptions])` \nInstantiates Config object and parses input_data. Depending on type of input_data, instance will parse it as list, as multiline string or will interpret string as path to config file and read it.\n\n- `has_section(item)` \nReturn True or False depending on existence of config section.\n\n- `has_property(item [, section])` \nReturn True or False depending on existence of config property. Will search in all sections by default or in one concrete section if it is passed as second argument.\n\n- `write(file)` \nExport config to file with the same settings as when object was instantiated.\n\n## Error handling\n- Attempt to load nonexistent config file will raise `FileNotFoundError`.\n\n- Also may raise `PermissionError` if process does not have sufficient privileges to read or write file.\n\n- If desired, access to nonexistent property (or section) will raise `AttributeError`.\n\n- If `input_data` is not list nor string nor path to config file, will raise `ValueError`.\n\n- Fail to decode `input_data` file will result in `UnicodeError`.\n\n## Example\n\n```ini\n===BEGIN config.ini===\n; liteconfig support very simple sectionless configs too\nproperty = value\n\n[section]\n; this comment will be ignored\nheads=tails\ntruth = lie\nnokia = 3310\n\n[misc]\n# this comment will be ignored too\nkill_all_humans = yes\npi = 3.14159\n\n[\u044e\u043d\u0438\u043a\u043e\u0434]\n\u6587\u5b57 = \ud83d\ude09\n===END config.ini===\n```\n\nHere we have: comments and empty lines, three sections and one \"free\" item. Some sections are named using ASCII symbols and one is Unicode. Also notice `heads=tails` key-value: it isn't necessary to have spaces before and after delimiter. Property and values can also be Unicode: cyrillic, hieroglyphs and emoji are welcome, thanks to Python3. \n\nDefault behaviour is to try to represent all numbers as ints and floats, not strings. The same goes to boolean values: notice how `yes` became `True` for `kill_all_humans` property. \n\n```python\nimport liteconfig\n\ncfg = liteconfig.Config('config.ini')\nprint(cfg.property) # 'value'\nprint(cfg.section.heads) # 'tails'\nprint(cfg.\u044e\u043d\u0438\u043a\u043e\u0434.\u6587\u5b57) # '\ud83d\ude09'\n\nprint(cfg.section.nokia) # 3310\nprint(type(cfg.section.nokia)) # int\n\nprint(cfg.misc.kill_all_humans) # True\nprint(type(cfg.misc.kill_all_humans)) # bool\n\nprint(cfg.misc.pi) # 3.14159\nprint(type(cfg.misc.pi)) # float\nprint(cfg.nonexistent) # AttributeError exception or None\nprint(cfg.voidsection.nonexistent) # AttributeError exception or Nothing (boolean False)\nprint(cfg.voidsection) # AttributeError exception or Nothing (boolean False)\n```\n\n## TO-DO\n- Keep comments when writing previously read config.\n\n- Parsers for various formats of hierarchical configs (with subsections).\n\n## History\n- 0.0.1: initial release.\n\n- 0.0.2: added option to raise exception or return None/False for absent properties or sections.\n\n- 0.0.3: minor fixes in documentation.\n\n- 0.1.0: added tests. Removed '1' and '0' from parsed booleans, as it conflicts with parsing numbers.\n\n- 0.1.1: minor fixes in documentation.\n\n- 0.1.2: code clean-up.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/zmej-serow/liteconfig", "keywords": "configparser ini parsing conf cfg configuration file", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "liteconfig", "package_url": "https://pypi.org/project/liteconfig/", "platform": "any", "project_url": "https://pypi.org/project/liteconfig/", "project_urls": { "Homepage": "https://github.com/zmej-serow/liteconfig" }, "release_url": "https://pypi.org/project/liteconfig/0.1.2/", "requires_dist": null, "requires_python": "", "summary": "Lightweight and configurable .ini config parser with dot notation property access.", "version": "0.1.2" }, "last_serial": 5388025, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "423841b26d96dfd35d97c10075783110", "sha256": "15244dc8fcb3a7ebb3cdd701e0fe9b93094407eaccdfbed2b1cb071b06853fb6" }, "downloads": -1, "filename": "liteconfig-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "423841b26d96dfd35d97c10075783110", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10250, "upload_time": "2019-04-22T22:33:41", "url": "https://files.pythonhosted.org/packages/5a/3f/c02bd742c4920b95baeb031224342cc874f1739e5a62e0da4fbb203cfd52/liteconfig-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d2ef59fd2ff094908bed755cfd95f8b5", "sha256": "67062eb2b1785d7ba72ec251975d61dfbab3f526f1f5068a8115737dfb2a86c3" }, "downloads": -1, "filename": "liteconfig-0.0.1.tar.gz", "has_sig": false, "md5_digest": "d2ef59fd2ff094908bed755cfd95f8b5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5317, "upload_time": "2019-04-22T22:33:44", "url": "https://files.pythonhosted.org/packages/76/da/6bc7d9c078b89f993444cd146f2a778745d5948738da45aa11c7c3f5adbf/liteconfig-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "823b8a8a1e0eb0d9dedc3a7df2a8cd8d", "sha256": "981e81a094176697399288d6e3d07427f4a6c4bc9db06cb2579f9813d9d6417a" }, "downloads": -1, "filename": "liteconfig-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "823b8a8a1e0eb0d9dedc3a7df2a8cd8d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8067, "upload_time": "2019-04-27T17:56:29", "url": "https://files.pythonhosted.org/packages/1a/99/e23387b5c2ae43e29a87fb69099495791b5f9867bdc3f77ecb7348182653/liteconfig-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b9aa5dfe4eef14008361f5942d6bbfc7", "sha256": "84b9d3a2a7cfb762ffb402f1315190e3d53b1d69095d4f22c2581a48e15486d7" }, "downloads": -1, "filename": "liteconfig-0.0.2.tar.gz", "has_sig": false, "md5_digest": "b9aa5dfe4eef14008361f5942d6bbfc7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6164, "upload_time": "2019-04-27T17:56:32", "url": "https://files.pythonhosted.org/packages/90/70/14bbf0ecc7586ccb08bc4cd4dfe700e06010d14195ea0dc0c7f8b606942b/liteconfig-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "da278113d7ac65282d5f99e1db497821", "sha256": "56015441e8087367f423d15ac36a403fc3b9a80dc4454edb66d3342a8b90098b" }, "downloads": -1, "filename": "liteconfig-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "da278113d7ac65282d5f99e1db497821", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8093, "upload_time": "2019-04-27T18:04:17", "url": "https://files.pythonhosted.org/packages/71/05/eb1f5d0237bfe62504c9427fb8cda7e2337d03e13f5b201e5bd975fc0bf7/liteconfig-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "955da0dfa3b7ad57bfe41174d5054d82", "sha256": "fd23d84d9e1fe31b0208adfee14b62b3e601856cf422102ae37fcab767eb385d" }, "downloads": -1, "filename": "liteconfig-0.0.3.tar.gz", "has_sig": false, "md5_digest": "955da0dfa3b7ad57bfe41174d5054d82", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6198, "upload_time": "2019-04-27T18:04:20", "url": "https://files.pythonhosted.org/packages/49/14/5e9f15ef3e8b37d8b5449a89d4c1f89da32fad0c352edecba1835ce5321f/liteconfig-0.0.3.tar.gz" } ], "0.1.0": [ { "comment_text": "", "digests": { "md5": "ceb2a0396310ccc5d9eb0d54358412a5", "sha256": "017346da24511ec7f7c18be749ddfc6ae3756d6bfc82c16873f85071c9c50df8" }, "downloads": -1, "filename": "liteconfig-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "ceb2a0396310ccc5d9eb0d54358412a5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 8150, "upload_time": "2019-06-04T13:12:07", "url": "https://files.pythonhosted.org/packages/d7/1d/fd508bea6a93f3e26a6d861c894a0e13c65e6e65931bd1a19e312eb5301b/liteconfig-0.1.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e1aeb238996fc827f0fb324ad701c2ea", "sha256": "8f7d66f95f646ae7bf921eba1473fc863a41f770ad610c18da97fe3f9f931ecd" }, "downloads": -1, "filename": "liteconfig-0.1.0.tar.gz", "has_sig": false, "md5_digest": "e1aeb238996fc827f0fb324ad701c2ea", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6309, "upload_time": "2019-06-04T13:12:08", "url": "https://files.pythonhosted.org/packages/cf/13/b9581610be9069545c61bc958e6beb5c8d09026d45c4c1f69586f85e6eaf/liteconfig-0.1.0.tar.gz" } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "1e72ea5b3c6e717f84705df65ff0b8d4", "sha256": "5aabef5c67d70771e4e61de7f34d2c66365383d82be44dfc1d9b18cab85c50b3" }, "downloads": -1, "filename": "liteconfig-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "1e72ea5b3c6e717f84705df65ff0b8d4", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9892, "upload_time": "2019-06-04T21:25:58", "url": "https://files.pythonhosted.org/packages/ad/31/8706028b7c5f03652d6b1f2bfdb60cd812b27c5c991127319724470fcf42/liteconfig-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d4f9ad7acf1a06d5361d46d6821fcba5", "sha256": "496323f0d60b8b7b49134afcf38cbfb03fa3fd06f31b67fe8b2874bbf064f8cc" }, "downloads": -1, "filename": "liteconfig-0.1.1.tar.gz", "has_sig": false, "md5_digest": "d4f9ad7acf1a06d5361d46d6821fcba5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7523, "upload_time": "2019-06-04T21:26:00", "url": "https://files.pythonhosted.org/packages/d8/43/ddd87cc7dd556c2f7a6ec91de92c816453d233b5ac208fac4897bdc7c230/liteconfig-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "08ad87a940cc35b06f762388c6ee3bd9", "sha256": "b34fc148f3b860e5d1d84ab6b81d834c9515b11162cffb305ae01f727c1f4e87" }, "downloads": -1, "filename": "liteconfig-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "08ad87a940cc35b06f762388c6ee3bd9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9980, "upload_time": "2019-06-11T19:33:00", "url": "https://files.pythonhosted.org/packages/b7/95/a729242bc13dc2b21ca80d07771f84dda281d5fe87e5f469d6115b94d1b3/liteconfig-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9b8f8dc973491277a8673c1db3d4d3d1", "sha256": "65d2955ba39600303632e8651d15f61ffbceda40f78b2872779575f027f18ed6" }, "downloads": -1, "filename": "liteconfig-0.1.2.tar.gz", "has_sig": false, "md5_digest": "9b8f8dc973491277a8673c1db3d4d3d1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7660, "upload_time": "2019-06-11T19:33:02", "url": "https://files.pythonhosted.org/packages/92/5d/0a82317aa022a600a6c56d1b091e398df7805aebc06c0ee58ef107b94b6d/liteconfig-0.1.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "08ad87a940cc35b06f762388c6ee3bd9", "sha256": "b34fc148f3b860e5d1d84ab6b81d834c9515b11162cffb305ae01f727c1f4e87" }, "downloads": -1, "filename": "liteconfig-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "08ad87a940cc35b06f762388c6ee3bd9", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 9980, "upload_time": "2019-06-11T19:33:00", "url": "https://files.pythonhosted.org/packages/b7/95/a729242bc13dc2b21ca80d07771f84dda281d5fe87e5f469d6115b94d1b3/liteconfig-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "9b8f8dc973491277a8673c1db3d4d3d1", "sha256": "65d2955ba39600303632e8651d15f61ffbceda40f78b2872779575f027f18ed6" }, "downloads": -1, "filename": "liteconfig-0.1.2.tar.gz", "has_sig": false, "md5_digest": "9b8f8dc973491277a8673c1db3d4d3d1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7660, "upload_time": "2019-06-11T19:33:02", "url": "https://files.pythonhosted.org/packages/92/5d/0a82317aa022a600a6c56d1b091e398df7805aebc06c0ee58ef107b94b6d/liteconfig-0.1.2.tar.gz" } ] }