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 1SeKmy-000513-In for garchives@archives.gentoo.org; Tue, 12 Jun 2012 06:41:17 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D21E3E04D2; Tue, 12 Jun 2012 06:41:08 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 8BA90E04D2 for ; Tue, 12 Jun 2012 06:41:08 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id C406D1B4010 for ; Tue, 12 Jun 2012 06:41:07 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id 5EB00E5430 for ; Tue, 12 Jun 2012 06:41:06 +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: <1339483252.9a49a7c4189c55d2105ddf21b12321e7da3bf415.zmedico@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: pym/portage/dbapi/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/dbapi/__init__.py pym/portage/dbapi/porttree.py X-VCS-Directories: pym/portage/dbapi/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: 9a49a7c4189c55d2105ddf21b12321e7da3bf415 X-VCS-Branch: master Date: Tue, 12 Jun 2012 06:41:06 +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: 4136485e-15f3-499c-a1f1-464df7d46a81 X-Archives-Hash: 64a40ef03ba3d0f685ed12119e611ab0 commit: 9a49a7c4189c55d2105ddf21b12321e7da3bf415 Author: Zac Medico gentoo org> AuthorDate: Tue Jun 12 06:40:52 2012 +0000 Commit: Zac Medico gentoo org> CommitDate: Tue Jun 12 06:40:52 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D9a49a7c4 dbapi: construct _pkg_str during match on-demand --- pym/portage/dbapi/__init__.py | 47 ++++++++++++++++++++++++++++++++---= ----- pym/portage/dbapi/porttree.py | 17 ++++++++++---- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/pym/portage/dbapi/__init__.py b/pym/portage/dbapi/__init__.p= y index a90d59e..2ab7dc5 100644 --- a/pym/portage/dbapi/__init__.py +++ b/pym/portage/dbapi/__init__.py @@ -16,6 +16,7 @@ portage.proxy.lazyimport.lazyimport(globals(), =20 from portage import os from portage import auxdbkeys +from portage.exception import InvalidData from portage.localization import _ =20 class dbapi(object): @@ -24,6 +25,8 @@ class dbapi(object): _use_mutable =3D False _known_keys =3D frozenset(x for x in auxdbkeys if not x.startswith("UNUSED_0")) + _pkg_str_aux_keys =3D ("EAPI", "SLOT", "repository") + def __init__(self): pass =20 @@ -125,29 +128,53 @@ class dbapi(object): =20 def _iter_match(self, atom, cpv_iter): cpv_iter =3D iter(match_from_list(atom, cpv_iter)) + if atom.repo: + cpv_iter =3D self._iter_match_repo(atom, cpv_iter) if atom.slot: cpv_iter =3D self._iter_match_slot(atom, cpv_iter) if atom.unevaluated_atom.use: cpv_iter =3D self._iter_match_use(atom, cpv_iter) - if atom.repo: - cpv_iter =3D self._iter_match_repo(atom, cpv_iter) return cpv_iter =20 + def _pkg_str(self, cpv, repo): + """ + This is used to contruct _pkg_str instances on-demand during + matching. If cpv is a _pkg_str instance with slot attribute, + then simply return it. Otherwise, fetch metadata and construct + a _pkg_str instance. This may raise KeyError or InvalidData. + """ + try: + cpv.slot + except AttributeError: + pass + else: + return cpv + + metadata =3D dict(zip(self._pkg_str_aux_keys, + self.aux_get(cpv, self._pkg_str_aux_keys, myrepo=3Drepo))) + + return _pkg_str(cpv, slot=3Dmetadata["SLOT"], + repo=3Dmetadata["repository"], eapi=3Dmetadata["EAPI"]) + def _iter_match_repo(self, atom, cpv_iter): for cpv in cpv_iter: try: - if self.aux_get(cpv, ["repository"], myrepo=3Datom.repo)[0] =3D=3D a= tom.repo: - yield cpv - except KeyError: - continue + pkg_str =3D self._pkg_str(cpv, atom.repo) + except (KeyError, InvalidData): + pass + else: + if pkg_str.repo =3D=3D atom.repo: + yield pkg_str =20 def _iter_match_slot(self, atom, cpv_iter): for cpv in cpv_iter: try: - if self.aux_get(cpv, ["SLOT"], myrepo=3Datom.repo)[0] =3D=3D atom.sl= ot: - yield cpv - except KeyError: - continue + pkg_str =3D self._pkg_str(cpv, atom.repo) + except (KeyError, InvalidData): + pass + else: + if pkg_str.slot =3D=3D atom.slot: + yield pkg_str =20 def _iter_match_use(self, atom, cpv_iter): """ diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.p= y index c5ee770..df68115 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -22,7 +22,8 @@ from portage.cache.cache_errors import CacheError from portage.cache.mappings import Mapping from portage.dbapi import dbapi from portage.exception import PortageException, \ - FileNotFound, InvalidAtom, InvalidDependString, InvalidPackageName + FileNotFound, InvalidAtom, InvalidData, \ + InvalidDependString, InvalidPackageName from portage.localization import _ =20 from portage import eclass_cache, \ @@ -825,18 +826,24 @@ class portdbapi(dbapi): # ebuild not in this repo, or masked by corruption continue =20 - if visibility_filter and not self._visible(cpv, metadata): + try: + pkg_str =3D _pkg_str(cpv, slot=3Dmetadata["SLOT"], + repo=3Dmetadata["repository"], eapi=3Dmetadata["EAPI"]) + except InvalidData: + continue + + if visibility_filter and not self._visible(pkg_str, metadata): continue =20 if mydep.slot is not None and \ - mydep.slot !=3D metadata["SLOT"]: + mydep.slot !=3D pkg_str.slot: continue =20 if mydep.unevaluated_atom.use is not None and \ - not self._match_use(mydep, cpv, metadata): + not self._match_use(mydep, pkg_str, metadata): continue =20 - myval.append(cpv) + myval.append(pkg_str) # only yield a given cpv once break =20