public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Brian Dolbec" <brian.dolbec@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/eshowkw/
Date: Fri, 25 Feb 2011 02:23:29 +0000 (UTC)	[thread overview]
Message-ID: <897833f0abc06b88849c7df76de6ef0f4023d767.dol-sen@gentoo> (raw)

commit:     897833f0abc06b88849c7df76de6ef0f4023d767
Author:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Fri Feb 25 01:53:01 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Feb 25 01:53:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=897833f0

move mysettings out of __getMaskStatus() into __init__() so it is only done once = 1/7th the time to run.
decorate functions not needing self with @staticmethod.

---
 pym/gentoolkit/eshowkw/keywords_content.py |   33 +++++++++++++++++----------
 1 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/pym/gentoolkit/eshowkw/keywords_content.py b/pym/gentoolkit/eshowkw/keywords_content.py
index a8ffedc..637c99a 100644
--- a/pym/gentoolkit/eshowkw/keywords_content.py
+++ b/pym/gentoolkit/eshowkw/keywords_content.py
@@ -34,7 +34,8 @@ class keywords_content:
 			# this is required because the list itself is not just one level depth
 			return list(''.join(output))
 
-		def __uniq(self, seq):
+		@staticmethod
+		def __uniq(seq):
 			"""Remove all duplicate elements from list."""
 			seen = {}
 			result = []
@@ -45,7 +46,8 @@ class keywords_content:
 				result.append(item)
 			return result
 
-		def __cleanKeyword(self, keyword):
+		@staticmethod
+		def __cleanKeyword(keyword):
 			"""Remove masked arches and hardmasks from keywords since we don't care about that."""
 			return ["%s" % x for x in keyword.split()
 				if x != '-*' and not x.startswith('-')]
@@ -137,8 +139,7 @@ class keywords_content:
 		def __getMaskStatus(self, cpv):
 			"""Figure out if package is pmasked."""
 			try:
-				mysettings = port.config(local_config=False)
-				if "package.mask" in port.getmaskingstatus(cpv, settings=mysettings):
+				if "package.mask" in port.getmaskingstatus(cpv, settings=self.mysettings):
 					return True
 			except:
 				# occurs when package is not known by portdb
@@ -146,17 +147,20 @@ class keywords_content:
 				pass
 			return False
 
+
 		def __getInstallStatus(self, cpv):
 			"""Check if package version we test is installed."""
-			vartree = port.db[port.settings['ROOT']]['vartree'].dbapi
-			return vartree.cpv_exists(cpv)
+			return self.vartree.cpv_exists(cpv)
 
 		def __init__(self, packages):
 			"""Query all relevant data for version data formatting"""
+			self.vartree = port.db[port.settings['ROOT']]['vartree'].dbapi
+			self.mysettings = port.config(local_config=False)
 			self.versions = self.__getVersions(packages)
 			self.masks = map(lambda x: self.__getMaskStatus(x), packages)
 
-	def __packages_sort(self, package_content):
+	@staticmethod
+	def __packages_sort(package_content):
 		"""
 		Sort packages queried based on version and slot
 		%% pn , repo, slot, keywords
@@ -218,7 +222,8 @@ class keywords_content:
 			raise SystemExit(msg_err)
 		return list(zip(*matches))
 
-	def __getMetadata(self, pdb, package, repo):
+	@staticmethod
+	def __getMetadata(pdb, package, repo):
 		"""Obtain all required metadata from portage auxdb"""
 		try:
 			metadata = pdb.aux_get(package, ['KEYWORDS', 'SLOT'], repo)
@@ -235,7 +240,8 @@ class keywords_content:
 			for i, arch in enumerate(keywords_list)])
 				for version in keywords]
 
-	def __prepareKeywordChar(self, arch, field, keywords, usebold = False, toplist = 'archlist'):
+	@staticmethod
+	def __prepareKeywordChar(arch, field, keywords, usebold = False, toplist = 'archlist'):
 		"""
 		Convert specified keywords for package into their visual replacements.
 		# possibilities:
@@ -262,7 +268,8 @@ class keywords_content:
 			char = colorize('bold', char)
 		return char
 
-	def __formatVersions(self, versions, align, length):
+	@staticmethod
+	def __formatVersions(versions, align, length):
 		"""Append colors and align keywords properly"""
 		# % are used as separators for further split so we wont loose spaces and coloring
 		tmp = []
@@ -279,7 +286,8 @@ class keywords_content:
 				tmp.append(pv)
 		return tmp
 
-	def __formatAdditional(self, additional, color, length):
+	@staticmethod
+	def __formatAdditional(additional, color, length):
 		"""Align additional items properly"""
 		# % are used as separators for further split so we wont loose spaces and coloring
 		tmp = []
@@ -294,7 +302,8 @@ class keywords_content:
 			tmp.append(x)
 		return tmp
 
-	def __prepareContentResult(self, versions, keywords, redundant, slots, slot_length, repos, linesep):
+	@staticmethod
+	def __prepareContentResult(versions, keywords, redundant, slots, slot_length, repos, linesep):
 		"""Parse version fields into one list with proper separators"""
 		content = []
 		oldslot = ''



             reply	other threads:[~2011-02-25  2:23 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-25  2:23 Brian Dolbec [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-08-09 20:14 [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/eshowkw/ Michał Górny
2012-05-16 21:59 Paul Varner
2012-05-08 21:06 Paul Varner
2012-04-11 15:01 Paul Varner
2011-05-29 10:59 Christian Ruppert
2011-05-16 16:40 Brian Dolbec
2011-02-25  2:23 Brian Dolbec
2011-02-24 21:49 Christian Ruppert
2011-02-24 21:41 Christian Ruppert

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=897833f0abc06b88849c7df76de6ef0f4023d767.dol-sen@gentoo \
    --to=brian.dolbec@gmail.com \
    --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