Python-ACK
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:
python -m python_ack "apple" /path/to/search
Help:
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:
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 .
cd /tests
python test.py
Local cli run
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:
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
Metadata
Release files for python-ack 0.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python-ack-0.0.2.tar.gz | 9.5 kB | Without provenance | Details for python-ack-0.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_ack-0.0.2-py3-none-any.whl | Python 3 | none | any | Details for python_ack-0.0.2-py3-none-any.whl |
Total release size: 18.5 kB
Release files / python-ack-0.0.2.tar.gz
| Download URL | python-ack-0.0.2.tar.gz |
|---|---|
| Size | 9.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8272356c5538208aa85c26c5ad1faddb5cf195f96e51b68b1db1fcef5243a284
|
|
BLAKE2b-256 checksum How to use checksums |
fc45d6fd8ce1bfa4ee6a3cfb323fac4ed778522d0fc18f7fa1a3dddeb7660519
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Release files / python_ack-0.0.2-py3-none-any.whl
| Download URL | python_ack-0.0.2-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fb97a4fc9b5a0e2119247545a8de06a58848586488f3b2bb8909c91c066126ca
|
|
BLAKE2b-256 checksum How to use checksums |
b13ad6f860b25ed78d46fb176f394ccb41304ef2fa107af4e69fbd6d3e809a42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.18
|
Security for python-ack 0.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.