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 1QjovI-0001A3-Qi for garchives@archives.gentoo.org; Thu, 21 Jul 2011 08:48:01 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 40B2821C073; Thu, 21 Jul 2011 08:47:22 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id E76AB21C073 for ; Thu, 21 Jul 2011 08:47:21 +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 3A7AE1B4038 for ; Thu, 21 Jul 2011 08:47:21 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 9A08380040 for ; Thu, 21 Jul 2011 08:47:20 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <8f5be684faba3da99038b41148a85eaaf81d3f3e.mgorny@gentoo> Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/ X-VCS-Repository: proj/gentoopm X-VCS-Files: gentoopm/portagepm/repo.py X-VCS-Directories: gentoopm/portagepm/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 8f5be684faba3da99038b41148a85eaaf81d3f3e Date: Thu, 21 Jul 2011 08:47:20 +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: c230fb4154ca4d6ee7d60a738e1e6d4a commit: 8f5be684faba3da99038b41148a85eaaf81d3f3e Author: Micha=C5=82 G=C3=B3rny gentoo org> AuthorDate: Thu Jul 21 07:21:24 2011 +0000 Commit: Micha=C5=82 G=C3=B3rny gentoo org> CommitDate: Thu Jul 21 07:21:24 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoopm.git;= a=3Dcommit;h=3D8f5be684 Portage: don't hardcode CPV classes in repo code. --- gentoopm/portagepm/repo.py | 19 ++++++++++++++----- 1 files changed, 14 insertions(+), 5 deletions(-) diff --git a/gentoopm/portagepm/repo.py b/gentoopm/portagepm/repo.py index 19f4e85..b4c3fa6 100644 --- a/gentoopm/portagepm/repo.py +++ b/gentoopm/portagepm/repo.py @@ -4,6 +4,7 @@ # Released under the terms of the 2-clause BSD license. =20 import os.path +from abc import abstractproperty =20 import portage.exception as pe from portage.versions import catsplit @@ -38,6 +39,7 @@ class PortageRepoDict(PMRepositoryDict): class PortageFilteredDBRepo(PortageFilteredPackageSet): def __init__(self, repo, atom): self._dbapi =3D repo._dbapi + self._pkg_class =3D repo._pkg_class self._atom =3D atom._atom =20 @property @@ -55,13 +57,14 @@ class PortageFilteredDBRepo(PortageFilteredPackageSet= ): yield p else: for p in it: - yield PortageDBCPV(p, self._dbapi) + yield self._pkg_class(p, self._dbapi) =20 class PortageHackedFilteredDBRepo(PortageFilteredDBRepo): def __init__(self, repo, pkgcand): cat =3D catsplit(pkgcand)[0] self._atom =3D str(repo._atom).replace('null/', '%s/' % cat) self._dbapi =3D repo._dbapi + self._pkg_class =3D repo._pkg_class =20 @property def _stringified_atom(self): @@ -71,9 +74,13 @@ class PortDBRepository(PortagePackageSet, PMRepository= ): def __init__(self, dbapi): self._dbapi =3D dbapi =20 + @abstractproperty + def _pkg_class(self): + pass + def __iter__(self): for p in self._dbapi.cpv_all(): # XXX - yield PortageDBCPV(p, self._dbapi) + yield self._pkg_class(p, self._dbapi) =20 _filtered_subclass =3D PortageFilteredDBRepo def filter(self, *args, **kwargs): @@ -117,7 +124,7 @@ class PortageFilteredRepo(PortageFilteredDBRepo): yield p else: for p in it: - yield PortageCPV(p, self._dbapi, self._path, self._prio) + yield self._pkg_class(p, self._dbapi, self._path, self._prio) =20 class PortageHackedAtom(object): def __init__(self, s, repo): @@ -139,6 +146,7 @@ class PortageHackedFilteredRepo(PortageFilteredRepo): repo._atom.repo) self._dbapi =3D repo._dbapi self._path =3D repo._path + self._pkg_class =3D repo._pkg_class self._prio =3D repo._prio self._name =3D repo._name =20 @@ -153,12 +161,13 @@ class PortageRepository(PortDBRepository, PMEbuildR= epository, self._repo =3D repo_obj PortDBRepository.__init__(self, portdbapi) =20 + _pkg_class =3D PortageCPV def __iter__(self): path =3D self.path prio =3D self._repo.priority for cp in self._dbapi.cp_all(trees =3D (path,)): for p in self._dbapi.cp_list(cp, mytree =3D path): - yield PortageCPV(p, self._dbapi, path, prio) + yield self._pkg_class(p, self._dbapi, path, prio) =20 _filtered_subclass =3D PortageFilteredRepo =20 @@ -174,4 +183,4 @@ class PortageRepository(PortDBRepository, PMEbuildRep= ository, return self._repo.priority < other._repo.priority =20 class VDBRepository(PortDBRepository): - pass + _pkg_class =3D PortageDBCPV