python-ack


Namepython-ack JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/klich3/python-ack
SummaryPython-ACK is a code-searching tool, similar to grep but optimized for programmers searching large trees of source code.
upload_time2024-01-04 11:02:27
maintainer
docs_urlNone
authorAnton Sychev
requires_python>=3.8
licenseThe MIT License (MIT) Copyright (c) <2024> Anton Sychev Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords regexp file document search
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python-ACK

![Python Version](https://img.shields.io/badge/python-3.6%2B-blue.svg)
![License](https://img.shields.io/badge/license-MIT-blue.svg)

ACK is a code-searching tool, similar to grep but optimized for programmers searching large trees of source code.

## Features
- Multi-process search
- Exclude specific paths and patterns
- ANSI color-coded output
- Search in symlinks (Python >= 2.6 only)
- Execution statistics

---

# Usage as script
***Options***
* --num-processes, -n: Number of processes to use (default: 4).
* --exclude-path, -x: Exclude paths matching EXCLUDE_PATH_PATTERN.
* --follow-links, -f: Follow symlinks (Python >= 2.6 only).
* --exclude-search, -s: Exclude results matching EXCLUDE_PATTERN.
* --no-colors, -c: Don't print ANSI colors like ACK tool.
* --statistics, -t: On final print execution statistics.


### Example

***Search:***
```shell
python -m python_ack "apple" /path/to/search
```

***Help:***
```shell
python -m python_ack --help
```

```
usage: python-ack [-h] [--num-processes NUM_PROCESSES] [--exclude-path EXCLUDE_PATH_PATTERN] [--follow-links] [--exclude-search EXCLUDE_PATTERN]
                  [--no-colors] [--statistics]
                  PATTERN [DIRECTORY]

Python-ACK is a code-searching tool, similar to grep but optimized for programmers searching large trees of source code.

positional arguments:
  PATTERN               Pattern to search for.
  DIRECTORY             A directory to search.

options:
  -h, --help            show this help message and exit
  --num-processes NUM_PROCESSES, -n NUM_PROCESSES
                        Number of processes to use.
  --exclude-path EXCLUDE_PATH_PATTERN, -x EXCLUDE_PATH_PATTERN
                        Exclude paths matching EXCLUDE_PATH_PATTERN.
  --follow-links, -f    Follow symlinks (Python >= 2.6 only).
  --exclude-search EXCLUDE_PATTERN, -s EXCLUDE_PATTERN
                        Exclude results matching EXCLUDE_PATTERN.
  --no-colors, -c       Don't print ANSI colors like ACK tool.
  --statistics, -t      On final print excecution statistics.

```

---

## Ack Class Attributes

The `ack` class in Python-ACK has several attributes that allow you to customize the behavior of the search tool. Here's a brief description of each attribute:

- **path**: The path to the directory where the search will be performed.
- **regexp**: The regular expression pattern to search for in files.
- **num_processes**: Number of processes to use for the multi-process search (default: 4).
- **exclude_paths_regexp**: A list of regular expressions to exclude paths from the search.
- **follow_links**: Boolean flag indicating whether to follow symbolic links (Python >= 2.6 only).
- **exclude_regexp**: A list of regular expressions to exclude results matching specific patterns in files.
- **use_ansi_colors**: Boolean flag indicating whether to use ANSI colors in the output.
- **search_function**: Custom search function to be used for searching in files.
- **return_as_dict**: Boolean flag indicating whether to return the result as a dictionary.


### Example Usage:

```python
from python_ack.ack import ack

def main():
    folder = "/path/to/search"
    instance = ack(
        path=folder,
        regexp="apple",
        exclude_regexp=["solor"],
        num_processes=10,
        exclude_paths_regexp=["exclude_*"],
        follow_links=False,
        use_ansi_colors=False
    )
    instance.process_folders()
    instance.print_result()

    duration = instance.get_duration()
    if duration is not None:
        print(f"\nComplete in {duration}ms.")

if __name__ == "__main__":
    main()

```

---

### Local dev

In root folder run `pip install -e .`

```shell
cd /tests
python test.py
```

## Local cli run

```shell
python -m python_ack
```

---

# Acknowledgements
* Author: Anton Sychev
* Email: anton@sychev.xyz


# License
This project is licensed under the MIT License - see the LICENSE file for details.


Make sure to replace "/path/to/search" with your actual path. You can also customize the badges, add more sections, and provide more details based on your project's needs.


---

### Publish to Pypi

***Local:***
```shell
python -m pip install build twine
python3 -m build   
twine check dist/*
twine upload dist/*
```

***Live:***
No need do nothing GitHub have Workflow action its publish auto

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/klich3/python-ack",
    "name": "python-ack",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "regexp,file,document,search",
    "author": "Anton Sychev",
    "author_email": "Anton Sychev <anton@sychev.xyz>",
    "download_url": "https://files.pythonhosted.org/packages/fc/45/d6fd8ce1bfa4ee6a3cfb323fac4ed778522d0fc18f7fa1a3dddeb7660519/python-ack-0.0.2.tar.gz",
    "platform": null,
    "description": "# Python-ACK\n\n![Python Version](https://img.shields.io/badge/python-3.6%2B-blue.svg)\n![License](https://img.shields.io/badge/license-MIT-blue.svg)\n\nACK is a code-searching tool, similar to grep but optimized for programmers searching large trees of source code.\n\n## Features\n- Multi-process search\n- Exclude specific paths and patterns\n- ANSI color-coded output\n- Search in symlinks (Python >= 2.6 only)\n- Execution statistics\n\n---\n\n# Usage as script\n***Options***\n* --num-processes, -n: Number of processes to use (default: 4).\n* --exclude-path, -x: Exclude paths matching EXCLUDE_PATH_PATTERN.\n* --follow-links, -f: Follow symlinks (Python >= 2.6 only).\n* --exclude-search, -s: Exclude results matching EXCLUDE_PATTERN.\n* --no-colors, -c: Don't print ANSI colors like ACK tool.\n* --statistics, -t: On final print execution statistics.\n\n\n### Example\n\n***Search:***\n```shell\npython -m python_ack \"apple\" /path/to/search\n```\n\n***Help:***\n```shell\npython -m python_ack --help\n```\n\n```\nusage: python-ack [-h] [--num-processes NUM_PROCESSES] [--exclude-path EXCLUDE_PATH_PATTERN] [--follow-links] [--exclude-search EXCLUDE_PATTERN]\n                  [--no-colors] [--statistics]\n                  PATTERN [DIRECTORY]\n\nPython-ACK is a code-searching tool, similar to grep but optimized for programmers searching large trees of source code.\n\npositional arguments:\n  PATTERN               Pattern to search for.\n  DIRECTORY             A directory to search.\n\noptions:\n  -h, --help            show this help message and exit\n  --num-processes NUM_PROCESSES, -n NUM_PROCESSES\n                        Number of processes to use.\n  --exclude-path EXCLUDE_PATH_PATTERN, -x EXCLUDE_PATH_PATTERN\n                        Exclude paths matching EXCLUDE_PATH_PATTERN.\n  --follow-links, -f    Follow symlinks (Python >= 2.6 only).\n  --exclude-search EXCLUDE_PATTERN, -s EXCLUDE_PATTERN\n                        Exclude results matching EXCLUDE_PATTERN.\n  --no-colors, -c       Don't print ANSI colors like ACK tool.\n  --statistics, -t      On final print excecution statistics.\n\n```\n\n---\n\n## Ack Class Attributes\n\nThe `ack` class in Python-ACK has several attributes that allow you to customize the behavior of the search tool. Here's a brief description of each attribute:\n\n- **path**: The path to the directory where the search will be performed.\n- **regexp**: The regular expression pattern to search for in files.\n- **num_processes**: Number of processes to use for the multi-process search (default: 4).\n- **exclude_paths_regexp**: A list of regular expressions to exclude paths from the search.\n- **follow_links**: Boolean flag indicating whether to follow symbolic links (Python >= 2.6 only).\n- **exclude_regexp**: A list of regular expressions to exclude results matching specific patterns in files.\n- **use_ansi_colors**: Boolean flag indicating whether to use ANSI colors in the output.\n- **search_function**: Custom search function to be used for searching in files.\n- **return_as_dict**: Boolean flag indicating whether to return the result as a dictionary.\n\n\n### Example Usage:\n\n```python\nfrom python_ack.ack import ack\n\ndef main():\n    folder = \"/path/to/search\"\n    instance = ack(\n        path=folder,\n        regexp=\"apple\",\n        exclude_regexp=[\"solor\"],\n        num_processes=10,\n        exclude_paths_regexp=[\"exclude_*\"],\n        follow_links=False,\n        use_ansi_colors=False\n    )\n    instance.process_folders()\n    instance.print_result()\n\n    duration = instance.get_duration()\n    if duration is not None:\n        print(f\"\\nComplete in {duration}ms.\")\n\nif __name__ == \"__main__\":\n    main()\n\n```\n\n---\n\n### Local dev\n\nIn root folder run `pip install -e .`\n\n```shell\ncd /tests\npython test.py\n```\n\n## Local cli run\n\n```shell\npython -m python_ack\n```\n\n---\n\n# Acknowledgements\n* Author: Anton Sychev\n* Email: anton@sychev.xyz\n\n\n# License\nThis project is licensed under the MIT License - see the LICENSE file for details.\n\n\nMake sure to replace \"/path/to/search\" with your actual path. You can also customize the badges, add more sections, and provide more details based on your project's needs.\n\n\n---\n\n### Publish to Pypi\n\n***Local:***\n```shell\npython -m pip install build twine\npython3 -m build   \ntwine check dist/*\ntwine upload dist/*\n```\n\n***Live:***\nNo need do nothing GitHub have Workflow action its publish auto\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT)  Copyright (c) <2024> Anton Sychev  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "Python-ACK is a code-searching tool, similar to grep but optimized for programmers searching large trees of source code.",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/klich3/python-ack",
        "Issues": "https://github.com/klich3/python-ack/issues"
    },
    "split_keywords": [
        "regexp",
        "file",
        "document",
        "search"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b13ad6f860b25ed78d46fb176f394ccb41304ef2fa107af4e69fbd6d3e809a42",
                "md5": "e41a1e2d9dfe1fe4973d8f3f3dbf5e36",
                "sha256": "fb97a4fc9b5a0e2119247545a8de06a58848586488f3b2bb8909c91c066126ca"
            },
            "downloads": -1,
            "filename": "python_ack-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e41a1e2d9dfe1fe4973d8f3f3dbf5e36",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 8972,
            "upload_time": "2024-01-04T11:02:25",
            "upload_time_iso_8601": "2024-01-04T11:02:25.746925Z",
            "url": "https://files.pythonhosted.org/packages/b1/3a/d6f860b25ed78d46fb176f394ccb41304ef2fa107af4e69fbd6d3e809a42/python_ack-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fc45d6fd8ce1bfa4ee6a3cfb323fac4ed778522d0fc18f7fa1a3dddeb7660519",
                "md5": "eaa6b03148d7ea7bd3d25140f1b8dbca",
                "sha256": "8272356c5538208aa85c26c5ad1faddb5cf195f96e51b68b1db1fcef5243a284"
            },
            "downloads": -1,
            "filename": "python-ack-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "eaa6b03148d7ea7bd3d25140f1b8dbca",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 9518,
            "upload_time": "2024-01-04T11:02:27",
            "upload_time_iso_8601": "2024-01-04T11:02:27.338122Z",
            "url": "https://files.pythonhosted.org/packages/fc/45/d6fd8ce1bfa4ee6a3cfb323fac4ed778522d0fc18f7fa1a3dddeb7660519/python-ack-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-04 11:02:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "klich3",
    "github_project": "python-ack",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "python-ack"
}
        
Elapsed time: 0.40070s