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 1QhvRO-0007d3-Sx for garchives@archives.gentoo.org; Sat, 16 Jul 2011 03:21:19 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id A7BF621C087; Sat, 16 Jul 2011 03:21:09 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 623A621C087 for ; Sat, 16 Jul 2011 03:21:09 +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 B977A2AC163 for ; Sat, 16 Jul 2011 03:21:08 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id E4BDD8003D for ; Sat, 16 Jul 2011 03:21:07 +0000 (UTC) From: "Paul Varner" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Paul Varner" Message-ID: Subject: [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/ X-VCS-Repository: proj/gentoolkit X-VCS-Files: pym/gentoolkit/package.py X-VCS-Directories: pym/gentoolkit/ X-VCS-Committer: fuzzyray X-VCS-Committer-Name: Paul Varner X-VCS-Revision: e93234d3f899e2e5577b8085bbfd90c7447576cd Date: Sat, 16 Jul 2011 03:21:07 +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: 12c681e35ee33a275b504cc3bce3a790 commit: e93234d3f899e2e5577b8085bbfd90c7447576cd Author: Paul Varner gentoo org> AuthorDate: Sat Jul 16 03:16:56 2011 +0000 Commit: Paul Varner gentoo org> CommitDate: Sat Jul 16 03:16:56 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoolkit.gi= t;a=3Dcommit;h=3De93234d3 Update Package Class to allow passing of local_config. The local_config variable determines if the portage.config settings object takes the /etc/portage/package.* files into account. --- pym/gentoolkit/package.py | 42 +++++++++++++++++++++++++++------------= --- 1 files changed, 27 insertions(+), 15 deletions(-) diff --git a/pym/gentoolkit/package.py b/pym/gentoolkit/package.py index e405412..45e59bd 100644 --- a/pym/gentoolkit/package.py +++ b/pym/gentoolkit/package.py @@ -47,7 +47,6 @@ import os from string import Template =20 import portage -from portage import settings from portage.util import LazyItemsDict =20 import gentoolkit.pprinter as pp @@ -58,13 +57,22 @@ from gentoolkit.keyword import determine_keyword from gentoolkit.flag import get_flags =20 # =3D=3D=3D=3D=3D=3D=3D +# Settings +# =3D=3D=3D=3D=3D=3D=3D + +default_settings =3D portage.config(local_config=3DTrue) +default_settings.lock() +nolocal_settings =3D portage.config(local_config=3DFalse) +nolocal_settings.lock() + +# =3D=3D=3D=3D=3D=3D=3D # Classes # =3D=3D=3D=3D=3D=3D=3D =20 class Package(CPV): """Exposes the state of a given CPV.""" =20 - def __init__(self, cpv, validate=3DFalse): + def __init__(self, cpv, validate=3DFalse, local_config=3DTrue): if isinstance(cpv, CPV): self.__dict__.update(cpv.__dict__) else: @@ -76,6 +84,11 @@ class Package(CPV): # CPV allows some things that Package must not raise errors.GentoolkitInvalidPackage(self.cpv) =20 + if local_config: + self._settings =3D default_settings + else: + self._settings =3D nolocal_settings + # Set dynamically self._package_path =3D None self._dblink =3D None @@ -123,8 +136,8 @@ class Package(CPV): self._dblink =3D portage.dblink( self.category, "%s-%s" % (self.name, self.fullversion), - settings["ROOT"], - settings + self._settings["ROOT"], + self._settings ) =20 return self._dblink @@ -209,17 +222,16 @@ class Package(CPV): =20 return bool(PORTDB.cpv_exists(self.cpv)) =20 - @staticmethod - def settings(key): + def settings(self, key): """Returns the value of the given key for this package (useful for package.* files.""" =20 - if settings.locked: - settings.unlock() + if self._settings.locked: + self._settings.unlock() try: - result =3D settings[key] + result =3D self._settings[key] finally: - settings.lock() + self._settings.lock() return result =20 def mask_status(self): @@ -234,11 +246,11 @@ class Package(CPV): 'missing keyword' """ =20 - if settings.locked: - settings.unlock() + if self._settings.locked: + self._settings.unlock() try: result =3D portage.getmaskingstatus(self.cpv, - settings=3Dsettings, + settings=3Dself._settings, portdb=3DPORTDB) except KeyError: # getmaskingstatus doesn't support packages without ebuilds in the @@ -257,7 +269,7 @@ class Package(CPV): =20 try: result =3D portage.getmaskingreason(self.cpv, - settings=3Dsettings, + settings=3Dself._settings, portdb=3DPORTDB, return_location=3DTrue) if result is None: @@ -372,7 +384,7 @@ class Package(CPV): if not ebuild: return None if self._portdir_path is None: - self._portdir_path =3D os.path.realpath(settings["PORTDIR"]) + self._portdir_path =3D os.path.realpath(self._settings["PORTDIR"]) return (tree and tree !=3D self._portdir_path) =20 def is_masked(self):