|
@@ -2,7 +2,7 @@ import os
|
|
|
import re
|
|
|
|
|
|
|
|
|
-def translate(pat):
|
|
|
+def translate(pat, match_end=r"\Z"):
|
|
|
"""Translate a shell-style pattern to a regular expression.
|
|
|
|
|
|
The pattern may include ``**<sep>`` (<sep> stands for the platform-specific path separator; "/" on POSIX systems) for
|
|
@@ -10,6 +10,9 @@ def translate(pat):
|
|
|
any path separator. Wrap meta-characters in brackets for a literal match (i.e. "[?]" to match the literal character
|
|
|
"?").
|
|
|
|
|
|
+ Using match_end=regex one can give a regular expression that is used to match after the regex that is generated from
|
|
|
+ the pattern. The default is to match the end of the string.
|
|
|
+
|
|
|
This function is derived from the "fnmatch" module distributed with the Python standard library.
|
|
|
|
|
|
Copyright (C) 2001-2017 Python Software Foundation. All rights reserved.
|
|
@@ -59,4 +62,4 @@ def translate(pat):
|
|
|
else:
|
|
|
res += re.escape(c)
|
|
|
|
|
|
- return res + r"\Z(?ms)"
|
|
|
+ return res + match_end + "(?ms)"
|