From: Brian Dolbec Date: Tue, 1 Feb 2011 00:12:40 +0000 (-0800) Subject: put main code in a private func() to remove near duplicated code X-Git-Tag: v2.2.0_alpha20~44 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=1989cc809b67b8f847d58c096fb70fe89a961a3e;p=portage.git put main code in a private func() to remove near duplicated code --- diff --git a/pym/portage/package/ebuild/_config/MaskManager.py b/pym/portage/package/ebuild/_config/MaskManager.py index be7a21274..c438eb7da 100644 --- a/pym/portage/package/ebuild/_config/MaskManager.py +++ b/pym/portage/package/ebuild/_config/MaskManager.py @@ -112,7 +112,7 @@ class MaskManager(object): for k, v in d.items(): d[k] = tuple(v) - def getMaskAtom(self, cpv, slot, repo): + def _getMaskAtom(self, cpv, slot, repo, unmask_atoms=None): """ Take a package and return a matching package.mask atom, or None if no such atom exists or it has been cancelled by package.unmask. PROVIDE @@ -122,6 +122,10 @@ class MaskManager(object): @type cpv: String @param slot: The package's slot @type slot: String + @param repo: The package's repository [optional] + @type repo: String + @param unmask_atoms: if desired pass in self._punmaskdict.get(cp) + @type unmask_atoms: list @rtype: String @return: A matching atom string or None if one is not found. """ @@ -133,7 +137,6 @@ class MaskManager(object): if repo: pkg = "".join((pkg, _repo_separator, repo)) pkg_list = [pkg] - unmask_atoms = self._punmaskdict.get(cp) for x in mask_atoms: if not match_from_list(x, pkg_list): continue @@ -144,6 +147,27 @@ class MaskManager(object): return x return None + + def getMaskAtom(self, cpv, slot, repo): + """ + Take a package and return a matching package.mask atom, or None if no + such atom exists or it has been cancelled by package.unmask. PROVIDE + is not checked, so atoms will not be found for old-style virtuals. + + @param cpv: The package name + @type cpv: String + @param slot: The package's slot + @type slot: String + @param repo: The package's repository [optional] + @type repo: String + @rtype: String + @return: A matching atom string or None if one is not found. + """ + + cp = cpv_getkey(cpv) + return self._getMaskAtom(cpv, slot, repo, self._punmaskdict.get(cp)) + + def getRawMaskAtom(self, cpv, slot, repo): """ Take a package and return a matching package.mask atom, or None if no @@ -155,19 +179,10 @@ class MaskManager(object): @type cpv: String @param slot: The package's slot @type slot: String + @param repo: The package's repository [optional] + @type repo: String @rtype: String @return: A matching atom string or None if one is not found. """ - cp = cpv_getkey(cpv) - mask_atoms = self._pmaskdict_raw.get(cp) - if mask_atoms: - pkg = "".join((cpv, _slot_separator, slot)) - if repo: - pkg = "".join((pkg, _repo_separator, repo)) - pkg_list = [pkg] - for x in mask_atoms: - if not match_from_list(x, pkg_list): - continue - return x - return None + return self._getMaskAtom(cpv, slot, repo)