{ "info": { "author": "podhmo", "author_email": "UNKNOWN", "bugtrack_url": null, "classifiers": [ "Programming Language :: Python", "Programming Language :: Python :: Implementation :: CPython" ], "description": "dictremapper\n========================================\n\ndictremapper is remapping dict library\n\n- ordered (important)\n- support inheritance (of mapper)\n- support nested structure\n- (excludes option of each layer)\n\nsimple example\n----------------------------------------\n\n.. code-block:: python\n\n import requests\n import json\n from dictremapper import Remapper, Path\n\n\n class SummaryRemapper(Remapper):\n fullname = Path(\"full_name\")\n url = Path(\"html_url\")\n description = Path(\"description\")\n\n url = \"https://api.github.com/repos/podhmo/dictremapper\"\n data = requests.get(url).json()\n data = SummaryRemapper()(data)\n print(json.dumps(data, indent=2))\n\noutput ::\n\n {\n \"fullname\": \"podhmo/dictremapper\",\n \"url\": \"https://github.com/podhmo/dictremapper\",\n \"description\": \"remapping dict\"\n }\n\n\nsupport inheritance (of mapper)\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n from dictremapper import Remapper, Path\n\n\n class URLRemapper(Remapper):\n url = Path(\"html_url\")\n\n\n class DescriptionRemapper(Remapper):\n fullname = Path(\"full_name\")\n description = Path(\"description\")\n\n\n class SummaryRemapper(URLRemapper, DescriptionRemapper):\n star = Path(\"stargazers_count\")\n\n url = \"https://api.github.com/repos/podhmo/dictremapper\"\n data = requests.get(url).json()\n remapped = SummaryRemapper()(data)\n print(json.dumps(remapped, indent=2))\n\noutput ::\n\n {\n \"url\": \"https://github.com/podhmo/dictremapper\",\n \"fullname\": \"podhmo/dictremapper\",\n \"description\": \"remapping dict\",\n \"star\": 0\n }\n\nIf you want to change order. `ChangeOrder` is helpful, maybe.\n\n.. code-block:: python\n\n from dictremapper import ChangeOrder\n\n\n class SummaryRemapper2(URLRemapper, DescriptionRemapper):\n url = ChangeOrder(URLRemapper.url)\n description = ChangeOrder(DescriptionRemapper.description)\n star = Path(\"stargazers_count\")\n\n remapped = SummaryRemapper2()(data)\n print(json.dumps(remapped, indent=2))\n\noutput ::\n\n {\n \"fullname\": \"podhmo/dictremapper\",\n \"url\": \"https://github.com/podhmo/dictremapper\",\n \"description\": \"remapping dict\",\n \"star\": 0\n }\n\n\nsupport nested structure\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. code-block :: python\n\n class MyMapper3(Remapper):\n body = Path(\"body\", callback=MyMapper())\n children = Path(\"children\", callback=MyMapper2(many=True))\n\n\nexcludes option of each layer\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. code-block :: python\n\n class MyMapper3(Remapper):\n body = Path(\"body\", callback=MyMapper())\n children = Path(\"children\", callback=MyMapper2(many=True, excludes=[\"object.name\", \"object.age\", \"id\"]))\n\n MyMapper3(excludes=[\"children.object.description\", \"body\"])(d)", "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/podhmo/dictremapper", "keywords": "dict,remapping,structure", "license": "mit", "maintainer": null, "maintainer_email": null, "name": "dictremapper", "package_url": "https://pypi.org/project/dictremapper/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/dictremapper/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/podhmo/dictremapper" }, "release_url": "https://pypi.org/project/dictremapper/0.0.2/", "requires_dist": null, "requires_python": null, "summary": "remapping dict", "version": "0.0.2" }, "last_serial": 1829486, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "b105b195ce6875ed0c2bc37897279845", "sha256": "359c571cac381e070256a2eb15831e2c1450780dfd76d0a21e9e8f6b6ce74ade" }, "downloads": -1, "filename": "dictremapper-0.0.1.tar.gz", "has_sig": false, "md5_digest": "b105b195ce6875ed0c2bc37897279845", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2775, "upload_time": "2015-11-23T14:22:26", "url": "https://files.pythonhosted.org/packages/9e/42/b9319a3a46cde77a81c6392c3729b382f5db959173e76453bc0dfced5192/dictremapper-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "879fb90d0d956be6dc342be6c69803f8", "sha256": "abed7ae70a003244d45fd67b477aa83424086d71d6730b44ad975c32c9bf6124" }, "downloads": -1, "filename": "dictremapper-0.0.2.tar.gz", "has_sig": false, "md5_digest": "879fb90d0d956be6dc342be6c69803f8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3673, "upload_time": "2015-11-23T14:43:06", "url": "https://files.pythonhosted.org/packages/05/f0/b9710c6c852b7b75f270598c92d3178dc7cc1c756ec07ccefce9276453c6/dictremapper-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "879fb90d0d956be6dc342be6c69803f8", "sha256": "abed7ae70a003244d45fd67b477aa83424086d71d6730b44ad975c32c9bf6124" }, "downloads": -1, "filename": "dictremapper-0.0.2.tar.gz", "has_sig": false, "md5_digest": "879fb90d0d956be6dc342be6c69803f8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3673, "upload_time": "2015-11-23T14:43:06", "url": "https://files.pythonhosted.org/packages/05/f0/b9710c6c852b7b75f270598c92d3178dc7cc1c756ec07ccefce9276453c6/dictremapper-0.0.2.tar.gz" } ] }