mirror of
https://github.com/nvbn/thefuck.git
synced 2025-02-21 20:38:54 +00:00
Slightly improve the fix_file
rule
This commit is contained in:
parent
51f1f44162
commit
9fc2bc904c
@ -35,17 +35,17 @@ patterns = (
|
||||
|
||||
# for the sake of readability do not use named groups above
|
||||
def _make_pattern(pattern):
|
||||
pattern = pattern.replace('{file}', '(?P<file>[^:\n]+)')
|
||||
pattern = pattern.replace('{line}', '(?P<line>[0-9]+)')
|
||||
pattern = pattern.replace('{col}', '(?P<col>[0-9]+)')
|
||||
pattern = pattern.replace('{file}', '(?P<file>[^:\n]+)') \
|
||||
.replace('{line}', '(?P<line>[0-9]+)') \
|
||||
.replace('{col}', '(?P<col>[0-9]+)')
|
||||
return re.compile(pattern, re.MULTILINE)
|
||||
patterns = [_make_pattern(p) for p in patterns]
|
||||
patterns = [_make_pattern(p).search for p in patterns]
|
||||
|
||||
|
||||
@memoize
|
||||
def _search(stderr):
|
||||
for pattern in patterns:
|
||||
m = re.search(pattern, stderr)
|
||||
m = pattern(stderr)
|
||||
if m and os.path.isfile(m.group('file')):
|
||||
return m
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user