On 05/22/2016 01:21 AM, Michał Górny wrote:
> +     def _is_install_masked(self, relative_path):
> +             ret = False
> +             for pattern in self.settings.install_mask:
> +                     # absolute path pattern
> +                     if pattern.startswith('/'):
> +                             # match either exact path or one of parent dirs
> +                             # the latter is done via matching pattern/*
> +                             if (fnmatch.fnmatch(relative_path, pattern[1:])
> +                                             or 
> fnmatch.fnmatch(relative_path, pattern[1:] + '/*')):
> +                                     ret = True
> +                                     break
> +                     # filename
> +                     else:
> +                             if 
> fnmatch.fnmatch(os.path.basename(relative_path), pattern):
> +                                     ret = True
> +                                     break
> +             return ret
> +

This is a hot spot, so it should use a pre-compiled regular expression,
using | to join the results of fnmatch.translate(pattern) calls for each
pattern.
-- 
Thanks,
Zac

Reply via email to