File tree Expand file tree Collapse file tree 2 files changed +4
-7
lines changed Expand file tree Collapse file tree 2 files changed +4
-7
lines changed Original file line number Diff line number Diff line change @@ -77,11 +77,6 @@ def translate(pat):
77
77
There is no way to quote meta-characters.
78
78
"""
79
79
80
- res = _translate (pat )
81
- return fr'(?s:{ res } )\Z'
82
-
83
-
84
- def _translate (pat ):
85
80
STAR = object ()
86
81
res = []
87
82
add = res .append
@@ -187,4 +182,4 @@ def _translate(pat):
187
182
add (f"(?>.*?{ fixed } )" )
188
183
assert i == n
189
184
res = "" .join (res )
190
- return res
185
+ return fr'(?s: { res } )\Z'
Original file line number Diff line number Diff line change @@ -66,6 +66,8 @@ def _is_wildcard_pattern(pat):
66
66
67
67
68
68
_SWAP_SLASH_AND_NEWLINE = str .maketrans ({'/' : '\n ' , '\n ' : '/' })
69
+ _FNMATCH_PADDING = fnmatch .translate ('_' ).split ('_' )
70
+ _FNMATCH_SLICE = slice (len (_FNMATCH_PADDING [0 ]), - len (_FNMATCH_PADDING [1 ]))
69
71
70
72
71
73
@functools .lru_cache ()
@@ -77,7 +79,7 @@ def _translate(pattern):
77
79
elif '**' in pattern :
78
80
raise ValueError ("Invalid pattern: '**' can only be an entire path component" )
79
81
else :
80
- return fnmatch ._translate (pattern )
82
+ return fnmatch .translate (pattern )[ _FNMATCH_SLICE ]
81
83
82
84
83
85
@functools .lru_cache ()
You can’t perform that action at this time.
0 commit comments