searchin


Namesearchin JSON
Version 0.2.3 PyPI version JSON
download
home_pagehttps://github.com/NicolasMICAUX/searchin
SummarySearch anything in a live python object, method or variable
upload_time2023-07-26 19:27:20
maintainer
docs_urlNone
authorNicolas Micaux
requires_python>=2.7
license
keywords search debug inspect
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <a name="readme-top"></a>
[![Contributors][contributors-shield]][contributors-url]<!--[![Forks][forks-shield]][forks-url]-->
[![Stargazers][stars-shield]][stars-url]
[![Issues][issues-shield]][issues-url]<!--[![MIT License][license-shield]][license-url]--><!--[![LinkedIn][linkedin-shield]][linkedin-url]-->
[![PyPi version][pypi-shield]][pypi-url]
[![Python 2][python2-shield]][python-url]
[![Python 3][python3-shield]][python-url]


<!-- PROJECT LOGO -->
<br />
<div align="center">

  <a href="https://github.com/NicolasMICAUX/searchin">
    <img src="https://raw.githubusercontent.com/NicolasMICAUX/searchin/main/images/logo.png" alt="Logo" width="160" height="160">
  </a>

  <h3 align="center">Search'In</h3>

  <p align="center">
    Search anything in a live python object, method or variable!
    <br />
<!--
    <a href="https://github.com/NicolasMICAUX/searchin"><strong>Explore the docs »</strong></a>
-->
    <br />
    <br />
    <a href="https://github.com/NicolasMICAUX/searchin">View Demo</a>
    ·
    <a href="https://github.com/NicolasMICAUX/searchin/issues">Report Bug</a>
</div>


<!-- ABOUT THE PROJECT -->
## About The Project

<!-- [Screen Shot][product-screenshot] -->

Have you ever spent hours looking for the name of a method or property of a third party library? You are sure that this method/property must exist, but you cannot find it, neither in the documentation, nor in the examples, nor on StackOverflow... You end up scrolling through the source code of the library... So frustrating!

Search'In is a tool that allows you to search in python objects as if you were on Google, just by adding a line in the middle of your code !

<!-- GETTING STARTED -->
## Getting Started
Using Search'In requires no effort at all!

Install Search'In with pip :
```sh
pip install searchin
```

Import Search'In in your code, by adding this line :
```python
import searchin
```

To search for `"name"` in a `Human` class for example, just add this line :
```python
searchin(Human, "name")
```

<!-- USAGE EXAMPLES -->
## Other examples
You can search for any string in any python "entity" : variable, method, object, class, module, etc.

**Search for `"5"` in a `tuple`**
```python
searchin((1, 2, 3, 4, 5, 6, 7, 8, 9), "5")
# >>> "5" found in root.4 : 5
```

**Search for `"mean"` in the method `torch.nn.functional.cross_entropy`**
```python
searchin(torch.nn.functional.cross_entropy, "mean")
# >>> "mean" found in root. : def cross_entropy( [...] reduction: str = "mean", [...], label_smoothing)
```

**Search for `"grad"` in a `torch.nn.Module`**
```python
model = torch.nn.Linear(10, 10)
searchin(model, "grad")
# >>> "grad" found in root.bias
# >>> "grad" found in root.requires_grad_
# >>> "grad" found in root.weight
# >>> "grad" found in root.zero_grad
```

## Advanced features
```python
def searchin(obj,
             query: str,
             max_depth: int = 3,
             top_k_results: int = 10,
             max_iterable_length: int = 100,
             get_raw_result: bool = False) -> Union[List[SearchResult], None]:
    """
    Search an object for a given search term.
    :param obj: The object to search in.
    :param query: What to search for.
    :param max_depth: The maximum depth of the recursive search.
    :param top_k_results: The maximum number of results to return.
    :param max_iterable_length: The maximum length of an iterable to search in.
    :param get_raw_result: If True, return the raw results (of type SearchResult), else just print them.
    :return: A list of search results.
    """
```

<p align="right">(<a href="#readme-top">back to top</a>)</p>



<!-- CONTRIBUTING -->
## Contributing
_(Section in english)_  
I want to add a lot of functionnalities to this project, but I don't have much time to work on it. Contributions are welcome!  

<!-- ROADMAP-->
### Roadmap/todo
<!-- table with columns : task, importance, difficulty, status, description -->
| Task                     | Importance | Difficulty | Contributor on it | Description                                                                                                                                    |
|:-------------------------|------------|------------|-------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------|
| [Fuzzy match](https://github.com/NicolasMICAUX/searchin/discussions/2)              | 5/5        | 2/5        | NOBODY            | _e.g._ : `batch_size` should match when searching `batchsize`.                                                                                 |
| [Link to implem](https://github.com/NicolasMICAUX/searchin/discussions/14)          | 5/5        | 3/5        | NOBODY            | In jupyter notebooks, etc. one should be able to click results to go to implementation.                                                                 |
| [Underline the match](https://github.com/NicolasMICAUX/searchin/discussions/4)      | 4/5        | 1/5        | NOBODY            | _e.g._ : the printed result should be formatted like this : _def cross_entropy( [...] reduction: str = "<u>mean</u>", [...], label_smoothing)_ |
| [Write some tests](https://github.com/NicolasMICAUX/searchin/discussions/5)         | 4/5        | 2/5        | NOBODY            | Write some tests to ensure that the code is working properly.                                                                                  |
| [Find a better algorithm](https://github.com/NicolasMICAUX/searchin/discussions/7)  | 3/5        | 4/5        | NOBODY            | The current algorithm is a BFS (Breadth First Search). Maybe there is a better algorithm to use.                                               |
| [`Searchin...` animation](https://github.com/NicolasMICAUX/searchin/discussions/9)  | 3/5        | 1/5        | NOBODY            | Add a cool animation when searching takes a bit of time.                                                                                       |
| [Profile code](https://github.com/NicolasMICAUX/searchin/discussions/11)             | 2/5        | 1/5        | NOBODY            | Profile the code to see if we can speed it up a little.                                                                                        |
| [Add a CLI](https://github.com/NicolasMICAUX/searchin/discussions/12)                | 1/5        | 2/5        | NOBODY            | Think about the design of a CLI (Command Line Interface) to use Search'In from the terminal.                                                   |

Non-Code contribution :

| Task                     | Importance | Difficulty | Contributor on it | Description                                                                                                                                                           |
|:-------------------------|------------|------------|-------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Adding documentation](https://github.com/NicolasMICAUX/searchin/discussions/6)     | 4/5        | 1/5        | NOBODY            | Add some helpful docstrings, write basic tutorials with real-life scenarios, write a wiki for other contributors to better understand the functioning of the library. |


_For every todo, just click on the link to find the discussion where I describe how I would do it._  
See the [discussions](https://github.com/NicolasMICAUX/searchin/discussions) for a full list of proposed features (and known issues).

<p align="right">(<a href="#readme-top">back to top</a>)</p>

### How to contribute
Contributing is an awesome way to learn, inspire, and help others. Any contributions you make are **greatly appreciated**, even if it's just about styling and best practices.

If you have a suggestion that would make this project better, please fork the repo and create a pull request.  
Don't forget to give the project a star! Thanks again!

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/YourAmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request


## Authors
This library was created by [Nicolas MICAUX](https://github.com/NicolasMICAUX).


<!-- MARKDOWN LINKS & IMAGES -->
<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->
[contributors-shield]: https://img.shields.io/github/contributors/NicolasMICAUX/searchin.svg?style=for-the-badge
[contributors-url]: https://github.com/NicolasMICAUX/searchin/graphs/contributors
[stars-shield]: https://img.shields.io/github/stars/NicolasMICAUX/searchin.svg?style=for-the-badge
[stars-url]: https://github.com/NicolasMICAUX/searchin/stargazers
[issues-shield]: https://img.shields.io/github/issues/NicolasMICAUX/searchin.svg?style=for-the-badge
[issues-url]: https://github.com/NicolasMICAUX/searchin/issues
[pypi-shield]: https://img.shields.io/pypi/v/searchin.svg?style=for-the-badge
[pypi-url]: https://pypi.org/project/searchin/
[python2-shield]: https://img.shields.io/badge/python-2.7+-blue.svg?style=for-the-badge
[python3-shield]: https://img.shields.io/badge/python-3.5+-blue.svg?style=for-the-badge
[python-url]: https://www.python.org/downloads/

[//]: # ([license-shield]: https://img.shields.io/github/license/NicolasMICAUX/searchin.svg?style=for-the-badge)
[//]: # ([license-url]: https://github.com/NicolasMICAUX/searchin/blob/master/LICENSE.txt)
[//]: # ([linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555)
[//]: # ([linkedin-url]: https://linkedin.com/in/othneildrew)
[product-screenshot]: images/screenshot.png


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/NicolasMICAUX/searchin",
    "name": "searchin",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=2.7",
    "maintainer_email": "",
    "keywords": "search,debug,inspect",
    "author": "Nicolas Micaux",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/4a/26/e2503eb0c806dd20271704586e42f139c1f07af2bc180decc7cd7315e8b8/searchin-0.2.3.tar.gz",
    "platform": null,
    "description": "<a name=\"readme-top\"></a>\n[![Contributors][contributors-shield]][contributors-url]<!--[![Forks][forks-shield]][forks-url]-->\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]<!--[![MIT License][license-shield]][license-url]--><!--[![LinkedIn][linkedin-shield]][linkedin-url]-->\n[![PyPi version][pypi-shield]][pypi-url]\n[![Python 2][python2-shield]][python-url]\n[![Python 3][python3-shield]][python-url]\n\n\n<!-- PROJECT LOGO -->\n<br />\n<div align=\"center\">\n\n  <a href=\"https://github.com/NicolasMICAUX/searchin\">\n    <img src=\"https://raw.githubusercontent.com/NicolasMICAUX/searchin/main/images/logo.png\" alt=\"Logo\" width=\"160\" height=\"160\">\n  </a>\n\n  <h3 align=\"center\">Search'In</h3>\n\n  <p align=\"center\">\n    Search anything in a live python object, method or variable!\n    <br />\n<!--\n    <a href=\"https://github.com/NicolasMICAUX/searchin\"><strong>Explore the docs \u00bb</strong></a>\n-->\n    <br />\n    <br />\n    <a href=\"https://github.com/NicolasMICAUX/searchin\">View Demo</a>\n    \u00b7\n    <a href=\"https://github.com/NicolasMICAUX/searchin/issues\">Report Bug</a>\n</div>\n\n\n<!-- ABOUT THE PROJECT -->\n## About The Project\n\n<!-- [Screen Shot][product-screenshot] -->\n\nHave you ever spent hours looking for the name of a method or property of a third party library? You are sure that this method/property must exist, but you cannot find it, neither in the documentation, nor in the examples, nor on StackOverflow... You end up scrolling through the source code of the library... So frustrating!\n\nSearch'In is a tool that allows you to search in python objects as if you were on Google, just by adding a line in the middle of your code !\n\n<!-- GETTING STARTED -->\n## Getting Started\nUsing Search'In requires no effort at all!\n\nInstall Search'In with pip :\n```sh\npip install searchin\n```\n\nImport Search'In in your code, by adding this line :\n```python\nimport searchin\n```\n\nTo search for `\"name\"` in a `Human` class for example, just add this line :\n```python\nsearchin(Human, \"name\")\n```\n\n<!-- USAGE EXAMPLES -->\n## Other examples\nYou can search for any string in any python \"entity\" : variable, method, object, class, module, etc.\n\n**Search for `\"5\"` in a `tuple`**\n```python\nsearchin((1, 2, 3, 4, 5, 6, 7, 8, 9), \"5\")\n# >>> \"5\" found in root.4 : 5\n```\n\n**Search for `\"mean\"` in the method `torch.nn.functional.cross_entropy`**\n```python\nsearchin(torch.nn.functional.cross_entropy, \"mean\")\n# >>> \"mean\" found in root. : def cross_entropy( [...] reduction: str = \"mean\", [...], label_smoothing)\n```\n\n**Search for `\"grad\"` in a `torch.nn.Module`**\n```python\nmodel = torch.nn.Linear(10, 10)\nsearchin(model, \"grad\")\n# >>> \"grad\" found in root.bias\n# >>> \"grad\" found in root.requires_grad_\n# >>> \"grad\" found in root.weight\n# >>> \"grad\" found in root.zero_grad\n```\n\n## Advanced features\n```python\ndef searchin(obj,\n             query: str,\n             max_depth: int = 3,\n             top_k_results: int = 10,\n             max_iterable_length: int = 100,\n             get_raw_result: bool = False) -> Union[List[SearchResult], None]:\n    \"\"\"\n    Search an object for a given search term.\n    :param obj: The object to search in.\n    :param query: What to search for.\n    :param max_depth: The maximum depth of the recursive search.\n    :param top_k_results: The maximum number of results to return.\n    :param max_iterable_length: The maximum length of an iterable to search in.\n    :param get_raw_result: If True, return the raw results (of type SearchResult), else just print them.\n    :return: A list of search results.\n    \"\"\"\n```\n\n<p align=\"right\">(<a href=\"#readme-top\">back to top</a>)</p>\n\n\n\n<!-- CONTRIBUTING -->\n## Contributing\n_(Section in english)_  \nI want to add a lot of functionnalities to this project, but I don't have much time to work on it. Contributions are welcome!  \n\n<!-- ROADMAP-->\n### Roadmap/todo\n<!-- table with columns : task, importance, difficulty, status, description -->\n| Task                     | Importance | Difficulty | Contributor on it | Description                                                                                                                                    |\n|:-------------------------|------------|------------|-------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------|\n| [Fuzzy match](https://github.com/NicolasMICAUX/searchin/discussions/2)              | 5/5        | 2/5        | NOBODY            | _e.g._ : `batch_size` should match when searching `batchsize`.                                                                                 |\n| [Link to implem](https://github.com/NicolasMICAUX/searchin/discussions/14)          | 5/5        | 3/5        | NOBODY            | In jupyter notebooks, etc. one should be able to click results to go to implementation.                                                                 |\n| [Underline the match](https://github.com/NicolasMICAUX/searchin/discussions/4)      | 4/5        | 1/5        | NOBODY            | _e.g._ : the printed result should be formatted like this : _def cross_entropy( [...] reduction: str = \"<u>mean</u>\", [...], label_smoothing)_ |\n| [Write some tests](https://github.com/NicolasMICAUX/searchin/discussions/5)         | 4/5        | 2/5        | NOBODY            | Write some tests to ensure that the code is working properly.                                                                                  |\n| [Find a better algorithm](https://github.com/NicolasMICAUX/searchin/discussions/7)  | 3/5        | 4/5        | NOBODY            | The current algorithm is a BFS (Breadth First Search). Maybe there is a better algorithm to use.                                               |\n| [`Searchin...` animation](https://github.com/NicolasMICAUX/searchin/discussions/9)  | 3/5        | 1/5        | NOBODY            | Add a cool animation when searching takes a bit of time.                                                                                       |\n| [Profile code](https://github.com/NicolasMICAUX/searchin/discussions/11)             | 2/5        | 1/5        | NOBODY            | Profile the code to see if we can speed it up a little.                                                                                        |\n| [Add a CLI](https://github.com/NicolasMICAUX/searchin/discussions/12)                | 1/5        | 2/5        | NOBODY            | Think about the design of a CLI (Command Line Interface) to use Search'In from the terminal.                                                   |\n\nNon-Code contribution :\n\n| Task                     | Importance | Difficulty | Contributor on it | Description                                                                                                                                                           |\n|:-------------------------|------------|------------|-------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Adding documentation](https://github.com/NicolasMICAUX/searchin/discussions/6)     | 4/5        | 1/5        | NOBODY            | Add some helpful docstrings, write basic tutorials with real-life scenarios, write a wiki for other contributors to better understand the functioning of the library. |\n\n\n_For every todo, just click on the link to find the discussion where I describe how I would do it._  \nSee the [discussions](https://github.com/NicolasMICAUX/searchin/discussions) for a full list of proposed features (and known issues).\n\n<p align=\"right\">(<a href=\"#readme-top\">back to top</a>)</p>\n\n### How to contribute\nContributing is an awesome way to learn, inspire, and help others. Any contributions you make are **greatly appreciated**, even if it's just about styling and best practices.\n\nIf you have a suggestion that would make this project better, please fork the repo and create a pull request.  \nDon't forget to give the project a star! Thanks again!\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/YourAmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n\n## Authors\nThis library was created by [Nicolas MICAUX](https://github.com/NicolasMICAUX).\n\n\n<!-- MARKDOWN LINKS & IMAGES -->\n<!-- https://www.markdownguide.org/basic-syntax/#reference-style-links -->\n[contributors-shield]: https://img.shields.io/github/contributors/NicolasMICAUX/searchin.svg?style=for-the-badge\n[contributors-url]: https://github.com/NicolasMICAUX/searchin/graphs/contributors\n[stars-shield]: https://img.shields.io/github/stars/NicolasMICAUX/searchin.svg?style=for-the-badge\n[stars-url]: https://github.com/NicolasMICAUX/searchin/stargazers\n[issues-shield]: https://img.shields.io/github/issues/NicolasMICAUX/searchin.svg?style=for-the-badge\n[issues-url]: https://github.com/NicolasMICAUX/searchin/issues\n[pypi-shield]: https://img.shields.io/pypi/v/searchin.svg?style=for-the-badge\n[pypi-url]: https://pypi.org/project/searchin/\n[python2-shield]: https://img.shields.io/badge/python-2.7+-blue.svg?style=for-the-badge\n[python3-shield]: https://img.shields.io/badge/python-3.5+-blue.svg?style=for-the-badge\n[python-url]: https://www.python.org/downloads/\n\n[//]: # ([license-shield]: https://img.shields.io/github/license/NicolasMICAUX/searchin.svg?style=for-the-badge)\n[//]: # ([license-url]: https://github.com/NicolasMICAUX/searchin/blob/master/LICENSE.txt)\n[//]: # ([linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge&logo=linkedin&colorB=555)\n[//]: # ([linkedin-url]: https://linkedin.com/in/othneildrew)\n[product-screenshot]: images/screenshot.png\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Search anything in a live python object, method or variable",
    "version": "0.2.3",
    "project_urls": {
        "Homepage": "https://github.com/NicolasMICAUX/searchin"
    },
    "split_keywords": [
        "search",
        "debug",
        "inspect"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4a26e2503eb0c806dd20271704586e42f139c1f07af2bc180decc7cd7315e8b8",
                "md5": "0e24f087dec9821aaf394c364829e33a",
                "sha256": "3b92a00812370ee1fd6875e579d2c645e30413c0e296b5965953aca6b101b703"
            },
            "downloads": -1,
            "filename": "searchin-0.2.3.tar.gz",
            "has_sig": false,
            "md5_digest": "0e24f087dec9821aaf394c364829e33a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.7",
            "size": 7762,
            "upload_time": "2023-07-26T19:27:20",
            "upload_time_iso_8601": "2023-07-26T19:27:20.019275Z",
            "url": "https://files.pythonhosted.org/packages/4a/26/e2503eb0c806dd20271704586e42f139c1f07af2bc180decc7cd7315e8b8/searchin-0.2.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-26 19:27:20",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NicolasMICAUX",
    "github_project": "searchin",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "searchin"
}
        
Elapsed time: 0.55609s