public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/pm/
Date: Wed, 25 May 2011 16:24:42 +0000 (UTC)	[thread overview]
Message-ID: <1a379e673441e5f4b9e6a7c6fe133fdbda59ae01.mgorny@gentoo> (raw)

commit:     1a379e673441e5f4b9e6a7c6fe133fdbda59ae01
Author:     Michał Górny <mgorny <AT> gentoo <DOT> org>
AuthorDate: Wed May 25 16:24:37 2011 +0000
Commit:     Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Wed May 25 16:24:37 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/pms-test-suite.git;a=commit;h=1a379e67

Distinguish between installed and non-installed PMs.

---
 PMSTestSuite/pm/__init__.py |   22 ++++++++++++++++++----
 PMSTestSuite/pm/portage.py  |    6 ++++++
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/PMSTestSuite/pm/__init__.py b/PMSTestSuite/pm/__init__.py
index 9980659..27df2fa 100644
--- a/PMSTestSuite/pm/__init__.py
+++ b/PMSTestSuite/pm/__init__.py
@@ -4,8 +4,10 @@
 
 """
 >>> pms = get_package_managers()
->>> 'portage' in [str(x) for x in pms]
+>>> 'portage' in [x.name for x in pms]
 True
+>>> str(pms[0]) # doctest: +ELLIPSIS
+'...'
 """
 
 class PackageManager(object):
@@ -28,8 +30,13 @@ class PackageManager(object):
 		raise NotImplementedError('Please override the pkg property.')
 
 	@classmethod
-	def is_available(self):
-		pass
+	def is_available(cls):
+		"""
+		Check whether a particular PM is installed and executable.
+
+		Returns True if the PM is available, False otherwise.
+		"""
+		raise NotImplementedError('Please override the is_available class method.')
 
 def get_package_managers():
 	""" Return the list of supported Package Managers. """
@@ -42,8 +49,15 @@ def get_package_managers():
 			""" Instantiate the wrapper for PM class <pmclass>. """
 			self._pmclass = pmclass
 
+		@property
+		def name(self):
+			""" The name of associated PM. """
+			return self._pmclass.name
+
 		def __str__(self):
-			""" Return the name of associated PM. """
+			""" Return the human-readable name of associated PM. """
+			if not self._pmclass.is_available():
+				return '(%s)' % self._pmclass.name
 			return self._pmclass.name
 
 	return [PMWrapper(x) for x in (PortagePM,)]

diff --git a/PMSTestSuite/pm/portage.py b/PMSTestSuite/pm/portage.py
index 5c8abd8..7a21593 100644
--- a/PMSTestSuite/pm/portage.py
+++ b/PMSTestSuite/pm/portage.py
@@ -2,9 +2,15 @@
 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
+import os
+
 from PMSTestSuite.pm import PackageManager
 
 class PortagePM(PackageManager):
 	""" A class implementing the interfaces to the Portage PM. """
 	name = 'portage'
 	pkg = 'sys-apps/portage'
+
+	@classmethod
+	def is_available(cls):
+		return os.access('/usr/bin/emerge', os.X_OK)



             reply	other threads:[~2011-05-25 16:24 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-25 16:24 Michał Górny [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-08-08 21:31 [gentoo-commits] proj/pms-test-suite:master commit in: pmstestsuite/pm/ Michał Górny
2011-08-05 19:54 Michał Górny
2011-08-05 17:09 Michał Górny
2011-08-05 17:09 Michał Górny
2011-08-03 20:17 Michał Górny
2011-08-03 20:17 Michał Górny
2011-07-31 15:10 Michał Górny
2011-06-23  9:51 [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/pm/ Michał Górny
2011-06-23  9:51 Michał Górny
2011-06-23  9:51 Michał Górny
2011-06-23  9:51 Michał Górny
2011-06-21 21:25 Michał Górny
2011-06-21 20:58 Michał Górny
2011-06-21 20:58 Michał Górny
2011-06-21 20:58 Michał Górny
2011-06-21 20:58 Michał Górny
2011-06-21 20:58 Michał Górny
2011-06-21 17:58 Michał Górny
2011-06-21 17:54 Michał Górny
2011-06-21 17:54 Michał Górny
2011-06-21 17:54 Michał Górny
2011-06-21 17:54 Michał Górny
2011-06-21 15:26 Michał Górny
2011-06-21 15:26 Michał Górny
2011-06-20 19:20 Michał Górny
2011-06-16 19:49 Michał Górny
2011-06-16 19:49 Michał Górny
2011-06-14 12:35 Michał Górny
2011-06-07 17:16 Michał Górny
2011-06-07 17:16 Michał Górny
2011-06-07 15:20 Michał Górny
2011-06-07 14:54 Michał Górny
2011-06-06  7:36 Michał Górny
2011-05-31 21:06 Michał Górny
2011-05-31 19:18 Michał Górny
2011-05-31 19:18 Michał Górny
2011-05-31 12:14 Michał Górny
2011-05-31 12:14 Michał Górny
2011-05-29 18:57 Michał Górny
2011-05-29 18:57 Michał Górny
2011-05-26  9:45 Michał Górny
2011-05-25 16:24 Michał Górny

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=1a379e673441e5f4b9e6a7c6fe133fdbda59ae01.mgorny@gentoo \
    --to=mgorny@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