{ "info": { "author": "Adrian Perez de Castro", "author_email": "aperez@igalia.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4" ], "description": "====\nwcfg\n====\n\n.. image:: https://img.shields.io/travis/aperezdc/python-wcfg.svg?style=flat\n :target: https://travis-ci.org/aperezdc/python-wcfg\n :alt: Build Status\n\n.. image:: https://img.shields.io/coveralls/aperezdc/python-wcfg/master.svg?style=flat\n :target: https://coveralls.io/r/aperezdc/python-wcfg?branch=master\n :alt: Code Coverage\n\n\n``wcfg`` is a small module to parse hierarchical data from text files, and it\nis particularly suitable for configuration files.\n\nFeatures:\n\n* Text-based, hierarchical format, with simple syntax which is designed to\n be easy to parse both by programs and humans.\n\n* Both reading *and* writing back is supported. Written data is guaranteed\n to be readable back to its original representation.\n\n* Small, self-contained, pure Python implementation.\n\n* Compatible with both Python 2.6 and 3.2 (or newer).\n\n\nRelated projects\n================\n\nEditor support\n--------------\n\nSyntax highlighting for the ``wcfg`` file format and other goodies are\nfor the following text editors:\n\n* **Vim**: `vim-wcfg `__\n\n\n\nExample\n=======\n\nGiven the following input file:\n\n.. code-block::\n\n # Configuration file for SuperFooBar v3000\n interface {\n language: \"en_US\"\n panes {\n top: [\"menu\", \"toolbar\"] # Optional commas in lists\n # The colon separating keys and values is optional\n bottom\n [\"statusbar\"]\n }\n \u263a : True # Enables emoji\n Unicode\u2192Su\u00fe\u00feorte\u00f0? : \"Indeed, J\u00fcrgen!\"\n }\n\n # Configure plug-ins\n plugin: {\n preview # Whitespace is mostly ignored\n {\n enabled: true\n timeout: 500 # Update every 500ms\n }\n }\n\nNote that the ``:`` separator in between keys and values is optional, and\ncan be omitted. Also, notice how white space \u2014including new lines\u2014 are\ncompletely meaningless and the structure is determined using only braces\nand brackets. Last but not least, a valid key is any Unicode character\nsequence which *does not* include white space or a colon.\n\nThe following code can be used to read it into a Python dictionary:\n\n.. code-block:: python\n\n import wcfg\n with open(\"superfoobar3000.conf\", \"rb\") as f:\n config = wcfg.load(f)\n\nConversions work as expected:\n\n* Sections are converted into dictionaries.\n* Keys are converted conveted to strings.\n* Text in double quotes are converted to strings.\n* Sections enclosed into ``{ }`` are converted to dictionaries.\n* Arrays enclosed into ``[ ]`` are converted to lists.\n* Numbers are converted either to ``int`` or ``float``, whichever is more\n appropriate.\n* Boolean values are converted to ``bool``.\n\nThe following can be used to convert a Python dictionary into its textual\nrepresentation:\n\n.. code-block:: python\n\n users = {\n \"peter\": {\n \"uid\": 1000,\n \"name\": \"Peter J\u00f8glund\",\n \"groups\": [\"wheel\", \"peter\"],\n },\n \"root\": {\n \"uid\": 0,\n \"groups\": [\"root\"],\n }\n }\n\n import wcfg\n text = wcfg.dumps(users)\n\nWhen generating a textual representation, the keys of each dictionary will\nbe sorted, to guarantee that the generated output is stable. The dictionary\nfrom the previous snippet would be written in text form as follows:\n\n.. code-block::\n\n peter: {\n name: \"Peter J\u00f8glund\"\n groups: [\"wheel\" \"peter\"]\n uid: 1000\n }\n root: {\n groups: [\"root\"]\n uid: 0\n }\n\n\nGrammar\n=======\n\nThis is the grammar accepted by the parser, in `EBNF syntax\n`__::\n\n identifier = - ( whitespace | \":\" )\n\n string character = - \"\\\"\"\n\n key-value pair = identifier, \":\", value\n | identifier, value\n\n octal digit = \"0\" | \"1\" | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\"\n\n digit = octal digit | \"8\" | \"9\"\n\n hexdigit = digit | \"a\" | \"b\" | \"c\" | \"d\" | \"e\" | \"f\"\n | \"A\" | \"B\" | \"C\" | \"D\" | \"E\" | \"F\"\n\n sign = \"-\" | \"+\"\n\n integral number = digit, { digit }\n\n dotted float = \".\", digit, { digit }\n | digit, \".\", { digit }\n\n exponent = (\"e\" | \"E\"), sign, digit, { digit }\n | (\"e\" | \"E\"), digit, { digit }\n\n float number = dotted float\n | dotted float, exponent\n | integral number, exponent\n\n number body = integral number\n | float number\n\n number = \"0\", ( \"x\" | \"X\" ), hex digit, { hex digit }\n | \"0\", octal digit, { octal digit }\n | sign, number body\n | number body\n\n boolean = \"True\" | \"False\"\n | \"true\" | \"false\"\n\n value = \"\\\"\", { string character }, \"\\\"\"\n | \"[\", { (value | value \",\") } \"]\"\n | \"{\", { key-value pair }, \"}\"\n | boolean\n | number\n\n input = \"{\", { key-value pair }, \"}\"\n | { key-value pair }\n\nNote that comments are not specified in the grammar above does not include\ncomments for the sake of simplicity. Comments can appear anywhere except\ninside strings, and they span from the octothorpe sign (``#``) to the end of\nthe line.\n", "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/aperezdc/python-wcfg", "keywords": null, "license": "Dual GPL3 / MIT", "maintainer": null, "maintainer_email": null, "name": "wcfg", "package_url": "https://pypi.org/project/wcfg/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/wcfg/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/aperezdc/python-wcfg" }, "release_url": "https://pypi.org/project/wcfg/6/", "requires_dist": null, "requires_python": null, "summary": "Parser for hyerarchical text data and configuration files", "version": "6" }, "last_serial": 1322915, "releases": { "1": [ { "comment_text": "", "digests": { "md5": "54edd34d7797cd1bcb841b8dd3ed5f97", "sha256": "cc4dec0e879ae212c2a8a938a6fb3ad45cac82362a46e16823927d2164de3708" }, "downloads": -1, "filename": "wcfg-1.tar.gz", "has_sig": false, "md5_digest": "54edd34d7797cd1bcb841b8dd3ed5f97", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2578, "upload_time": "2014-10-21T15:40:51", "url": "https://files.pythonhosted.org/packages/38/3a/5b3a6edae9a9f7f5d1a178bb2b9007437359c70f3f23ceaa810aee3995c7/wcfg-1.tar.gz" } ], "2": [ { "comment_text": "", "digests": { "md5": "56d325a10843a9ddc572d31024c36f94", "sha256": "33b078da081ff72b8a4adeaff88d2feee8546d8ade3b977f15075b7807cdbc5f" }, "downloads": -1, "filename": "wcfg-2.tar.gz", "has_sig": false, "md5_digest": "56d325a10843a9ddc572d31024c36f94", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9908, "upload_time": "2014-10-22T11:30:23", "url": "https://files.pythonhosted.org/packages/e4/26/0c224d1a266f39071b653825fa8f1c67f0ac3a103d7c051ca3010c033628/wcfg-2.tar.gz" } ], "3": [ { "comment_text": "", "digests": { "md5": "921eec5097ea21e54291357f1952deb8", "sha256": "7c50f2b7bd4d38bcc13f9f2e2ec4243aae55c3e231b7e2a802eaebcf4e476ba3" }, "downloads": -1, "filename": "wcfg-3.tar.gz", "has_sig": false, "md5_digest": "921eec5097ea21e54291357f1952deb8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10121, "upload_time": "2014-11-05T17:44:53", "url": "https://files.pythonhosted.org/packages/60/11/6dd94d307bf20a47dc5a82e44e7d6585dd043a589ec77f3a2829ad41f849/wcfg-3.tar.gz" } ], "4": [ { "comment_text": "", "digests": { "md5": "ded528df7e9912f245a19eabff6cd0ba", "sha256": "772e742bd11fda0c473a7675965726c1f3ef87ec4a541c32bb5e55606c474a27" }, "downloads": -1, "filename": "wcfg-4.tar.gz", "has_sig": false, "md5_digest": "ded528df7e9912f245a19eabff6cd0ba", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10117, "upload_time": "2014-11-05T17:50:22", "url": "https://files.pythonhosted.org/packages/bc/25/76573817ba6b9f49bb576a3e2f3815f263fea67554dc84baca44cd771b96/wcfg-4.tar.gz" } ], "5": [ { "comment_text": "", "digests": { "md5": "aab205869885cfa57e4d48724c258a23", "sha256": "766b787280ea1e3cf6574f7c57796c344b338129ecae3e9e20f158b36644049d" }, "downloads": -1, "filename": "wcfg-5.tar.gz", "has_sig": false, "md5_digest": "aab205869885cfa57e4d48724c258a23", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10354, "upload_time": "2014-11-20T11:49:24", "url": "https://files.pythonhosted.org/packages/f0/10/60954d43f805ccec37dd5a5435836c085675e4de9e4cb1426fe5b25736f8/wcfg-5.tar.gz" } ], "6": [ { "comment_text": "", "digests": { "md5": "118d92a62ef23172a6a90358f6ea53f2", "sha256": "d79879e1c1fef06aa55668fb525a6455b9750c11557dc5e8b0662d02fd58cad3" }, "downloads": -1, "filename": "wcfg-6.tar.gz", "has_sig": false, "md5_digest": "118d92a62ef23172a6a90358f6ea53f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10641, "upload_time": "2014-11-27T11:03:26", "url": "https://files.pythonhosted.org/packages/48/07/d988d419924cb37a988c8962893af1706c44b7a85acdbb3991102e6b8ce9/wcfg-6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "118d92a62ef23172a6a90358f6ea53f2", "sha256": "d79879e1c1fef06aa55668fb525a6455b9750c11557dc5e8b0662d02fd58cad3" }, "downloads": -1, "filename": "wcfg-6.tar.gz", "has_sig": false, "md5_digest": "118d92a62ef23172a6a90358f6ea53f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10641, "upload_time": "2014-11-27T11:03:26", "url": "https://files.pythonhosted.org/packages/48/07/d988d419924cb37a988c8962893af1706c44b7a85acdbb3991102e6b8ce9/wcfg-6.tar.gz" } ] }