~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/globbing.py

  • Committer: Martin Pool
  • Date: 2011-06-28 22:25:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6004.
  • Revision ID: mbp@canonical.com-20110628222528-gwf27vdagmxatljc
More explicit laziness

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
    must not contain capturing groups.
42
42
    """
43
43
 
44
 
    _expand = re.compile(ur'\\&')
 
44
    _expand = lazy_regex.lazy_compile(ur'\\&')
45
45
 
46
46
    def __init__(self, source=None):
47
47
        self._pat = None
77
77
 
78
78
    def __call__(self, text):
79
79
        if not self._pat:
80
 
            self._pat = re.compile(
 
80
            self._pat = lazy_regex.lazy_compile(
81
81
                    u'|'.join([u'(%s)' % p for p in self._pats]),
82
82
                    re.UNICODE)
83
83
        return self._pat.sub(self._do_sub, text)
282
282
        translator = Globster.pattern_info[Globster.identify(pattern)]["translator"]
283
283
        tpattern = '(%s)' % translator(pattern)
284
284
        try:
285
 
            re_obj = re.compile(tpattern, re.UNICODE)
 
285
            re_obj = lazy_regex.lazy_compile(tpattern, re.UNICODE)
286
286
            re_obj.search("") # force compile
287
287
        except errors.InvalidPattern, e:
288
288
            result = False
341
341
                Globster.pattern_info[t]["prefix"])
342
342
 
343
343
 
344
 
_slashes = re.compile(r'[\\/]+')
 
344
_slashes = lazy_regex.lazy_compile(r'[\\/]+')
345
345
def normalize_pattern(pattern):
346
346
    """Converts backslashes in path patterns to forward slashes.
347
347