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 1QlolR-0000hw-9N for garchives@archives.gentoo.org; Tue, 26 Jul 2011 21:02:05 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E110F21C2C3 for ; Tue, 26 Jul 2011 21:02:04 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 2737821C240 for ; Tue, 26 Jul 2011 20:10:30 +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 92B152AC022 for ; Tue, 26 Jul 2011 20:10:29 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id B2BF48003D for ; Tue, 26 Jul 2011 20:10:28 +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: <763280601768fdbea58a4824d5d6d35b1b66888a.mgorny@gentoo> Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/ X-VCS-Repository: proj/gentoopm X-VCS-Files: gentoopm/basepm/pkg.py X-VCS-Directories: gentoopm/basepm/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 763280601768fdbea58a4824d5d6d35b1b66888a Date: Tue, 26 Jul 2011 20:10:28 +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: 1f5c2d51ffc56ad5819dbeaf0185ffa2 commit: 763280601768fdbea58a4824d5d6d35b1b66888a Author: Micha=C5=82 G=C3=B3rny gentoo org> AuthorDate: Tue Jul 26 19:37:20 2011 +0000 Commit: Micha=C5=82 G=C3=B3rny gentoo org> CommitDate: Tue Jul 26 19:41:54 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/gentoopm.git;= a=3Dcommit;h=3D76328060 Introduce an abstract API for getting IUSE. --- gentoopm/basepm/pkg.py | 48 ++++++++++++++++++++++++++++++++++++++++++= ++++++ 1 files changed, 48 insertions(+), 0 deletions(-) diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py index d4f421f..b92a9cc 100644 --- a/gentoopm/basepm/pkg.py +++ b/gentoopm/basepm/pkg.py @@ -70,6 +70,45 @@ class PMPackageDescription(ABCObject, StringCompat): """ return str(self.long or self.short) =20 +class PMUseFlag(ABCObject, StringCompat): + """ + A base class for a USE flag supported by a package. + """ + + def __init__(self, usestr): + """ + Instantiate from an IUSE atom. + + @param usestr: the IUSE atom (C{[+-]?flag}) + @type usestr: string + """ + self._default =3D None + if usestr[0] in ('-', '+'): + self._default =3D (usestr[0] =3D=3D '+') + usestr =3D usestr[1:] + self._name =3D usestr + + @property + def default(self): + """ + The default state, if provided by the ebuild. + + @type: bool/C{None} + """ + return self._default + + @property + def name(self): + """ + The flag name. + + @type: string + """ + return self._name + + def __str__(self): + return self.name + class PMPackage(PMAtom, FillMissingComparisons): """ An abstract class representing a single, uniquely-identified package @@ -240,6 +279,15 @@ class PMPackage(PMAtom, FillMissingComparisons): """ pass =20 + @property + def use(self): + """ + Get the list of USE flags declared in the ebuild (C{IUSE}). + + @type: L{SpaceSepTuple}(L{PMUseFlag}) + """ + pass + @abstractproperty def slotted(self): """