6576
|
1 |
import util
|
|
2 |
|
|
3 |
class match(object):
|
|
4 |
def __init__(self, root, cwd, patterns, include, exclude, default):
|
|
5 |
self._patterns = patterns
|
|
6 |
self._root = root
|
|
7 |
self._cwd = cwd
|
|
8 |
self._include = include
|
|
9 |
self._exclude = exclude
|
|
10 |
f, mf, ap = util.matcher(self._root, self._cwd, self._patterns,
|
|
11 |
self._include, self._exclude, self.src(),
|
|
12 |
default)
|
|
13 |
self._files = f
|
|
14 |
self._fmap = dict.fromkeys(f)
|
|
15 |
self._matchfn = mf
|
|
16 |
self._anypats = ap
|
|
17 |
def src(self):
|
|
18 |
return None
|
|
19 |
def __call__(self, fn):
|
|
20 |
return self._matchfn(fn)
|
|
21 |
def __iter__(self):
|
|
22 |
for f in self._files:
|
|
23 |
yield f
|
|
24 |
def bad(self, f, msg):
|
|
25 |
return True
|
|
26 |
def dir(self, f):
|
|
27 |
pass
|
|
28 |
def missing(self, f):
|
|
29 |
pass
|
|
30 |
def exact(self, f):
|
|
31 |
return f in self._fmap
|
|
32 |
def rel(self, f):
|
|
33 |
return util.pathto(self._root, self._cwd, f)
|
|
34 |
def files(self):
|
|
35 |
return self._files
|
|
36 |
def anypats(self):
|
|
37 |
return self._anypats
|