{ "info": { "author": "Susam Pal", "author_email": "susam@susam.in", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python :: 3.4", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "DON - Dot Object Notation\n=========================\n\nDON stands for Dot Object Notation. It is a convenient way to write\nsimple configuration files.\n\n.. image:: https://travis-ci.org/susam/don.svg?branch=master\n :target: https://travis-ci.org/susam/don\n\n.. image:: https://img.shields.io/coveralls/susam/don.svg\n :target: https://coveralls.io/r/susam/don\n\n.. contents::\n :backlinks: none\n\nRequirements\n------------\nThis module should be used with Python 3.4 or any later version of\nPython interpreter.\n\nThis module depends only on the Python standard library. It does not\ndepend on any third party libraries.\n\nInstallation\n------------\nYou can install this package using pip3 using the following command. ::\n\n pip3 install don\n\nYou can install this package from source distribution. To do so,\ndownload the latest .tar.gz file from https://pypi.python.org/pypi/don,\nextract it, then open command prompt or shell, and change your current\ndirectory to the directory where you extracted the source distribution,\nand then execute the following command. ::\n\n python3 setup.py install\n\nNote that on a Windows system, you may have to replace ``python3`` with\nthe path to your Python 3 interpreter.\n\nSupport\n-------\nTo report any bugs, or ask any question, please visit\nhttps://github.com/susam/don/issues.\n\nResources\n---------\nHere is a list of useful links about this project.\n\n- `Latest release on PyPI `_\n- `Source code on GitHub `_\n- `Issue tracker on GitHub `_\n- `Changelog on GitHub\n `_\n\nLicense\n-------\nThis is free software. You are permitted to redistribute and use it in\nsource and binary forms, with or without modification, under the terms\nof the Simplified BSD License. See the LICENSE.rst file for the complete\nlicense.\n\nThis software is provided WITHOUT ANY WARRANTY; without even the implied\nwarranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nLICENSE.rst file for the complete disclaimer.\n\n\nTutorial\n========\n\nGetting started\n---------------\nHere is a very simple example of DON. ::\n\n title: Countries\n\n india.capital: New Delhi\n india.demonym: Indian\n india.driving: Left\n\n italy.capital: Rome\n italy.demonym: Italian\n italy.driving: Right\n\nThe above DON specifies three top-level DON attributes (also known as\nroot attributes). They are ``title``, ``india`` and ``italy``. The\n``title`` attribute is a string attribute. The value of ``title`` is\n``Countries``. However, ``india`` and ``italy`` are object attributes.\nThe value of ``india`` is an object which contains three attributes:\n``capital``, ``demonym`` and ``driving``.\n\nThe root object is an object of type ``don.Object``. This is a\ndictionary that supports accessing its keys as attributes as well.\nTherefore, for the above example, ``title``, ``india`` and ``italy`` are\nkeys in the root object. The value of string attributes are of type\n``str``. The value of object attributes are of type ``don.Object``.\n\nThe following Python code demonstrates how the ``don`` module may be\nused to parse the above example DON into a root DON object, and then\naccess the attributes.\n\n.. code:: python\n\n import don\n\n # An example DON\n s = \"\"\"\n title: Countries\n\n india.capital: New Delhi\n india.demonym: Indian\n india.driving: Left\n\n italy.capital: Rome\n italy.demonym: Italian\n italy.driving: Right\n \"\"\"\n\n # Parse DON\n root = don.parse(s)\n\n # Access a root attribute\n print(root.title)\n\n # Access object attributes in various ways\n print(root.india.capital) # As attributes\n print(root['india']['demonym']) # As dictionary keys\n print(root.india['driving']) # In a mixed fashion\n\n # An object attribute is actually a dictionary\n print(root.italy)\n\nHere is the output of the above program. ::\n\n Countries\n New Delhi\n Indian\n Left\n {'driving': 'Right', 'capital': 'Rome', 'demonym': 'Italian'}\n\nThis is all there is to parsing a DON string into an object and\naccessing its attributes.\n\nDON syntax\n----------\nA DON string or DON file contains a list of key value pairs. Each key\nvalue pair is separated by a colon. Here is an example. ::\n\n fruit: mango\n drink: beer\n level: debug\n\nEmpty lines, lines consisting of whitespace characters only and lines\nbeginning with the hash character, i.e. ``#``, are ignored. Therefore,\nlines beginning with ``#`` may be used to write comments. The following\nDON example is equivalent to the previous example. ::\n\n # Eat and drink\n fruit: mango\n drink: beer\n\n # Logging level\n level: debug\n\nFurther, any leading whitespace before a key or a value, and any\ntrailing whitespace after a key or value are ignored. The following DON\nexample is equivalent to the previous example. ::\n\n # Eat and drink\n fruit : mango\n drink: beer\n\n # Logging level\n level:debug\n\nA DON string represents a single object, known as the root object, that\ncontains attributes. For example, when the above example is parsed by\nDON parser, the string is converted into a root object (which we will\ncall as ``root``). This root object in turn contains three attributes\nwith three values. In this case, all three values happen to be strings,\nso these attributes may be called string attributes.\n\nThe keys in DON may be one or more dot separated tokens. Each token must\nbe a valid Python identifier. Here is an example that shows dot\nseparated tokens as keys. ::\n\n process.priority: normal\n process.protocol: tcp\n process.log.file: log.txt\n process.log.level: debug\n process.log.rotate: daily\n\nIn this example, the root object contains an object attribute called\n``process`` which in turn contains two string attributes called\n``priority`` and ``protocol``, and one object attribute called ``log``.\nThe ``log`` attribute in turn contains three string attributes called\n``file``, ``level`` and ``rotate``.\n\nHere is a tree diagram that shows the relationship between the various\nattributes. ::\n\n (root)\n `-- process\n |-- priority\n |-- protocol\n `-- log\n |-- file\n |-- level\n `-- rotate\n\nThis is a DON tree. The root node is known as the root object. The\ninternal nodes are always object attributes. They contain one or more\nother attributes as their values. The leaf nodes are always string\nattributes. They contain strings as their values.\n\nA key may contain one or more empty tokens before any non-empty token.\nAn empty token in a key is equivalent to the corresponding token in its\nprevious key, i.e. the Nth empty token in a key is a synonym for the Nth\ntoken in its previous key. An empty token must appear before any\nnon-empty token. The number of empty tokens in a key must not exceed the\nnumber of tokens in its previous key. According to these rules, the\nfollowing DON example is equivalent to the previous example. ::\n\n process.priority: normal\n .protocol: tcp\n .log.file: log.txt\n ..level: debug\n ..rotate: daily\n\nSince leading and trailing whitespace characters around keys and values\nare ignored, the keys with empty tokens may be indented to improve\nreadability. ::\n\n process.priority: normal\n .protocol: tcp \n .log.file: log.txt\n ..level: debug\n ..rotate: daily\n\nWhen a key is followed by empty value, it only declares the key. It does\nnot define anything. It does not cause the DON tree to be updated.\nDeclaring a key is useful for using empty tokens in the following keys,\nso that the empty tokens in the following keys become synonyms of the\ncorresponding tokens in the declared key. This can improve readability\nquite significantly as shown by the following DON example which is\nequivalent to the previous example. ::\n\n process:\n .priority: normal\n .protocol: tcp \n .log:\n ..file: log.txt\n ..level: debug\n ..rotate: daily", "description_content_type": null, "docs_url": null, "download_url": "https://pypi.python.org/pypi/don", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/susam/don", "keywords": "configuration,serialization", "license": "Simplified BSD License", "maintainer": null, "maintainer_email": null, "name": "don", "package_url": "https://pypi.org/project/don/", "platform": "Any", "project_url": "https://pypi.org/project/don/", "project_urls": { "Download": "https://pypi.python.org/pypi/don", "Homepage": "https://github.com/susam/don" }, "release_url": "https://pypi.org/project/don/0.1.1/", "requires_dist": null, "requires_python": null, "summary": "Dot Object Notation (DON) parser.", "version": "0.1.1" }, "last_serial": 1275958, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "3c4116fb17b9fac460d89400aed98433", "sha256": "b732b38bea53fe7901f8277ce2321d23b4fd5650fa590b6ad2e0c570a3de3910" }, "downloads": -1, "filename": "don-0.1.1.tar.gz", "has_sig": false, "md5_digest": "3c4116fb17b9fac460d89400aed98433", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8627, "upload_time": "2014-10-19T22:48:39", "url": "https://files.pythonhosted.org/packages/61/c0/c489291e9daef066e8825de7625cd13f6b601a6d63d996f3b80934b8f8f4/don-0.1.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "3c4116fb17b9fac460d89400aed98433", "sha256": "b732b38bea53fe7901f8277ce2321d23b4fd5650fa590b6ad2e0c570a3de3910" }, "downloads": -1, "filename": "don-0.1.1.tar.gz", "has_sig": false, "md5_digest": "3c4116fb17b9fac460d89400aed98433", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8627, "upload_time": "2014-10-19T22:48:39", "url": "https://files.pythonhosted.org/packages/61/c0/c489291e9daef066e8825de7625cd13f6b601a6d63d996f3b80934b8f8f4/don-0.1.1.tar.gz" } ] }