##// END OF EJS Templates
util.re: move check for re2 into a separate method...
Siddharth Agarwal -
r21913:50aad460 default
parent child Browse files
Show More
@@ -717,19 +717,22 b' except ImportError:'
717 _re2 = False
717 _re2 = False
718
718
719 class _re(object):
719 class _re(object):
720 def _checkre2(self):
721 global _re2
722 try:
723 # check if match works, see issue3964
724 _re2 = bool(re2.match(r'\[([^\[]+)\]', '[ui]'))
725 except ImportError:
726 _re2 = False
727
720 def compile(self, pat, flags=0):
728 def compile(self, pat, flags=0):
721 '''Compile a regular expression, using re2 if possible
729 '''Compile a regular expression, using re2 if possible
722
730
723 For best performance, use only re2-compatible regexp features. The
731 For best performance, use only re2-compatible regexp features. The
724 only flags from the re module that are re2-compatible are
732 only flags from the re module that are re2-compatible are
725 IGNORECASE and MULTILINE.'''
733 IGNORECASE and MULTILINE.'''
726 global _re2
727 if _re2 is None:
734 if _re2 is None:
728 try:
735 self._checkre2()
729 # check if match works, see issue3964
730 _re2 = bool(re2.match(r'\[([^\[]+)\]', '[ui]'))
731 except ImportError:
732 _re2 = False
733 if _re2 and (flags & ~(remod.IGNORECASE | remod.MULTILINE)) == 0:
736 if _re2 and (flags & ~(remod.IGNORECASE | remod.MULTILINE)) == 0:
734 if flags & remod.IGNORECASE:
737 if flags & remod.IGNORECASE:
735 pat = '(?i)' + pat
738 pat = '(?i)' + pat
General Comments 0
You need to be logged in to leave comments. Login now