{ "info": { "author": "Adrian Room", "author_email": "ingolemo@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)", "Natural Language :: English", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy", "Topic :: Software Development :: Libraries" ], "description": "\nLenses\n======\n\n.. image:: https://travis-ci.org/ingolemo/python-lenses.svg\n :target: https://travis-ci.org/ingolemo/python-lenses\n\n.. image:: https://codecov.io/gh/ingolemo/python-lenses/branch/master/graph/badge.svg\n :target: https://codecov.io/gh/ingolemo/python-lenses\n\nLenses is a python library that helps you to manipulate large\ndata-structures without mutating them. It is inspired by the lenses in\nHaskell, although it's much less principled and the api is more suitable\nfor python.\n\n\nInstallation\n------------\n\nYou can install the latest version from pypi using pip like so::\n\n pip install lenses\n\nYou can uninstall similarly::\n\n pip uninstall lenses\n\n\nDocumentation\n-------------\n\nThe lenses library makes liberal use of docstrings, which you can access\nas normal with the ``pydoc`` shell command, the ``help`` function in\nthe repl, or by reading the source yourself.\n\nMost users will only need the docs from ``lenses.UnboundLens``. If you\nwant to add hooks to allow parts of the library to work with custom\nobjects then you should check out the ``lenses.hooks`` module. Most of\nthe fancy lens code is in the ``lenses.optics`` module for those who\nare curious how everything works.\n\nSome examples are given in the `examples`_ folder and the `documentation`_\nis available on ReadTheDocs.\n\n.. _examples: examples\n.. _documentation: https://python-lenses.readthedocs.io/en/latest/\n\n\nExample\n-------\n\n>>> from pprint import pprint\n>>> from lenses import lens\n>>>\n>>> data = [{'name': 'Jane', 'scores': ['a', 'a', 'b', 'a']},\n... {'name': 'Richard', 'scores': ['c', None, 'd', 'c']},\n... {'name': 'Zoe', 'scores': ['f', 'f', None, 'f']}]\n... \n>>> format_scores = lens.Each()['scores'].Each().Instance(str).call_upper()\n>>> cheat = lens[2]['scores'].Each().set('a')\n>>>\n>>> corrected = format_scores(data)\n>>> pprint(corrected)\n[{'name': 'Jane', 'scores': ['A', 'A', 'B', 'A']},\n {'name': 'Richard', 'scores': ['C', None, 'D', 'C']},\n {'name': 'Zoe', 'scores': ['F', 'F', None, 'F']}]\n>>>\n>>> cheated = format_scores(cheat(data))\n>>> pprint(cheated)\n[{'name': 'Jane', 'scores': ['A', 'A', 'B', 'A']},\n {'name': 'Richard', 'scores': ['C', None, 'D', 'C']},\n {'name': 'Zoe', 'scores': ['A', 'A', 'A', 'A']}]\n\n\nThe definition of ``format_scores`` means \"for each item in the data take\nthe value with the key of ``'scores'`` and then for each item in that list\nthat is an instance of ``str``, call its ``upper`` method on it\". That one\nline is the equivalent of this code:\n\n::\n\n def format_scores(data):\n results = []\n for entry in data:\n result = {}\n for key, value in entry.items():\n if key == 'scores':\n new_value = []\n for letter in value:\n if isinstance(letter, str):\n new_value.append(letter.upper())\n else:\n new_value.append(letter)\n result[key] = new_value\n else:\n result[key] = value\n results.append(result)\n return results\n\n\nLicense\n-------\n\npython-lenses is free software: you can redistribute it and/or modify it\nunder the terms of the GNU General Public License as published by the\nFree Software Foundation, either version 3 of the License, or (at your\noption) any later version.\n\nThis program is distributed in the hope that it will be useful, but\nWITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General\nPublic License for more details.\n\nYou should have received a copy of the GNU General Public License along\nwith this program. If not, see http://www.gnu.org/licenses/.\n\n\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ingolemo/python-lenses", "keywords": "lens lenses immutable functional optics", "license": "GPLv3+", "maintainer": "", "maintainer_email": "", "name": "lenses", "package_url": "https://pypi.org/project/lenses/", "platform": "", "project_url": "https://pypi.org/project/lenses/", "project_urls": { "Homepage": "https://github.com/ingolemo/python-lenses" }, "release_url": "https://pypi.org/project/lenses/0.5.0/", "requires_dist": [ "singledispatch", "typing ; python_version < \"3\"", "sphinx ; extra == 'docs'", "pyrsistent ; extra == 'optional'", "frozendict ; extra == 'optional'", "pyrsistent ; extra == 'tests'", "frozendict ; extra == 'tests'", "pytest ; extra == 'tests'", "coverage ; extra == 'tests'", "pytest-coverage ; extra == 'tests'", "hypothesis ; extra == 'tests'", "mypy ; (python_version >= \"3.3\" and implementation_name == \"cpython\") and extra == 'tests'" ], "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <4", "summary": "A lens library for python", "version": "0.5.0" }, "last_serial": 4683159, "releases": { "0.1.7": [ { "comment_text": "", "digests": { "md5": "40f0c9e8381a41351db2a950ab26c8ab", "sha256": "5e024e29b1eab8b5bd5c8b415998657f5905833e84e77c3031dab5a951495d70" }, "downloads": -1, "filename": "lenses-0.1.7.tar.gz", "has_sig": true, "md5_digest": "40f0c9e8381a41351db2a950ab26c8ab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23456, "upload_time": "2016-05-29T18:36:16", "url": "https://files.pythonhosted.org/packages/58/6d/78a7b24a29a31b268e73899c648e4b16bb79566f1826b62ca3cd65348f4d/lenses-0.1.7.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "341042223831d9930cf2d6fe568cbe03", "sha256": "a6f80bf99a8616c9adb5fea263cdcea2f1637e0dfc0bdbfbca5b16a424ef3828" }, "downloads": -1, "filename": "lenses-0.2.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "341042223831d9930cf2d6fe568cbe03", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 35998, "upload_time": "2017-09-07T08:35:17", "url": "https://files.pythonhosted.org/packages/90/fe/af07580455ab9b78713c03d28f401df67764bdd43100090a4ffe2c2ce72f/lenses-0.2.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "c9e47632fecd721562b8419beb04816d", "sha256": "cc274681b2efa89f6f4fd9625e417bf83e6546423e8c7220f7da41bf5b2dc2ce" }, "downloads": -1, "filename": "lenses-0.2.0.tar.gz", "has_sig": false, "md5_digest": "c9e47632fecd721562b8419beb04816d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27268, "upload_time": "2017-09-07T08:35:21", "url": "https://files.pythonhosted.org/packages/a7/86/18e503c442e8bd6600b55ebf2ae215c1ce3f28a487dc46919ec0249d33fb/lenses-0.2.0.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "ac289c648a883995af9ec11db17ff8a8", "sha256": "0fe298ac1f51d406eaa69be424c7e263bc8bf99d30fe9fc22b4599af6a04e6a7" }, "downloads": -1, "filename": "lenses-0.2.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "ac289c648a883995af9ec11db17ff8a8", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 36008, "upload_time": "2017-09-07T15:17:38", "url": "https://files.pythonhosted.org/packages/5d/c1/dedb5960390918de4fc7aeda66796c9298babe6a5d4be851b992b0b9952c/lenses-0.2.1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "10a45ef1e37fe3094b52895e1e0a1e8b", "sha256": "2810bdb9835948b6c10df12fbc2b99a932205024a79381c7172a66597368e859" }, "downloads": -1, "filename": "lenses-0.2.1.tar.gz", "has_sig": false, "md5_digest": "10a45ef1e37fe3094b52895e1e0a1e8b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27390, "upload_time": "2017-09-07T15:17:41", "url": "https://files.pythonhosted.org/packages/6a/e5/0aa9d933a238a1a74b6c72e64c9c10f38bb76d0883e0afa424ea9ab22962/lenses-0.2.1.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "bb1550a62ef4f79a6d7ab89c13a091ac", "sha256": "7505331cd8c828c5b251371c503497c4bbfac321dd5bcd895d503739312635f0" }, "downloads": -1, "filename": "lenses-0.3.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "bb1550a62ef4f79a6d7ab89c13a091ac", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 36745, "upload_time": "2017-09-12T19:46:57", "url": "https://files.pythonhosted.org/packages/69/24/01168e274677a9cdaf15cddf8f091851cd319aaf5115efa77f6754478076/lenses-0.3.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "421c8f77389298eeb22d66d85e491f7b", "sha256": "7892d748b06f8ff7e7b475a68197393808dd45613ee69d6ef9eb2ea01dcd5c76" }, "downloads": -1, "filename": "lenses-0.3.0.tar.gz", "has_sig": false, "md5_digest": "421c8f77389298eeb22d66d85e491f7b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27903, "upload_time": "2017-09-12T19:46:58", "url": "https://files.pythonhosted.org/packages/64/7e/53de804129325e7e30219a351143b4e8585c64741889f9d906a7dddfc702/lenses-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "508a28ecdc52fda99717c166650db540", "sha256": "8214f7fe99254c5b2a02b09dffd581dde04c0250e5c85a33d9c2cbae1bb5e2b2" }, "downloads": -1, "filename": "lenses-0.4.0-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "508a28ecdc52fda99717c166650db540", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <4", "size": 39327, "upload_time": "2017-12-01T06:31:43", "url": "https://files.pythonhosted.org/packages/b2/9d/3a454f8981b4be84de66635da00edcefba79368d41e092fa76e6a10b5f1f/lenses-0.4.0-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d306a678c1da14e41179bb2c6ad79267", "sha256": "4ffac58703f79fdecfb040561a73e895a69b14f96c6a00763761d15c6009a393" }, "downloads": -1, "filename": "lenses-0.4.0.tar.gz", "has_sig": false, "md5_digest": "d306a678c1da14e41179bb2c6ad79267", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <4", "size": 29921, "upload_time": "2017-12-01T06:31:45", "url": "https://files.pythonhosted.org/packages/1a/42/2413dbf5640ab1568f25b44ccb2d1150e5a284fa4eb0771f626398f276f2/lenses-0.4.0.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "08e3a28fbaa314d4d4ca302574fc33dc", "sha256": "5fa2892eaf6c1da230423e9b4db70348f8dc6d193f3546fce2f2fe6e9e608dcd" }, "downloads": -1, "filename": "lenses-0.5.0-py3-none-any.whl", "has_sig": false, "md5_digest": "08e3a28fbaa314d4d4ca302574fc33dc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <4", "size": 49725, "upload_time": "2019-01-10T23:35:24", "url": "https://files.pythonhosted.org/packages/9c/5f/e6116e7eafd47b9289478d7abb7180217c1495e5b34cabbdd3bb5062ec96/lenses-0.5.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "998117e3df10f384c694debda1589846", "sha256": "5b318173f2f2884c2c9933855dc5df3c014f7abe90b8ea78f29f809e919b604a" }, "downloads": -1, "filename": "lenses-0.5.0.tar.gz", "has_sig": false, "md5_digest": "998117e3df10f384c694debda1589846", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <4", "size": 31954, "upload_time": "2019-01-10T23:35:27", "url": "https://files.pythonhosted.org/packages/76/43/14e98e10f902796eafedc080b469150b9e1027173f4312a02a42cd32ee80/lenses-0.5.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "08e3a28fbaa314d4d4ca302574fc33dc", "sha256": "5fa2892eaf6c1da230423e9b4db70348f8dc6d193f3546fce2f2fe6e9e608dcd" }, "downloads": -1, "filename": "lenses-0.5.0-py3-none-any.whl", "has_sig": false, "md5_digest": "08e3a28fbaa314d4d4ca302574fc33dc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <4", "size": 49725, "upload_time": "2019-01-10T23:35:24", "url": "https://files.pythonhosted.org/packages/9c/5f/e6116e7eafd47b9289478d7abb7180217c1495e5b34cabbdd3bb5062ec96/lenses-0.5.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "998117e3df10f384c694debda1589846", "sha256": "5b318173f2f2884c2c9933855dc5df3c014f7abe90b8ea78f29f809e919b604a" }, "downloads": -1, "filename": "lenses-0.5.0.tar.gz", "has_sig": false, "md5_digest": "998117e3df10f384c694debda1589846", "packagetype": "sdist", "python_version": "source", "requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, <4", "size": 31954, "upload_time": "2019-01-10T23:35:27", "url": "https://files.pythonhosted.org/packages/76/43/14e98e10f902796eafedc080b469150b9e1027173f4312a02a42cd32ee80/lenses-0.5.0.tar.gz" } ] }