Skip to content

Commit

Permalink
Couple regex doc clarifications.
Browse files Browse the repository at this point in the history
Closes #21.
  • Loading branch information
jlevy committed Dec 17, 2024
1 parent 1d34eba commit d95b069
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ repren -p patfile --word-breaks --full mydir1

# Same as above, for all case variants:
repren -p patfile --word-breaks --preserve-case --full mydir1

# Same as above but including only .py files and excluding the tests directory
# and any files or directories starting with test_:
repren -p patfile --word-breaks --preserve-case --full --include='.*[.]py$' --exclude='tests|test_.*' mydir1
```

## Usage
Expand Down Expand Up @@ -122,15 +126,15 @@ scripts that would scare your mother.

No dependencies except Python 3.10+. It's easiest to install with pip:

```
```bash
pip install repren
```

Or, since it's just one file, you can copy the
[repren.py](https://raw.githubusercontent.com/jlevy/repren/master/repren/repren.py) script
somewhere convenient and make it executable.

## Try it
## Try It

Let's try a simple replacement in my working directory (which has a few random source
files):
Expand Down
2 changes: 2 additions & 0 deletions devtools/generate_readme.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python

from jinja2 import Template
import os
import sys
Expand Down
12 changes: 10 additions & 2 deletions repren/repren.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@
## Notes
- All pattern matching is via standard
[Python regular expressions](https://docs.python.org/3/library/re.html).
- As with sed, replacements are made line by line by default.
Memory permitting, replacements may be done on entire files using `--at-once`.
Expand Down Expand Up @@ -847,7 +850,7 @@ def main() -> None:
parser.add_argument(
"--walk-only",
help=(
"like --dry-run, but only walk and list that will be processed "
"like --dry-run, but only walk directories and list files that will be processed "
"(good for confirming your --include and --exclude patterns)"
),
dest="walk_only",
Expand Down Expand Up @@ -989,6 +992,11 @@ def format_flags(flags: int) -> str:
main()

# TODO:
# --undo mode to revert a previous run by using .orig files; --clean mode to remove .orig files
# consider using regex for better Unicode support (but only gracefully, such as
# with a dynamic import, if those features like Unicode character properties are needed)
# --undo mode to revert a previous run by using .orig files
# --clean mode to remove .orig files
# --orig_suffix to allow for backups besides .orig, including for these use cases
# Log collisions
# Separate patterns file for renames and replacements
# Should --at-once be the default?

0 comments on commit d95b069

Please sign in to comment.