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 1QPGtA-00075B-Ga for garchives@archives.gentoo.org; Wed, 25 May 2011 16:24:52 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id EC95F1C09E; Wed, 25 May 2011 16:24:43 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id BCDEF1C09E for ; Wed, 25 May 2011 16:24:43 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 3D4F01B4037 for ; Wed, 25 May 2011 16:24:43 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id A800B8050A for ; Wed, 25 May 2011 16:24:42 +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: <1a379e673441e5f4b9e6a7c6fe133fdbda59ae01.mgorny@gentoo> Subject: [gentoo-commits] proj/pms-test-suite:master commit in: PMSTestSuite/pm/ X-VCS-Repository: proj/pms-test-suite X-VCS-Files: PMSTestSuite/pm/__init__.py PMSTestSuite/pm/portage.py X-VCS-Directories: PMSTestSuite/pm/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 1a379e673441e5f4b9e6a7c6fe133fdbda59ae01 Date: Wed, 25 May 2011 16:24:42 +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: f34cc560c3edd69f84b1206d67dd6a2a commit: 1a379e673441e5f4b9e6a7c6fe133fdbda59ae01 Author: Micha=C5=82 G=C3=B3rny gentoo org> AuthorDate: Wed May 25 16:24:37 2011 +0000 Commit: Micha=C5=82 G=C3=B3rny gentoo org> CommitDate: Wed May 25 16:24:37 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/pms-test-suit= e.git;a=3Dcommit;h=3D1a379e67 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 @@ =20 """ >>> pms =3D 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 +'...' """ =20 class PackageManager(object): @@ -28,8 +30,13 @@ class PackageManager(object): raise NotImplementedError('Please override the pkg property.') =20 @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 meth= od.') =20 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 . """ self._pmclass =3D pmclass =20 + @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 =20 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=C5=82 G=C3=B3rny # Released under the terms of the 2-clause BSD license. =20 +import os + from PMSTestSuite.pm import PackageManager =20 class PortagePM(PackageManager): """ A class implementing the interfaces to the Portage PM. """ name =3D 'portage' pkg =3D 'sys-apps/portage' + + @classmethod + def is_available(cls): + return os.access('/usr/bin/emerge', os.X_OK)