trace-dkey


Nametrace-dkey JSON
Version 0.0.8 PyPI version JSON
download
home_pagehttps://github.com/Agent-Hellboy/trace-dkey
SummaryPython library to trace path of a particular key inside a nested dict
upload_time2024-10-17 13:32:16
maintainerNone
docs_urlNone
authorPrince Roshan
requires_python>=3.9
licenseMIT
keywords tracer dict-key-path-finder
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            trace-dkey
==========

Python library to trace path of a particular key inside a nested dict

.. image:: https://img.shields.io/pypi/v/trace-dkey
   :target: https://pypi.python.org/pypi/trace-dkey/

.. image:: https://github.com/Agent-Hellboy/trace-dkey/actions/workflows/python-app.yml/badge.svg
    :target: https://github.com/Agent-Hellboy/trace-dkey/
    
.. image:: https://img.shields.io/pypi/pyversions/trace-dkey.svg
   :target: https://pypi.python.org/pypi/trace-dkey/

.. image:: https://img.shields.io/pypi/l/trace-dkey.svg
   :target: https://pypi.python.org/pypi/trace-dkey/

.. image:: https://pepy.tech/badge/trace-dkey
   :target: https://pepy.tech/project/trace-dkey

.. image:: https://img.shields.io/pypi/format/trace-dkey.svg
   :target: https://pypi.python.org/pypi/trace-dkey/

.. image:: https://coveralls.io/repos/github/Agent-Hellboy/trace-dkey/badge.svg?branch=main
   :target: https://coveralls.io/github/Agent-Hellboy/trace-dkey?branch=main

Installation
============

For stable version 
   - pip install trace-dkey

For development 
   - git clone https://github.com/Agent-Hellboy/trace-dkey
   - cd trace-dkey 
   - python -m venv .venv 
   - source .venv/bin/activate

Example
=======


you can use the library as ``python3 -m trace_dkey --file=test.json --key=name``, test.json is 

A JSON file containing name as key

.. code:: py

   >>> from trace_dkey import trace
   >>> l={'a':{'b':{'c':{'d':{'e':{'f':1}}}}}}
   >>> print(trace(l,'f'))
   [['a', 'b', 'c', 'd', 'e', 'f']]

   Now you can query it as l['a']['b']['c']['d']['e']['f']

   >>> l['a']['b']['c']['d']['e']['f']
   1

Documentation
=============

For more details, you can refer to the `documentation <https://agent-hellboy.github.io/trace-dkey/>`_.

General Info
============

- The value returned by the `trace` function is an array of paths, where each path is an array of dictionary keys.
- Because of that, the library can be used in a practical way by taking advantage of this format.
- In the example below we use the returned path to iterate over the dictionary keys and print the key value:
  
.. code:: py
 
    from trace_dkey import trace
    l={'a':{'b':{'c':{'d':{'e':{'f':1}}}}}}
 
    paths = trace(l,'f')

    for path in paths:
       dic = l
       for key in path:
          dic = dic[key]
       print(dic)


- This addresses a wide range of questions asked on StackOverflow about key inside a nested dict
- At least 13 duplicate questions can be found on Stackoverflow 
- This can be tracked on https://you.com/search?q=find%20key%20in%20nested%20dictionary%20python
   


| Someone made a nice comparision of this lib(trace-dkey) with one of the famous lib(yamlpath) which is doing the similar thing 



.. image:: /images/img.png
   :width: 600

Contributing
============

Pull requests are welcome. For major changes, please open an issue first
to discuss what you would like to change.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Agent-Hellboy/trace-dkey",
    "name": "trace-dkey",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "tracer, dict-key-path-finder",
    "author": "Prince Roshan",
    "author_email": "princekrroshan01@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c9/9b/2771b68ecbdbd99d0b8c521dbba68b82a1bd185d0fba759edc8db7e19744/trace_dkey-0.0.8.tar.gz",
    "platform": null,
    "description": "trace-dkey\n==========\n\nPython library to trace path of a particular key inside a nested dict\n\n.. image:: https://img.shields.io/pypi/v/trace-dkey\n   :target: https://pypi.python.org/pypi/trace-dkey/\n\n.. image:: https://github.com/Agent-Hellboy/trace-dkey/actions/workflows/python-app.yml/badge.svg\n    :target: https://github.com/Agent-Hellboy/trace-dkey/\n    \n.. image:: https://img.shields.io/pypi/pyversions/trace-dkey.svg\n   :target: https://pypi.python.org/pypi/trace-dkey/\n\n.. image:: https://img.shields.io/pypi/l/trace-dkey.svg\n   :target: https://pypi.python.org/pypi/trace-dkey/\n\n.. image:: https://pepy.tech/badge/trace-dkey\n   :target: https://pepy.tech/project/trace-dkey\n\n.. image:: https://img.shields.io/pypi/format/trace-dkey.svg\n   :target: https://pypi.python.org/pypi/trace-dkey/\n\n.. image:: https://coveralls.io/repos/github/Agent-Hellboy/trace-dkey/badge.svg?branch=main\n   :target: https://coveralls.io/github/Agent-Hellboy/trace-dkey?branch=main\n\nInstallation\n============\n\nFor stable version \n   - pip install trace-dkey\n\nFor development \n   - git clone https://github.com/Agent-Hellboy/trace-dkey\n   - cd trace-dkey \n   - python -m venv .venv \n   - source .venv/bin/activate\n\nExample\n=======\n\n\nyou can use the library as ``python3 -m trace_dkey --file=test.json --key=name``, test.json is \n\nA JSON file containing name as key\n\n.. code:: py\n\n   >>> from trace_dkey import trace\n   >>> l={'a':{'b':{'c':{'d':{'e':{'f':1}}}}}}\n   >>> print(trace(l,'f'))\n   [['a', 'b', 'c', 'd', 'e', 'f']]\n\n   Now you can query it as l['a']['b']['c']['d']['e']['f']\n\n   >>> l['a']['b']['c']['d']['e']['f']\n   1\n\nDocumentation\n=============\n\nFor more details, you can refer to the `documentation <https://agent-hellboy.github.io/trace-dkey/>`_.\n\nGeneral Info\n============\n\n- The value returned by the `trace` function is an array of paths, where each path is an array of dictionary keys.\n- Because of that, the library can be used in a practical way by taking advantage of this format.\n- In the example below we use the returned path to iterate over the dictionary keys and print the key value:\n  \n.. code:: py\n \n    from trace_dkey import trace\n    l={'a':{'b':{'c':{'d':{'e':{'f':1}}}}}}\n \n    paths = trace(l,'f')\n\n    for path in paths:\n       dic = l\n       for key in path:\n          dic = dic[key]\n       print(dic)\n\n\n- This addresses a wide range of questions asked on StackOverflow about key inside a nested dict\n- At least 13 duplicate questions can be found on Stackoverflow \n- This can be tracked on https://you.com/search?q=find%20key%20in%20nested%20dictionary%20python\n   \n\n\n| Someone made a nice comparision of this lib(trace-dkey) with one of the famous lib(yamlpath) which is doing the similar thing \n\n\n\n.. image:: /images/img.png\n   :width: 600\n\nContributing\n============\n\nPull requests are welcome. For major changes, please open an issue first\nto discuss what you would like to change.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python library to trace path of a particular key inside a nested dict",
    "version": "0.0.8",
    "project_urls": {
        "Homepage": "https://github.com/Agent-Hellboy/trace-dkey"
    },
    "split_keywords": [
        "tracer",
        " dict-key-path-finder"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0977ac509ef7ecfbde477dcec77b2018149de6bda3c96da1ca751725a80f249b",
                "md5": "77658aa1d077600c47e68eb30ad190ee",
                "sha256": "a9521d60b1b53ddc79bc10e01556527e3fe74d81ac10671ce0db70ef425cf6a5"
            },
            "downloads": -1,
            "filename": "trace_dkey-0.0.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "77658aa1d077600c47e68eb30ad190ee",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 4872,
            "upload_time": "2024-10-17T13:32:15",
            "upload_time_iso_8601": "2024-10-17T13:32:15.449960Z",
            "url": "https://files.pythonhosted.org/packages/09/77/ac509ef7ecfbde477dcec77b2018149de6bda3c96da1ca751725a80f249b/trace_dkey-0.0.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c99b2771b68ecbdbd99d0b8c521dbba68b82a1bd185d0fba759edc8db7e19744",
                "md5": "9bd1b99d825e869d696be245c3fb6c7e",
                "sha256": "c225a6ebd3da6a37651bdb812d6cc34830cec21cc8b6212da522cd7c28a44011"
            },
            "downloads": -1,
            "filename": "trace_dkey-0.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "9bd1b99d825e869d696be245c3fb6c7e",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 5083,
            "upload_time": "2024-10-17T13:32:16",
            "upload_time_iso_8601": "2024-10-17T13:32:16.406298Z",
            "url": "https://files.pythonhosted.org/packages/c9/9b/2771b68ecbdbd99d0b8c521dbba68b82a1bd185d0fba759edc8db7e19744/trace_dkey-0.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-17 13:32:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Agent-Hellboy",
    "github_project": "trace-dkey",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "trace-dkey"
}
        
Elapsed time: 0.31692s