public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Paul Varner" <fuzzyray@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/
Date: Sat, 16 Jul 2011 03:21:07 +0000 (UTC)	[thread overview]
Message-ID: <e93234d3f899e2e5577b8085bbfd90c7447576cd.fuzzyray@gentoo> (raw)

commit:     e93234d3f899e2e5577b8085bbfd90c7447576cd
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 16 03:16:56 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Sat Jul 16 03:16:56 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=e93234d3

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
 
 import portage
-from portage import settings
 from portage.util import LazyItemsDict
 
 import gentoolkit.pprinter as pp
@@ -58,13 +57,22 @@ from gentoolkit.keyword import determine_keyword
 from gentoolkit.flag import get_flags
 
 # =======
+# Settings
+# =======
+
+default_settings = portage.config(local_config=True)
+default_settings.lock()
+nolocal_settings = portage.config(local_config=False)
+nolocal_settings.lock()
+
+# =======
 # Classes
 # =======
 
 class Package(CPV):
 	"""Exposes the state of a given CPV."""
 
-	def __init__(self, cpv, validate=False):
+	def __init__(self, cpv, validate=False, local_config=True):
 		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)
 
+		if local_config:
+			self._settings = default_settings
+		else:
+			self._settings = nolocal_settings
+
 		# Set dynamically
 		self._package_path = None
 		self._dblink = None
@@ -123,8 +136,8 @@ class Package(CPV):
 			self._dblink = portage.dblink(
 				self.category,
 				"%s-%s" % (self.name, self.fullversion),
-				settings["ROOT"],
-				settings
+				self._settings["ROOT"],
+				self._settings
 			)
 
 		return self._dblink
@@ -209,17 +222,16 @@ class Package(CPV):
 
 		return bool(PORTDB.cpv_exists(self.cpv))
 
-	@staticmethod
-	def settings(key):
+	def settings(self, key):
 		"""Returns the value of the given key for this package (useful
 		for package.* files."""
 
-		if settings.locked:
-			settings.unlock()
+		if self._settings.locked:
+			self._settings.unlock()
 		try:
-			result = settings[key]
+			result = self._settings[key]
 		finally:
-			settings.lock()
+			self._settings.lock()
 		return result
 
 	def mask_status(self):
@@ -234,11 +246,11 @@ class Package(CPV):
 			'missing keyword'
 		"""
 
-		if settings.locked:
-			settings.unlock()
+		if self._settings.locked:
+			self._settings.unlock()
 		try:
 			result = portage.getmaskingstatus(self.cpv,
-				settings=settings,
+				settings=self._settings,
 				portdb=PORTDB)
 		except KeyError:
 			# getmaskingstatus doesn't support packages without ebuilds in the
@@ -257,7 +269,7 @@ class Package(CPV):
 
 		try:
 			result = portage.getmaskingreason(self.cpv,
-				settings=settings,
+				settings=self._settings,
 				portdb=PORTDB,
 				return_location=True)
 			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 = os.path.realpath(settings["PORTDIR"])
+			self._portdir_path = os.path.realpath(self._settings["PORTDIR"])
 		return (tree and tree != self._portdir_path)
 
 	def is_masked(self):



             reply	other threads:[~2011-07-16  3:21 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-16  3:21 Paul Varner [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-06-02 22:10 [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/ Paul Varner
2014-02-22 19:28 Brian Dolbec
2013-03-12 16:06 Mike Frysinger
2013-01-04 22:23 Paul Varner
2012-12-30 20:25 Brian Dolbec
2012-11-13 20:40 Paul Varner
2012-11-13 20:40 Paul Varner
2012-11-13 20:40 Paul Varner
2012-11-13 20:40 Paul Varner
2012-11-13 20:40 Paul Varner
2012-11-13 20:40 Paul Varner
2012-11-13 20:40 Paul Varner
2012-11-13 20:40 Paul Varner
2012-11-13 20:40 Paul Varner
2012-11-13 20:40 Paul Varner
2012-11-13 20:40 Paul Varner
2012-11-13 20:40 Paul Varner
2012-11-13 20:40 Paul Varner
2012-11-13 20:40 Paul Varner
2012-11-13 20:40 Paul Varner
2012-11-13 20:40 Paul Varner
2012-10-09 21:35 Paul Varner
2012-08-01  3:34 Brian Dolbec
2012-07-24 17:18 Paul Varner
2012-05-16 21:18 Paul Varner
2012-03-02  0:01 Brian Dolbec
2011-12-23  6:05 Brian Dolbec
2011-07-16  4:04 Paul Varner
2011-07-15 20:02 Paul Varner
2011-05-23  3:45 Brian Dolbec
2011-05-20  5:54 Brian Dolbec
2011-05-18 21:18 Brian Dolbec
2011-04-18 18:28 Paul Varner
2011-03-31 21:53 Paul Varner
2011-02-23  9:10 Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e93234d3f899e2e5577b8085bbfd90c7447576cd.fuzzyray@gentoo \
    --to=fuzzyray@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox