From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1R7XXR-0004gT-UY for garchives@archives.gentoo.org; Sat, 24 Sep 2011 19:05:28 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C855121CA77; Sat, 24 Sep 2011 19:05:17 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 8BB6721CA77 for ; Sat, 24 Sep 2011 19:05:17 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0EB631B4014 for ; Sat, 24 Sep 2011 19:05:17 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 26A8380042 for ; Sat, 24 Sep 2011 19:05:16 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: <5076fa35cdcba5a092f16c2004e90d4d84c01044.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/dbapi/porttree.py X-VCS-Directories: pym/portage/dbapi/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 5076fa35cdcba5a092f16c2004e90d4d84c01044 Date: Sat, 24 Sep 2011 19:05:16 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 9c25999b29b46525f2207aad2a36dcce commit: 5076fa35cdcba5a092f16c2004e90d4d84c01044 Author: Zac Medico gentoo org> AuthorDate: Sat Sep 24 19:05:00 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Sat Sep 24 19:05:00 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D5076fa35 portdbapi: move repo loop to _iter_visible This allows use to avoid using a set to eliminate duplicates, since we can break out of the repo loop as soon as a given cpv is found to be visible. --- pym/portage/dbapi/porttree.py | 123 +++++++++++++++++++++--------------= ----- 1 files changed, 65 insertions(+), 58 deletions(-) diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.p= y index e4cf9a6..aaa69fa 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -874,22 +874,9 @@ class portdbapi(dbapi): =20 elif level =3D=3D "match-visible": # find all visible matches - if mydep.repo is not None or len(self.porttrees) =3D=3D 1: - myval =3D list(self._iter_visible( - self.xmatch("match-all", mydep), - mytree=3Dmytree)) - else: - myval =3D set() - # We iterate over self.porttrees, since it's common to - # tweak this attribute in order to adjust match behavior. - for tree in self.porttrees: - repo =3D self.repositories.get_name_for_location(tree) - myval.update(self._iter_visible( - self.xmatch("match-all", mydep.with_repo(repo)), - mytree=3Dtree)) - myval =3D list(myval) - if len(myval) > 1: - self._cpv_sort_ascending(myval) + myval =3D self.xmatch("match-all", mydep) + if myval: + myval =3D list(self._iter_visible(myval, myrepo=3Dmydep.repo)) =20 elif level =3D=3D "minimum-all": # Find the minimum matching version. This is optimized to @@ -1016,24 +1003,24 @@ class portdbapi(dbapi): def match(self, mydep, use_cache=3D1): return self.xmatch("match-visible", mydep) =20 - def gvisible(self, mylist, mytree=3DNone): + def gvisible(self, mylist): warnings.warn("The 'gvisible' method of " "portage.dbapi.porttree.portdbapi " "is deprecated, and the functionality " "has been combined into the 'visible' method", DeprecationWarning, stacklevel=3D2) - return self.visible(mylist, mytree=3Dmytree) + return self.visible(mylist) =20 - def visible(self, cpv_iter, mytree=3DNone): + def visible(self, cpv_iter): """ Return a list containing only visible packages. """ - if mylist is None: + if cpv_iter is None: return [] =20 - return list(self._iter_visible(iter(cpv_iter), mytree=3Dmytree)) + return list(self._iter_visible(iter(cpv_iter))) =20 - def _iter_visible(self, cpv_iter, mytree=3DNone): + def _iter_visible(self, cpv_iter, myrepo=3DNone): """ Return a new list containing only visible packages. """ @@ -1043,46 +1030,66 @@ class portdbapi(dbapi): chost =3D self.settings.get('CHOST', '') accept_chost =3D self.settings._accept_chost getMaskAtom =3D self.settings._getMaskAtom + + if len(self.porttrees) =3D=3D 1: + repos =3D [None] + elif myrepo is not None: + repos =3D [myrepo] + else: + # We iterate over self.porttrees, since it's common to + # tweak this attribute in order to adjust match behavior. + repos =3D [] + for tree in reversed(self.porttrees): + repos.append(self.repositories.get_name_for_location(tree)) + for mycpv in cpv_iter: - metadata.clear() - try: - metadata.update(zip(aux_keys, - self.aux_get(mycpv, aux_keys, mytree=3Dmytree))) - except KeyError: - continue - except PortageException as e: - writemsg("!!! Error: aux_get('%s', %s)\n" % (mycpv, aux_keys), - noiselevel=3D-1) - writemsg("!!! %s\n" % (e,), noiselevel=3D-1) - del e - continue - eapi =3D metadata["EAPI"] - if not eapi_is_supported(eapi): - continue - if _eapi_is_deprecated(eapi): - continue - if not metadata["SLOT"]: - continue - if getMaskAtom(mycpv, metadata): - continue - if self.settings._getMissingKeywords(mycpv, metadata): - continue - if local_config: - metadata['CHOST'] =3D chost - if not accept_chost(mycpv, metadata): - continue - metadata["USE"] =3D "" - if "?" in metadata["LICENSE"] or "?" in metadata["PROPERTIES"]: - self.doebuild_settings.setcpv(mycpv, mydb=3Dmetadata) - metadata['USE'] =3D self.doebuild_settings['PORTAGE_USE'] + for repo in repos: + metadata.clear() try: - if self.settings._getMissingLicenses(mycpv, metadata): + metadata.update(zip(aux_keys, + self.aux_get(mycpv, aux_keys, myrepo=3Drepo))) + except KeyError: + continue + except PortageException as e: + writemsg("!!! Error: aux_get('%s', %s)\n" % + (mycpv, aux_keys), noiselevel=3D-1) + writemsg("!!! %s\n" % (e,), noiselevel=3D-1) + del e + continue + eapi =3D metadata["EAPI"] + if not eapi_is_supported(eapi): + continue + if _eapi_is_deprecated(eapi): + continue + if not metadata["SLOT"]: + continue + if getMaskAtom(mycpv, metadata): + continue + if self.settings._getMissingKeywords(mycpv, metadata): + continue + if local_config: + metadata['CHOST'] =3D chost + if not accept_chost(mycpv, metadata): continue - if self.settings._getMissingProperties(mycpv, metadata): + metadata["USE"] =3D "" + if "?" in metadata["LICENSE"] or \ + "?" in metadata["PROPERTIES"]: + self.doebuild_settings.setcpv(mycpv, mydb=3Dmetadata) + metadata['USE'] =3D \ + self.doebuild_settings['PORTAGE_USE'] + try: + if self.settings._getMissingLicenses( + mycpv, metadata): + continue + if self.settings._getMissingProperties( + mycpv, metadata): + continue + except InvalidDependString: continue - except InvalidDependString: - continue - yield mycpv + + yield mycpv + # only yield a given cpv once + break =20 def close_portdbapi_caches(): for i in portdbapi.portdbapi_instances: