equal
deleted
inserted
replaced
205 Abort = error.Abort |
205 Abort = error.Abort |
206 |
206 |
207 def always(fn): return True |
207 def always(fn): return True |
208 def never(fn): return False |
208 def never(fn): return False |
209 |
209 |
210 def patkind(name, default): |
210 def _patsplit(pat, default): |
211 """Split a string into an optional pattern kind prefix and the |
211 """Split a string into an optional pattern kind prefix and the |
212 actual pattern.""" |
212 actual pattern.""" |
213 for prefix in 're', 'glob', 'path', 'relglob', 'relpath', 'relre': |
213 for prefix in 're', 'glob', 'path', 'relglob', 'relpath', 'relre': |
214 if name.startswith(prefix + ':'): return name.split(':', 1) |
214 if pat.startswith(prefix + ':'): return pat.split(':', 1) |
215 return default, name |
215 return default, pat |
216 |
216 |
217 def globre(pat, head='^', tail='$'): |
217 def globre(pat, head='^', tail='$'): |
218 "convert a glob pattern into a regexp" |
218 "convert a glob pattern into a regexp" |
219 i, n = 0, len(pat) |
219 i, n = 0, len(pat) |
220 res = '' |
220 res = '' |
434 |
434 |
435 def normalizepats(names, default): |
435 def normalizepats(names, default): |
436 pats = [] |
436 pats = [] |
437 roots = [] |
437 roots = [] |
438 anypats = False |
438 anypats = False |
439 for kind, name in [patkind(p, default) for p in names]: |
439 for kind, name in [_patsplit(p, default) for p in names]: |
440 if kind in ('glob', 'relpath'): |
440 if kind in ('glob', 'relpath'): |
441 name = canonpath(canonroot, cwd, name) |
441 name = canonpath(canonroot, cwd, name) |
442 elif kind in ('relglob', 'path'): |
442 elif kind in ('relglob', 'path'): |
443 name = normpath(name) |
443 name = normpath(name) |
444 |
444 |
737 from windows import * |
737 from windows import * |
738 def expand_glob(pats): |
738 def expand_glob(pats): |
739 '''On Windows, expand the implicit globs in a list of patterns''' |
739 '''On Windows, expand the implicit globs in a list of patterns''' |
740 ret = [] |
740 ret = [] |
741 for p in pats: |
741 for p in pats: |
742 kind, name = patkind(p, None) |
742 kind, name = _patsplit(p, None) |
743 if kind is None: |
743 if kind is None: |
744 globbed = glob.glob(name) |
744 globbed = glob.glob(name) |
745 if globbed: |
745 if globbed: |
746 ret.extend(globbed) |
746 ret.extend(globbed) |
747 continue |
747 continue |