Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: Re: [gentoo-portage-dev] [PATCH v2] Move INSTALL_MASK handling into merging
Date: Sun, 12 Jun 2016 08:42:01
Message-Id: 575D2053.6070809@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH v2] Move INSTALL_MASK handling into merging by "Michał Górny"
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