https://github.com/tirkarthi/escape_sequence_fixer
A simple script to fix invalid escape sequences
https://github.com/tirkarthi/escape_sequence_fixer
Last synced: 4 months ago
JSON representation
A simple script to fix invalid escape sequences
- Host: GitHub
- URL: https://github.com/tirkarthi/escape_sequence_fixer
- Owner: tirkarthi
- License: mit
- Created: 2020-01-15T06:24:02.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-16T16:29:41.000Z (over 5 years ago)
- Last Synced: 2025-01-05T12:42:33.769Z (5 months ago)
- Language: Python
- Size: 8.79 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Escape sequence fixer
A simple script to fix invalid escape sequences deprecation warning by converting the string to raw strings.
# Usage
```python
# /tmp/foo.pyimport re
numbers = re.compile("\d")
```This will produce a warning regarding invalid escape sequence as below :
```
$ python -Wall /tmp/foo.py
/tmp/foo.py:3: DeprecationWarning: invalid escape sequence \d
numbers = re.compile("\d")
```Using `escape_seq_fixer.py` will create a patch to conver the strings to raw strings. The patch can be applied with `patch -p0 < fixer.patch`
```
python escape_sequence_fixer.py --input /tmp/foo.py
--- /tmp/foo.py
+++ /tmp/foo.py
@@ -1,3 +1,3 @@
import re-numbers = re.compile("\d")
+numbers = re.compile(r"\d")
```# Help
```
usage: escape_sequence_fixer.py [-h] [--input INPUT [INPUT ...]]
[--output [OUTPUT]]optional arguments:
-h, --help show this help message and exit
--input INPUT [INPUT ...]
List of files as input.
--output [OUTPUT] Output file for the patch.
```