{"id":17034686,"url":"https://github.com/randomir/plucky","last_synced_at":"2025-04-12T13:00:24.280Z","repository":{"id":9780982,"uuid":"63280059","full_name":"randomir/plucky","owner":"randomir","description":"Plucking (deep) keys/paths/items safely from Python objects has never been easier.","archived":false,"fork":false,"pushed_at":"2024-04-28T19:25:00.000Z","size":54,"stargazers_count":15,"open_issues_count":24,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-28T20:29:57.122Z","etag":null,"topics":["get","itemgetter","iterator","pluck","safe-get","slice"],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/plucky","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/randomir.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-07-13T21:16:06.000Z","updated_at":"2024-06-05T10:44:17.084Z","dependencies_parsed_at":"2023-01-16T19:15:38.742Z","dependency_job_id":"9ef3a8a2-6a67-412a-8aae-114de02f667b","html_url":"https://github.com/randomir/plucky","commit_stats":{"total_commits":85,"total_committers":3,"mean_commits":"28.333333333333332","dds":"0.16470588235294115","last_synced_commit":"16b7b59aa19d619d8e619dc15dc7eeffc9fe078a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randomir%2Fplucky","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randomir%2Fplucky/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randomir%2Fplucky/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/randomir%2Fplucky/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/randomir","download_url":"https://codeload.github.com/randomir/plucky/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248571938,"owners_count":21126522,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["get","itemgetter","iterator","pluck","safe-get","slice"],"created_at":"2024-10-14T08:44:21.080Z","updated_at":"2025-04-12T13:00:24.254Z","avatar_url":"https://github.com/randomir.png","language":"Python","readme":"plucky: concise deep obj.get()\n==============================\n\n.. image:: https://img.shields.io/pypi/v/plucky.svg\n    :target: https://pypi.python.org/pypi/plucky\n\n.. image:: https://img.shields.io/pypi/l/plucky.svg\n    :target: https://pypi.python.org/pypi/plucky\n\n.. image:: https://img.shields.io/pypi/wheel/plucky.svg\n    :target: https://pypi.python.org/pypi/plucky\n\n.. image:: https://img.shields.io/pypi/pyversions/plucky.svg\n    :target: https://pypi.python.org/pypi/plucky\n\n.. image:: https://api.travis-ci.org/randomir/plucky.svg?branch=master\n    :target: https://travis-ci.org/randomir/plucky\n\n\n``plucky.pluckable`` happily wraps any Python object and allows\nfor chained soft plucking with attribute- and item- getters (e.g. ``.attr``,\n``[\"key\"]``, ``[idx]``, ``[::2]``, or a combination: ``[\"key1\", \"key2\"]``,\nand ``[0, 3:7, ::-1]``; even: ``[\"length\", 0:5, 7]``).\n\n``plucky.pluck`` will allow you to pluck *same as with* ``pluckable``\n(regarding the plucking operations), but accepting a string selector\ninstead of a Python expression.\n\n``plucky.plucks`` enables you to safely extract several-levels deep values by\nusing a concise string selector comprised of dictionary-like keys and list-like\nindices/slices. Stands for *pluck simplified*, since it supports only a subset of\n``pluck`` syntax. It's simpler and a more efficient.\n\n``plucky.merge`` facilitates recursive merging of two data structures, reducing\nleaf values with the provided binary operator.\n\n\nInstallation\n------------\n\n``plucky`` is available as a **zero-dependency** Python package. Install with::\n\n    $ pip install plucky\n\n\nUsage\n-----\n\n.. code-block:: python\n\n    from plucky import pluck, plucks, pluckable, merge\n\n    pluckable(obj).users[2:5, 10:15].name[\"first\", \"middle\"].value\n\n    pluck(obj, 'users[2:5, 10:15].name[\"first\", \"middle\"]')\n\n    plucks(obj, 'users.2:5.name.first')\n\n    merge({\"x\": 1, \"y\": 0}, {\"x\": 2})\n\n\nExamples\n--------\n\n.. code-block:: python\n\n    obj = {\n        'users': [{\n            'uid': 1234,\n            'name': {\n                'first': 'John',\n                'last': 'Smith',\n            }\n        }, {\n            'uid': 2345,\n            'name': {\n                'last': 'Bono'\n            }\n        }, {\n            'uid': 3456\n        }]\n    }\n\n    plucks(obj, 'users.1.name')\n    # -\u003e {'last': 'Bono'}\n\n    plucks(obj, 'users.name.last')\n    # -\u003e ['Smith', 'Bono']\n\n    plucks(obj, 'users.*.name.first')\n    # -\u003e ['John']\n\n    pluckable(obj).users.name.first.value\n    # -\u003e ['John']\n\n    pluckable(obj).users.uid[0, 2, 1].value\n    # -\u003e [1234, 3456, 2345]\n\n    pluckable([datetime.datetime.now(), None, {'month': 8}])[::2].month\n    # -\u003e [5, 8]\n\n    pluckable(obj, skipmissing=False, default='Unnamed').users.name.first.value\n    # -\u003e ['John', 'Unnamed', 'Unnamed']\n\n\nMore Examples! :)\n-----------------\n\n.. code-block:: python\n\n    pluckable(obj).users[:, ::-1].name.last.value\n    # -\u003e ['Smith', 'Bono', 'Bono', 'Smith']\n\n    pluckable(obj).users[:, ::-1].name.last[0, -1].value\n    # -\u003e ['Smith', 'Smith']\n\n    pluck(obj, 'users[:, ::-1].name.last[0, -1]')\n    # -\u003e ['Smith', 'Smith']\n\n    plucks([1, {'val': 2}, 3], 'val')\n    # -\u003e [2]\n\n    plucks([1, {'val': [1,2,3]}, 3], '1.val.-1')\n    # -\u003e 3\n\n    merge({\"x\": 1, \"y\": 0}, {\"x\": 2})\n    # -\u003e {\"x\": 3, \"y\": 0}\n\n    merge({\"a\": [1, 2], \"b\": [1, 2]}, {\"a\": [3, 4], \"b\": [3]})\n    # -\u003e {\"a\": [4, 6], \"b\": [1, 2, 3]}\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frandomir%2Fplucky","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frandomir%2Fplucky","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frandomir%2Fplucky/lists"}