Show More
@@ -716,29 +716,33 b' try:' | |||||
716 | except ImportError: |
|
716 | except ImportError: | |
717 | _re2 = False |
|
717 | _re2 = False | |
718 |
|
718 | |||
719 | def compilere(pat, flags=0): |
|
719 | class _re(object): | |
720 | '''Compile a regular expression, using re2 if possible |
|
720 | def compile(self, pat, flags=0): | |
|
721 | '''Compile a regular expression, using re2 if possible | |||
721 |
|
722 | |||
722 | For best performance, use only re2-compatible regexp features. The |
|
723 | For best performance, use only re2-compatible regexp features. The | |
723 | only flags from the re module that are re2-compatible are |
|
724 | only flags from the re module that are re2-compatible are | |
724 | IGNORECASE and MULTILINE.''' |
|
725 | IGNORECASE and MULTILINE.''' | |
725 | global _re2 |
|
726 | global _re2 | |
726 | if _re2 is None: |
|
727 | if _re2 is None: | |
727 | try: |
|
728 | try: | |
728 | # check if match works, see issue3964 |
|
729 | # check if match works, see issue3964 | |
729 | _re2 = bool(re2.match(r'\[([^\[]+)\]', '[ui]')) |
|
730 | _re2 = bool(re2.match(r'\[([^\[]+)\]', '[ui]')) | |
730 | except ImportError: |
|
731 | except ImportError: | |
731 | _re2 = False |
|
732 | _re2 = False | |
732 | if _re2 and (flags & ~(remod.IGNORECASE | remod.MULTILINE)) == 0: |
|
733 | if _re2 and (flags & ~(remod.IGNORECASE | remod.MULTILINE)) == 0: | |
733 | if flags & remod.IGNORECASE: |
|
734 | if flags & remod.IGNORECASE: | |
734 | pat = '(?i)' + pat |
|
735 | pat = '(?i)' + pat | |
735 | if flags & remod.MULTILINE: |
|
736 | if flags & remod.MULTILINE: | |
736 | pat = '(?m)' + pat |
|
737 | pat = '(?m)' + pat | |
737 | try: |
|
738 | try: | |
738 | return re2.compile(pat) |
|
739 | return re2.compile(pat) | |
739 | except re2.error: |
|
740 | except re2.error: | |
740 | pass |
|
741 | pass | |
741 | return remod.compile(pat, flags) |
|
742 | return remod.compile(pat, flags) | |
|
743 | ||||
|
744 | re = _re() | |||
|
745 | compilere = re.compile | |||
742 |
|
746 | |||
743 | _fspathcache = {} |
|
747 | _fspathcache = {} | |
744 | def fspath(name, root): |
|
748 | def fspath(name, root): |
General Comments 0
You need to be logged in to leave comments.
Login now