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 1Qg2Jy-0006UO-Kn for garchives@archives.gentoo.org; Sun, 10 Jul 2011 22:17:50 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id B3D8A21C1C8; Sun, 10 Jul 2011 22:17:28 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 8708B21C10C for ; Sun, 10 Jul 2011 22:17:28 +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 DCFD91B406F for ; Sun, 10 Jul 2011 22:17:27 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 3E3B48003F for ; Sun, 10 Jul 2011 22:17:27 +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: <3e8b0067791e55c4a28c6a0a275e55f0eb7d21a9.mgorny@gentoo> Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/portagepm/ X-VCS-Repository: proj/gentoopm X-VCS-Files: gentoopm/portagepm/__init__.py gentoopm/portagepm/atom.py X-VCS-Directories: gentoopm/portagepm/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 3e8b0067791e55c4a28c6a0a275e55f0eb7d21a9 Date: Sun, 10 Jul 2011 22:17:27 +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: e88e46e0ace9fa10d3dc5f0ef4bed0d5 commit: 3e8b0067791e55c4a28c6a0a275e55f0eb7d21a9 Author: Micha=C5=82 G=C3=B3rny gentoo org> AuthorDate: Sun Jul 10 21:53:44 2011 +0000 Commit: Micha=C5=82 G=C3=B3rny gentoo org> CommitDate: Sun Jul 10 22:16:51 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoopm.git;= a=3Dcommit;h=3D3e8b0067 Portage: Pass FakeSettings to instantiate atoms without dbapi. --- gentoopm/portagepm/__init__.py | 2 +- gentoopm/portagepm/atom.py | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/gentoopm/portagepm/__init__.py b/gentoopm/portagepm/__init__= .py index 4b1887a..6bade14 100644 --- a/gentoopm/portagepm/__init__.py +++ b/gentoopm/portagepm/__init__.py @@ -32,4 +32,4 @@ class PortagePM(PackageManager): =20 @property def Atom(self): - return functools.partial(PortageAtom, pm =3D self) + return PortageAtom diff --git a/gentoopm/portagepm/atom.py b/gentoopm/portagepm/atom.py index 121e3b1..7614298 100644 --- a/gentoopm/portagepm/atom.py +++ b/gentoopm/portagepm/atom.py @@ -3,6 +3,8 @@ # (c) 2011 Micha=C5=82 G=C3=B3rny # Released under the terms of the 2-clause BSD license. =20 +import collections + import portage.exception as pe from portage.dbapi.dep_expand import dep_expand from portage.dep import match_from_list @@ -11,10 +13,18 @@ from portage.versions import catsplit from gentoopm.basepm.atom import PMAtom from gentoopm.exceptions import InvalidAtomStringError =20 +class FakeSettings(object): + """ + Fake settings object, to satisfy cpv_expand(). + """ + + def __getattr__(self, key): + return lambda: collections.defaultdict(lambda: '') + class PortageAtom(object): - def __new__(self, s, pm): + def __new__(self, s): try: - a =3D dep_expand(s, settings =3D pm._portdb.settings) + a =3D dep_expand(s, settings =3D FakeSettings()) except pe.InvalidAtom: raise InvalidAtomStringError('Incorrect atom: %s' % s) =20