Greptile
Fast grep implementation in python, with replace features
usage: greptile.py [-h] [-v] [-x EXTENSIONS [EXTENSIONS ...]] [-r] [-l] [-i]
[-g REPLACE_EXPR] [-f REPLACE_EXPR]
expression [file]
file search and replace with regular expressions
positional arguments:
expression regular expression
file file path (or directory if -r is used)
optional arguments:
-h, --help show this help message and exit
-v, --version show program's version number and exit
-x EXTENSIONS [EXTENSIONS ...], --extensions EXTENSIONS [EXTENSIONS ...]
restrict search to file extensions (ex: .py .txt .java
.xml)
-r, --recursive recursively search in path
-l, --list list files matching pattern
-i, --inplace update the file inplace (with -g or -f)
-g REPLACE_EXPR, --replace-global REPLACE_EXPR
global replacement expression
-f REPLACE_EXPR, --replace-first REPLACE_EXPR
first occurrence replacement expression
Why fast?
Because it exclusively uses generators, reptile never allocates big lists, it always processes one line in one file at a time. you can do a search on big files and large directories like / recursively without memory overhead.
Examples:
Search "import" in ./greptile.py :
$ ./greptile.py "import" ./greptile.py
import re
import os
import sys
import argparse
Recursively search from ~/ lines in python files containing Copyright :
$ ./greptile.py -x .py -r "Copyright" ~/
/Users/nic/Library/Android/sdk/platform-tools/systrace/systrace-legacy.py 2: # Copyright (c) 2011 The Chromium Authors. All rights reserved.
/Users/nic/Library/Android/sdk/platform-tools/systrace/systrace.py 2: # Copyright (c) 2011 The Chromium Authors. All rights reserved.
/Users/nic/Library/Android/sdk/platform-tools/systrace/systrace_agent.py 0: # Copyright (c) 2015 The Chromium Authors. All rights reserved.
/Users/nic/Library/Android/sdk/platform-tools/systrace/util.py 0: # Copyright (c) 2015 The Chromium Authors. All rights reserved.
/Users/nic/Library/Android/sdk/platform-tools/systrace/agents/__init__.py 0: # Copyright (c) 2015 The Chromium Authors. All rights reserved.
/Users/nic/Library/Android/sdk/platform-tools/systrace/agents/atrace_agent.py 0: # Copyright (c) 2015 The Chromium Authors. All rights reserved.
...
Replacement & easy grouping with python re.sub syntax :
$ greptile.py "\[(.*)\]\((.*)\)" README.md -g "<a href=\"\2\">\1</a>" | diff -u README.md -
--- README.md 2016-04-19 22:37:20.000000000 +0200
+++ - 2016-04-25 14:54:24.000000000 +0200
@@ -1,4 +1,4 @@
-
+!<a href="https://github.com/google/agera/blob/master/doc/images/agera.png">Agera</a>
Reactive Programming for Android
================================
Api:
import greptile
# Replace "import" by "export" from dir `./`, in all files and these extensions: .py, .xml, .java
greptile.replace('import', 'export', './', '.py', '.xml', '.java')
# Return filenames of all files containing the text "import" from dir `./` and .py, .xml, .java
my_list = greptile.grep_rl('import', './', '.py', '.xml', '.java')
# same as calling replace()
greptile.sed_i(my_list, 'import', 'export')
Metadata
Release files for Greptile 0.9
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 |
|---|---|---|---|---|
| Greptile-0.9.tar.gz | 2.7 kB | Without provenance | Details for Greptile-0.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| Greptile-0.9-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details for Greptile-0.9-py2.py3-none-any.whl |
Total release size: 6.6 kB
Release files / Greptile-0.9.tar.gz
| Download URL | Greptile-0.9.tar.gz |
|---|---|
| Size | 2.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
52ab9c1f15a93937e72682edac854f0a1527d63576a859948e9bc73062e3a31f
|
|
BLAKE2b-256 checksum How to use checksums |
0c4b40ce082f83f69992de208c56e3d6af6fe1a6213d370caca1ab76e2abe974
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / Greptile-0.9-py2.py3-none-any.whl
| Download URL | Greptile-0.9-py2.py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
27ac2382eaf187569890f7d421372cae1ccca09b4ba0c54e3e0fce8ad8fb629e
|
|
BLAKE2b-256 checksum How to use checksums |
bed8256ddaf0622e4f5a4fcdcab0b967a468c50d333eb8125f6cf825d1983da7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for Greptile 0.9
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.