{ "info": { "author": "Jonathan Eunice", "author_email": "jonathan.eunice@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "\n| |travisci| |version| |versions| |impls| |wheel| |coverage|\n\n.. |travisci| image:: https://travis-ci.org/jonathaneunice/items.svg?branch=master\n :alt: Travis CI build status\n :target: https://travis-ci.org/jonathaneunice/items\n\n.. |version| image:: http://img.shields.io/pypi/v/items.svg?style=flat\n :alt: PyPI Package latest release\n :target: https://pypi.python.org/pypi/items\n\n.. |versions| image:: https://img.shields.io/pypi/pyversions/items.svg\n :alt: Supported versions\n :target: https://pypi.python.org/pypi/items\n\n.. |impls| image:: https://img.shields.io/pypi/implementation/items.svg\n :alt: Supported implementations\n :target: https://pypi.python.org/pypi/items\n\n.. |wheel| image:: https://img.shields.io/pypi/wheel/items.svg\n :alt: Wheel packaging support\n :target: https://pypi.python.org/pypi/items\n\n.. |coverage| image:: https://img.shields.io/badge/test_coverage-100%25-6600CC.svg\n :alt: Test line coverage\n :target: https://pypi.python.org/pypi/items\n\nAttributes are the most straightforward and convenient to access composite data\nin many situations. ``item.name`` is neater, more readable, and more concise\nthan the indexing style ``item['name']`` typical of dictionaries. Having\nattribute access often is the difference between being able to easily\nde-reference a component of ``item`` directly and deciding to store that\nattribute in a completely separate variable for clarity (``item_name =\nitem['name']``).\n\nIn traversing data structures from XML, JSON, and other typically-nested data\nsources, concise direct access can clean up code considerably.\n\nItems\n-----\n\n``items`` therefore provides ``Item``, a convenient attribute-accessible ``dict`` subclass,\nplus helper functions.\n\n``itemize``, for example, helps iterate through a sequence of dictionaries, as often found\nin JSON processing: Each record is handed back as an ``Item`` rather than a Python\n``dict``.\n\nA typical progression would be from:\n\n.. code-block:: python\n\n for item in data:\n item_name = item['name']\n # ...\n print(item_name)\n\nto\n\n.. code-block:: python\n\n from items import itemize\n\n for item in itemize(data):\n # ...\n print(item.name)\n\nTo process a sequence wholesale, returning a ``list``:\n\n.. code-block:: python\n\n from items import itemize_all\n\n itemize_all(data)\n\nIf you're iterating over a sequence of tuples (or lists) rather than\ndictionaries, you can still use ``itemize`` by providing the field names\nyou wnat assigned.\n\n.. code-block:: python\n\n parser = ...\n for item in itemize(parser, fields='prefix token value'):\n if item.prefix is None and item.token == 'start_array':\n ...\n\nHere each result returned by ``parser`` (typically a Python generator)\nis converted from a tuple (or list) into an ``Item``. Now you have several values\nconveniently packaged in a name-accessible way without having to create\na separate ``namedtuple`` for this result type, and without any need for\ntuple positional indexing.\n\nYou can even do this for a scalar sequence:\n\n for item in itemize('aeiou', fields='vowel'):\n item.value = 20 if item.vowel == 'e' else 15\n\nBeyond graceful handling of single-valued sequences, this example demonstrates\nthe mutability of each ``Item``. ``namedtuples`` are grand as return types,\nbut they cannot be easily extended or annotated by subsequent processing...a\ncommon requirement for many algorithms.\n\nDiving Deeper\n-------------\n\n``Item`` subclasses ``collections.OrderedDict``, so keys are ordered the same\nas when your program first encountered them. The performance overhead of\nordered mappings is minimal in most development contexts, especially in\nexploratory and data-cleanup tasks. Whatever overhead there is is more than\nmade up for by the programming and debugging clarity of not having keys occur\nin seemingly randomized order.\n\n``Item`` s are also permissive, in a way that ``dict`` and its variants usually\nare not: If you access ``item.some_attribute`` where the attribute does\nnot exist, you do **not** raise a ``KeyError``, unlike typical\nPython dictionaries. Instead you get ``Empty``, a designated, false-y\nvalue similar to, but distinct from, ``None``. This is convenient for\nprocessing data which is irregular or not uniformly filled-in, because you do\nnot need the constant \"guard conditions\"--``if`` statements or\n``try``/``except KeyError`` blocks--to protect against cases where this data\nvalue or that is missing. Using ``Empty`` instead of ``None`` preserves your\nability to use ``None`` in cases where it's semantically important. For\nexample, in parsing JSON, ``None`` is returned from JSON's ``null`` value.\n\n``Empty`` objects are infinitely dereferenceable. No matter how many levels of\nindirection, they always just hand back themselves--the same gentle \"nothing\nhere, no exceptions raised\" behavior. You can also iterate over an\n``Empty``--it will simply iterate zero times. This neatly avoids the common\n``TypeError: 'NoneType' object is not iterable`` error messages in instances\nwhere a value can be a list--or ``None`` if the list is not present.\n\n.. code-block:: python\n\n from items import Empty\n\n e = Empty\n assert e[1].method().there[33][0].no.attributes[99].here is Empty\n for x in Empty:\n print('hey!') # never prints, because no such iterations occur\n\nFor more on the background of ``Empty``, see the `nulltype `_\nmodule. A typical use would be:\n\n.. code-block:: python\n\n for item in itemize(data):\n if item.name:\n process(item)\n\nItems that lack names are simply not processed.\n\nThe more nested, complex, and irregular your data structures, the\nmore valuable this becomes.\n\nSerialization and Deserialization\n=================================\n\nBe careful importing data. Popular Python modules for reading JSON, YAML, and\nother formats do not believe mappings are (or should be) ordered. Historically\nand officially, they're not, no matter how ordered they look, no matter that\nother languages such as JavaScript take a different approach, and no matter how\nmany Stack Overflow questions demonstrate that ordered input and output is\nstrongly and broadly desired. Therefore stock input/output modules can cause\ndislocation as data is parsed. Take steps to return ordered mappings from them.\n\n.. code-block:: python\n\n # YAML module that will load into OrderedDict instances, which can then\n # be easily converted to Item instances; based on default PyYAML\n import oyaml as yaml\n data = itemize_all(yaml.load(rawyaml))\n\n # modified call to json.load or json.loads to preserve order by instantiating\n # Item instances rather than dict\n import json\n data = json.loads(rawjson, object_pairs_hook=Item)\n\nCycles\n======\n\nNot currently organized for handling cyclic data structures. Those do not\nappear in processing JSON, XML, and other common data formats, but might\nbe a nice future extension.\n\nInstallation\n============\n\nTo install or upgrade to the latest version::\n\n pip install -U items\n\nSometimes Python installations have different names for ``pip`` (e.g. ``pip``,\n``pip2``, and ``pip3``), and on systems with multiple versions of Python, which\n``pip`` goes with which Python interpreter can become confusing. In those\ncases, try running ``pip`` as a module of the Python version you want to\ninstall under. This can reduce conflicts and confusion::\n\n python3.6 -m pip install -U items\n\nOn Unix, Linux, and macOS you may need to prefix these with ``sudo`` to authorize\ninstallation. In environments without super-user privileges, you may want to\nuse ``pip``'s ``--user`` option, to install only for a single user, rather\nthan system-wide.\n\nTesting\n=======\n\nIf you wish to run the module tests locally, you'll need to install\n``pytest`` and ``tox``. For full testing, you will also need ``pytest-cov``\nand ``coverage``. Then run one of these commands::\n\n tox # normal run - speed optimized\n tox -e py37 # run for a specific version only\n tox -c toxcov.ini # run full coverage tests\n\nNotes\n=====\n\n* Does not work on Python 2. Should work on Python 3 prior to 3.6, but not guaranteed.\n Testing more difficult given different dictionary ordering rules prior to 3.6.\n Since items intended as forward-looking module, not currently worth energy to retrofit\n to archaic dialects.\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://bitbucket.org/jeunice/items", "keywords": "attributes attrs", "license": "Apache License 2.0", "maintainer": "", "maintainer_email": "", "name": "items", "package_url": "https://pypi.org/project/items/", "platform": "", "project_url": "https://pypi.org/project/items/", "project_urls": { "Homepage": "https://bitbucket.org/jeunice/items" }, "release_url": "https://pypi.org/project/items/0.6.5/", "requires_dist": [ "nulltype (>=2.3.1)" ], "requires_python": "", "summary": "Attribute accessible dicts and collections thereof", "version": "0.6.5" }, "last_serial": 4858554, "releases": { "0.5.0": [ { "comment_text": "", "digests": { "md5": "16fdea37639c0400bf5c6adf4a51eee2", "sha256": "19642b76a072a3950107841895d02eb85bcbbd5f677a00d7ccc3f1bc77f9dfe3" }, "downloads": -1, "filename": "items-0.5.0.zip", "has_sig": false, "md5_digest": "16fdea37639c0400bf5c6adf4a51eee2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14455, "upload_time": "2018-05-28T22:40:32", "url": "https://files.pythonhosted.org/packages/3c/43/163c8985c9610c3e6856d93ced2ed3dcf5f0d202c0e25f0d53b90ba5cb03/items-0.5.0.zip" } ], "0.5.1": [ { "comment_text": "", "digests": { "md5": "45b82301d2b7e4e4f42a8cc7dbb688e6", "sha256": "27edc0e0a50fb00a7b16ca92d8942dde4b5121b47a8a4e6d7a3fac8d7cdeb1ca" }, "downloads": -1, "filename": "items-0.5.1.zip", "has_sig": false, "md5_digest": "45b82301d2b7e4e4f42a8cc7dbb688e6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15571, "upload_time": "2018-05-30T22:34:32", "url": "https://files.pythonhosted.org/packages/b5/00/f19745f4132682725c1b61de0b6ea161f06cec2e6b53c1aa26d61e9f1cef/items-0.5.1.zip" } ], "0.5.3": [ { "comment_text": "", "digests": { "md5": "f455328c1c18e51e1fe6664dde74ff24", "sha256": "6bf353ecd04e3a132d48662c8eaec5ba9e8ff4a34d54b7f4a8cd77c0000655f4" }, "downloads": -1, "filename": "items-0.5.3.zip", "has_sig": false, "md5_digest": "f455328c1c18e51e1fe6664dde74ff24", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16401, "upload_time": "2018-06-02T15:46:49", "url": "https://files.pythonhosted.org/packages/6f/87/47dcd68e292e28a21e135b02f76b13ce2f7b44857aa4eda2804971a8c900/items-0.5.3.zip" } ], "0.5.4": [ { "comment_text": "", "digests": { "md5": "fabf5dfbcd085ac6381aeb59cc655c43", "sha256": "d3a7d0716f3278ab6ae78cb4a1c5a1aa121c53c5996b58afed28e4d3fbc5d2ca" }, "downloads": -1, "filename": "items-0.5.4-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "fabf5dfbcd085ac6381aeb59cc655c43", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 9608, "upload_time": "2018-06-05T16:20:36", "url": "https://files.pythonhosted.org/packages/91/ea/f8f0b4602002beaebdb7393667a4bbfd40129ad3dc40a68961c72976abe1/items-0.5.4-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7668096a09a8527933ccba7093d1201f", "sha256": "e6280c1dbb3fb6fdb27937803968c5e22bb122669a3646eb1bb4afe746902c09" }, "downloads": -1, "filename": "items-0.5.4.zip", "has_sig": false, "md5_digest": "7668096a09a8527933ccba7093d1201f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15911, "upload_time": "2018-06-05T16:20:33", "url": "https://files.pythonhosted.org/packages/34/d3/2ad65fd10dd1d8a6d67ee233a71f12530c122149dbdfe47bd1521134f30a/items-0.5.4.zip" } ], "0.5.5": [ { "comment_text": "", "digests": { "md5": "f3960892360a390e0170734df136d675", "sha256": "acb815e8b8892bdf7951cd78afddeeb29522f13f81b9ffbea0c5442dee5ee6f4" }, "downloads": -1, "filename": "items-0.5.5-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "f3960892360a390e0170734df136d675", "packagetype": "bdist_wheel", "python_version": "3.6", "requires_python": null, "size": 9564, "upload_time": "2018-07-03T10:57:15", "url": "https://files.pythonhosted.org/packages/36/5b/5d3710b57a4f242824ac7356dbf75cf5dc5c2a608315282d86b483834603/items-0.5.5-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "7d296148efe2d991d9d609d5f32caf17", "sha256": "c3eaf006b274f5498cdb95a33edba0cbb378e35016149702636c56114245b847" }, "downloads": -1, "filename": "items-0.5.5.zip", "has_sig": false, "md5_digest": "7d296148efe2d991d9d609d5f32caf17", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15847, "upload_time": "2018-07-03T10:57:13", "url": "https://files.pythonhosted.org/packages/13/87/f5e7cdc332fae61ae72473574e04232faffd13a4a03e38027bd06d70bacf/items-0.5.5.zip" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "7eabbc8a9c8df92c62d4551ff4872209", "sha256": "c3faff615ef92ea769e95ab6617071ddd9cbf1763293ee7f0d4817bdd22d9e7e" }, "downloads": -1, "filename": "items-0.6.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "7eabbc8a9c8df92c62d4551ff4872209", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 10931, "upload_time": "2019-02-22T15:20:49", "url": "https://files.pythonhosted.org/packages/6f/68/d95cb6294c35dc8e21eac43b0277cc175d7e958123f2982ccc062bfd3483/items-0.6.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "21d396acee3ad6f9caf6058ab4103057", "sha256": "a18c6b41d39c6f9f773dd4fb79d38e1776408deb89c045bf26c5630a7b20db58" }, "downloads": -1, "filename": "items-0.6.0-py3-none-any.whl", "has_sig": false, "md5_digest": "21d396acee3ad6f9caf6058ab4103057", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10645, "upload_time": "2019-02-22T15:20:50", "url": "https://files.pythonhosted.org/packages/c4/14/d9715f0c8016d1bb1bd4e852b5612bfea4989182f129354b35961775ea85/items-0.6.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "160a8ee2a71baf711003af9c4f841c66", "sha256": "5f0c8bda6d6e089d612db0f5ed72df3da15b25cc002fc14a66f62d039a26d7b1" }, "downloads": -1, "filename": "items-0.6.0.zip", "has_sig": false, "md5_digest": "160a8ee2a71baf711003af9c4f841c66", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18470, "upload_time": "2019-02-22T15:20:51", "url": "https://files.pythonhosted.org/packages/63/63/d6d3d31af564bb2bd2080a5a83ba37f88bb50be6b9aa900d91741e609a17/items-0.6.0.zip" } ], "0.6.1": [ { "comment_text": "", "digests": { "md5": "d791cf794f89d08f2b84a036a0d70f8d", "sha256": "313b5014ef64c9c0db24e9cfb8f30030e390bbbca2de0e295e71d08e37d2a851" }, "downloads": -1, "filename": "items-0.6.1-py3-none-any.whl", "has_sig": false, "md5_digest": "d791cf794f89d08f2b84a036a0d70f8d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10645, "upload_time": "2019-02-22T15:30:00", "url": "https://files.pythonhosted.org/packages/41/bd/5f648c5e74b7589af97c85be2f0c4ac29b39e02407be11680fc865a91b9d/items-0.6.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "b72189a880c60bf0bd0b4912b8d62404", "sha256": "1559729522097ea669a020c11a972c228102ac9d25b5a021c7b625a69640d702" }, "downloads": -1, "filename": "items-0.6.1.tar.gz", "has_sig": false, "md5_digest": "b72189a880c60bf0bd0b4912b8d62404", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8744, "upload_time": "2019-02-22T15:30:01", "url": "https://files.pythonhosted.org/packages/6c/59/ff8708f10ad9d0dae0240d60613dfa47b8bf2c2feef89bfa3db4e69a9e51/items-0.6.1.tar.gz" } ], "0.6.5": [ { "comment_text": "", "digests": { "md5": "72fc5a8f71ed9e58482661b2aafcf20d", "sha256": "865ab5ed9782f979e3d3984a18d8233aea77f88e24d54a1f1d29d3d22ef31ad9" }, "downloads": -1, "filename": "items-0.6.5-py3-none-any.whl", "has_sig": false, "md5_digest": "72fc5a8f71ed9e58482661b2aafcf20d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10809, "upload_time": "2019-02-23T15:40:17", "url": "https://files.pythonhosted.org/packages/26/d9/6aab567263af8760e26a43793260776283f9b2d2a540c99a8a9459af43f3/items-0.6.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5b2a2c26929ded028a5183981723a3c6", "sha256": "ad7fb0b8369c5ea1b1e8b83104210cfff39710e6fa794659cab12f856abae393" }, "downloads": -1, "filename": "items-0.6.5.tar.gz", "has_sig": false, "md5_digest": "5b2a2c26929ded028a5183981723a3c6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9239, "upload_time": "2019-02-23T15:40:18", "url": "https://files.pythonhosted.org/packages/ef/ee/cd1171db6e0168b4b26678617eb5b3a1fc4b1dfa6ef365fcb60a1799e364/items-0.6.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "72fc5a8f71ed9e58482661b2aafcf20d", "sha256": "865ab5ed9782f979e3d3984a18d8233aea77f88e24d54a1f1d29d3d22ef31ad9" }, "downloads": -1, "filename": "items-0.6.5-py3-none-any.whl", "has_sig": false, "md5_digest": "72fc5a8f71ed9e58482661b2aafcf20d", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10809, "upload_time": "2019-02-23T15:40:17", "url": "https://files.pythonhosted.org/packages/26/d9/6aab567263af8760e26a43793260776283f9b2d2a540c99a8a9459af43f3/items-0.6.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5b2a2c26929ded028a5183981723a3c6", "sha256": "ad7fb0b8369c5ea1b1e8b83104210cfff39710e6fa794659cab12f856abae393" }, "downloads": -1, "filename": "items-0.6.5.tar.gz", "has_sig": false, "md5_digest": "5b2a2c26929ded028a5183981723a3c6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9239, "upload_time": "2019-02-23T15:40:18", "url": "https://files.pythonhosted.org/packages/ef/ee/cd1171db6e0168b4b26678617eb5b3a1fc4b1dfa6ef365fcb60a1799e364/items-0.6.5.tar.gz" } ] }