1 |
On 05/22/2016 01:21 AM, Michał Górny wrote: |
2 |
> + def _is_install_masked(self, relative_path): |
3 |
> + ret = False |
4 |
> + for pattern in self.settings.install_mask: |
5 |
> + # absolute path pattern |
6 |
> + if pattern.startswith('/'): |
7 |
> + # match either exact path or one of parent dirs |
8 |
> + # the latter is done via matching pattern/* |
9 |
> + if (fnmatch.fnmatch(relative_path, pattern[1:]) |
10 |
> + or fnmatch.fnmatch(relative_path, pattern[1:] + '/*')): |
11 |
> + ret = True |
12 |
> + break |
13 |
> + # filename |
14 |
> + else: |
15 |
> + if fnmatch.fnmatch(os.path.basename(relative_path), pattern): |
16 |
> + ret = True |
17 |
> + break |
18 |
> + return ret |
19 |
> + |
20 |
|
21 |
This is a hot spot, so it should use a pre-compiled regular expression, |
22 |
using | to join the results of fnmatch.translate(pattern) calls for each |
23 |
pattern. |
24 |
-- |
25 |
Thanks, |
26 |
Zac |