{
"info": {
"author": "Shubham Dalvi",
"author_email": "shubham.dalvi97@gmail.com",
"bugtrack_url": null,
"classifiers": [
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.4",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Topic :: Software Development :: Libraries :: Python Modules"
],
"description": "# \u2115\ud835\udd56\ud835\udd64\ud835\udd65\ud835\udd56\ud835\udd55\ud835\udd3d\ud835\udd56\ud835\udd65\ud835\udd54\ud835\udd59\n[](https://travis-ci.org/saintlyzero/NestedFetch)  \n\n## Outline\n\n1. [Overview](#overview)\n2. [Installation](#installation)\n3. [Usage](#usage)\n4. [Examples](#examples)\n 1. [Fetch Value](#fetch-data)\n 2. [Set Value](#set--update--data)\n 3. [Flatten Nested Lists](#flatten-nested-lists)\n5. [How to Contribute](#how-to-contribute)\n\n## Overview\n- **NestedFetch** provides syntactic sugar \ud83c\udf6c to deal with a nested python `dictionary` or a nested `list` \ud83d\udc0d\n- You can `get`, `set`, `update` and `flatten` values from a deeply nested dictionary or a list with a more concise, easier and a `KeyError`, `IndexError` free way \ud83d\ude0c\n\n```python\ndata = {\n \"league\": \"Champions League\",\n \"matches\": [\n {\n \"match_id\": \"match_1\",\n \"goals\": [\n {\n \"time\": 13,\n \"scorrer\": \"Lionel Messi\",\n \"assist\": \"Luis Suarez\"\n },\n {\n \"time\": 78,\n \"scorrer\": \"Luis Suarez\",\n \"assist\": \"Ivan Rakitic\"\n }]\n },\n {\n \"match_id\": \"match_2\",\n \"goals\": [\n {\n \"time\": 36,\n \"scorrer\": \"C. Ronaldo\",\n \"assist\": \"Luka Modric\"\n }]\n }]\n }\n```\n\n|  |  |\n|--|--|\n|  |\n## Installation\n\n**NestedFetch** works with Python3.
You can directly install it via **pip**
\n\n```sh\n$ pip3 install nestedfetch\n```\n\n## Usage\n\nImport the methods from the package. \n\n```python3\nfrom nestedfetch import nested_get, nested_set\n```\n\nNo need to instantiate any object, just use the methods specifying valid parameters.\n\n## Examples\n\n### Fetch Data\n\n```python\nnested_get(data, keys, default=None, flatten=False)\n\n@Arguments\ndata : dict / list\nkeys => List of sequential keys leading to the desired value to fetch\ndefault => Specifies the default value to be returned if any specified key is not present. If not specified, it will be None\nflatten => Specifies whether to flatten the returned value\n\n@Return\nReturns the fetched value if it exists, or returns specified default value\n```\n\n- **Fetch** simple nested data :\n\n```python\ndata = {\n 'name': 'Jesse Pinkman',\n 'details': {\n 'address':{\n 'city': 'Albuquerque'\n }\n }\n }\nres = nested_get(data,['details','address','city'])\n# res = Albuquerque\n```\n\n- **Fetch** simple nested data with `default` value:\n\n```python\ndata = {\n 'name': 'Jesse Pinkman',\n 'details': {\n 'address':{\n 'city': 'Albuquerque'\n }\n }\n }\nres = nested_get(data,['details','address','state'], default=-1)\n# res = -1\n```\n\n- **Fetch** nested data:\n\n```python\ndata = {\n 'name': 'Jesse Pinkman',\n 'details': {\n 'address':[{\n 'city': 'Albuquerque'\n },{\n 'city': 'El Paso'\n }]\n }\n }\nres = nested_get(data,['details','address','city'])\n# res = ['Albuquerque','El Paso']\n```\n\n- **Fetch** nested data with `default` value:\n\n```python\ndata = {\n 'name': 'Jesse Pinkman',\n 'details': {\n 'address':[{\n 'city': 'Albuquerque'\n },{\n 'city': 'El Paso'\n },{\n 'state': 'New Mexico'\n }]\n }\n }\nres = nested_get(data,['details','address','city'], default= None)\n# res = ['Albuquerque','El Paso', None]\n```\n\n- **Fetch** nested data by specifing `index`:\n\n```python\ndata = {\n 'name': 'Walter White',\n 'details': {\n 'address':[{\n 'city': 'Albuquerque'\n },{\n 'city': 'El Paso'\n }]\n }\n }\nres = nested_get(data,['details','address','city', 0])\n# res = Albuquerque\n```\n\n- **Fetch** nested data without `flatten`:\n\n```python\ndata = {\n \"league\": \"Champions League\",\n \"matches\": [\n {\n \"match_id\": \"match_1\",\n \"goals\": [\n {\n \"time\": 13,\n \"scorrer\": \"Lionel Messi\",\n \"assist\": \"Luis Suarez\"\n },\n {\n \"time\": 78,\n \"scorrer\": \"Luis Suarez\",\n \"assist\": \"Ivan Rakitic\"\n }]\n },\n {\n \"match_id\": \"match_2\",\n \"goals\": [\n {\n \"time\": 36,\n \"scorrer\": \"C. Ronaldo\",\n \"assist\": \"Luka Modric\"\n }]\n }]\n }\nres = nested_get(data,['matches','goals','scorrer'])\n# res = [['Lionel Messi', 'Luis Suarez'], ['C. Ronaldo']]\n```\n\n- **Fetch** nested data with `flatten`:\n\n```python\ndata = {\n \"league\": \"Champions League\",\n \"matches\": [\n {\n \"match_id\": \"match_1\",\n \"goals\": [\n {\n \"time\": 13,\n \"scorrer\": \"Lionel Messi\",\n \"assist\": \"Luis Suarez\"\n },\n {\n \"time\": 78,\n \"scorrer\": \"Luis Suarez\",\n \"assist\": \"Ivan Rakitic\"\n }]\n },\n {\n \"match_id\": \"match_2\",\n \"goals\": [\n {\n \"time\": 36,\n \"scorrer\": \"C. Ronaldo\",\n \"assist\": \"Luka Modric\"\n }]\n }]\n }\nres = nested_get(data,['matches','goals','scorrer'], flatten=True)\n# res = ['Lionel Messi', 'Luis Suarez', 'C. Ronaldo']\n```\n\n### Set / Update Data\n\n```python\nnested_set(data, keys, value, create_missing=False):\n\n@Arguments\ndata => dict / list\nkeys => List of sequential keys leading to the desired value to set / update\nvalue => Specifies the value to set / update\ncreate_missing => Specifies whether to create new key while building up if the specified key does not exists\n\n@Return\nReturns the number of values updated\n```\n\n\n- **Update** value of simple nested data :\n\n```python\ndata = {\n 'name': 'Jesse Pinkman',\n 'details': {\n 'address':{\n 'city': 'Albuquerque'\n }\n }\n }\nres = nested_set(data,['details','address','city'], \"Denver\")\n# res = 1\n\n# data = {\n# 'name': 'Jesse Pinkman',\n# 'details': {\n# 'address':{\n# 'city': 'Denver'\n# }\n# }\n# }\n\n```\n\n- **Update** nested data:\n\n```python\ndata = {\n 'name': 'Jesse Pinkman',\n 'details': {\n 'address':[{\n 'city': 'Albuquerque'\n },{\n 'city': 'El Paso'\n }]\n }\n }\nres = nested_set(data,['details','address','city'], \"Denver\")\n# res = 2\n\n# data = {\n# 'name': 'Jesse Pinkman',\n# 'details': {\n# 'address':[{\n# 'city': 'Denver'\n# },{\n# 'city': 'Denver'\n# }]\n# }\n# }\n```\n\n- **Update** nested data with `index`:\n\n```python\ndata = {\n 'name': 'Jesse Pinkman',\n 'details': {\n 'address':[{\n 'city': 'Albuquerque'\n },{\n 'city': 'El Paso'\n }]\n }\n }\nres = nested_set(data,['details','address',0,'city'], \"Denver\")\n# res = 1\n\n# data = {\n# 'name': 'Jesse Pinkman',\n# 'details': {\n# 'address':[{\n# 'city': 'Denver'\n# },{\n# 'city': 'El Paso'\n# }]\n# }\n# }\n```\n\n- **Set** nested data with `create_missing` :\n\n```python\ndata = {\n 'name': 'Jesse Pinkman',\n 'details': {\n 'address':{\n 'city': 'Albuquerque'\n }\n }\n }\nres = nested_set(data,['details','address','state'], \"New Mexico\", create_missing=True)\n# res = 1\n\n# data = {\n# 'name': 'Jesse Pinkman',\n# 'details': {\n# 'address':{\n# 'city': 'Denver',\n# 'state': 'New Mexico'\n# }\n# }\n# }\n\n```\n\n### Flatten Nested Lists\n\n```python\nflatten_data(data):\n\n@Arguments\ndata => list of list\n\n@Return\nReturns the flattened list\n```\n\n- **Flatten** List of Lists\n\n```python\ndata = [[\n ['This','is'],\n ['flattened', 'data']\n]]\n\nres = flatten_data(data)\n# res = ['This','is','flattened','data']\n```\n\n## How to contribute\n\nContributions are welcome \ud83d\ude07.
Feel free to submit a patch, report a bug \ud83d\udc1b or ask for a feature \ud83d\udc23.
Please open an issue first to encourage and keep track of potential discussions \ud83d\udcdd.",
"description_content_type": "text/markdown",
"docs_url": null,
"download_url": "https://github.com/saintlyzero/NestedFetch/archive/v_012.tar.gz",
"downloads": {
"last_day": -1,
"last_month": -1,
"last_week": -1
},
"home_page": "https://github.com/saintlyzero/NestedFetch",
"keywords": "dict,nested dictionary,nested list,list,flatten,scalpl,nestedfetch,addict,box,Nested Fetch",
"license": "MIT",
"maintainer": "",
"maintainer_email": "",
"name": "nestedfetch",
"package_url": "https://pypi.org/project/nestedfetch/",
"platform": "",
"project_url": "https://pypi.org/project/nestedfetch/",
"project_urls": {
"Download": "https://github.com/saintlyzero/NestedFetch/archive/v_012.tar.gz",
"Homepage": "https://github.com/saintlyzero/NestedFetch"
},
"release_url": "https://pypi.org/project/nestedfetch/0.1.2/",
"requires_dist": null,
"requires_python": "",
"summary": "Syntactic sugar to GET, SET, UPDATE and FLATTEN values from nested dictionaries and nested lists.",
"version": "0.1.2",
"yanked": false,
"yanked_reason": null
},
"last_serial": 6036827,
"releases": {
"0.1": [
{
"comment_text": "",
"digests": {
"md5": "d193472fc208af425b8e45134b8d933e",
"sha256": "db5dd4071541b970c27b034451dce97a062246d106821ff42696275940704fc5"
},
"downloads": -1,
"filename": "nestedfetch-0.1.tar.gz",
"has_sig": false,
"md5_digest": "d193472fc208af425b8e45134b8d933e",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4909,
"upload_time": "2019-10-26T20:33:03",
"upload_time_iso_8601": "2019-10-26T20:33:03.720162Z",
"url": "https://files.pythonhosted.org/packages/7b/c2/2af0adb00c8c6fd62d28b863b532d40eb8d17128ce4f4e716b4129230882/nestedfetch-0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"0.1.1": [
{
"comment_text": "",
"digests": {
"md5": "3932b135366a4bb6dd19b64d205f2bec",
"sha256": "df6c905fb2fc865dafcbcdd01d4ec556b495db696ee813d88d0ea522f3ce5d6a"
},
"downloads": -1,
"filename": "nestedfetch-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "3932b135366a4bb6dd19b64d205f2bec",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4990,
"upload_time": "2019-10-27T12:17:49",
"upload_time_iso_8601": "2019-10-27T12:17:49.521682Z",
"url": "https://files.pythonhosted.org/packages/dd/67/e7fddf33eaa1ce74b57822a48ccf7c65e30a4a7d2233bdad3f0a8abc6d1c/nestedfetch-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"0.1.2": [
{
"comment_text": "",
"digests": {
"md5": "8ec1fd9f84367658ad86b8721fc62569",
"sha256": "19c4b16602965f57f27231350ea3f26822621e8d75a7dcfe1dcedc59666bab7c"
},
"downloads": -1,
"filename": "nestedfetch-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "8ec1fd9f84367658ad86b8721fc62569",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4902,
"upload_time": "2019-10-27T12:34:26",
"upload_time_iso_8601": "2019-10-27T12:34:26.019252Z",
"url": "https://files.pythonhosted.org/packages/74/cc/5b1db68f0d012401e01546c61d29b0638ca40133bec0b7109fda2f998af6/nestedfetch-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
]
},
"urls": [
{
"comment_text": "",
"digests": {
"md5": "8ec1fd9f84367658ad86b8721fc62569",
"sha256": "19c4b16602965f57f27231350ea3f26822621e8d75a7dcfe1dcedc59666bab7c"
},
"downloads": -1,
"filename": "nestedfetch-0.1.2.tar.gz",
"has_sig": false,
"md5_digest": "8ec1fd9f84367658ad86b8721fc62569",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 4902,
"upload_time": "2019-10-27T12:34:26",
"upload_time_iso_8601": "2019-10-27T12:34:26.019252Z",
"url": "https://files.pythonhosted.org/packages/74/cc/5b1db68f0d012401e01546c61d29b0638ca40133bec0b7109fda2f998af6/nestedfetch-0.1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"vulnerabilities": []
}