Gentoo Archives: gentoo-commits

From: "Michał Górny" <mgorny@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/gentoopm:master commit in: gentoopm/basepm/
Date: Tue, 26 Jul 2011 21:02:05
Message-Id: 763280601768fdbea58a4824d5d6d35b1b66888a.mgorny@gentoo
1 commit: 763280601768fdbea58a4824d5d6d35b1b66888a
2 Author: Michał Górny <mgorny <AT> gentoo <DOT> org>
3 AuthorDate: Tue Jul 26 19:37:20 2011 +0000
4 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
5 CommitDate: Tue Jul 26 19:41:54 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/gentoopm.git;a=commit;h=76328060
7
8 Introduce an abstract API for getting IUSE.
9
10 ---
11 gentoopm/basepm/pkg.py | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
12 1 files changed, 48 insertions(+), 0 deletions(-)
13
14 diff --git a/gentoopm/basepm/pkg.py b/gentoopm/basepm/pkg.py
15 index d4f421f..b92a9cc 100644
16 --- a/gentoopm/basepm/pkg.py
17 +++ b/gentoopm/basepm/pkg.py
18 @@ -70,6 +70,45 @@ class PMPackageDescription(ABCObject, StringCompat):
19 """
20 return str(self.long or self.short)
21
22 +class PMUseFlag(ABCObject, StringCompat):
23 + """
24 + A base class for a USE flag supported by a package.
25 + """
26 +
27 + def __init__(self, usestr):
28 + """
29 + Instantiate from an IUSE atom.
30 +
31 + @param usestr: the IUSE atom (C{[+-]?flag})
32 + @type usestr: string
33 + """
34 + self._default = None
35 + if usestr[0] in ('-', '+'):
36 + self._default = (usestr[0] == '+')
37 + usestr = usestr[1:]
38 + self._name = usestr
39 +
40 + @property
41 + def default(self):
42 + """
43 + The default state, if provided by the ebuild.
44 +
45 + @type: bool/C{None}
46 + """
47 + return self._default
48 +
49 + @property
50 + def name(self):
51 + """
52 + The flag name.
53 +
54 + @type: string
55 + """
56 + return self._name
57 +
58 + def __str__(self):
59 + return self.name
60 +
61 class PMPackage(PMAtom, FillMissingComparisons):
62 """
63 An abstract class representing a single, uniquely-identified package
64 @@ -240,6 +279,15 @@ class PMPackage(PMAtom, FillMissingComparisons):
65 """
66 pass
67
68 + @property
69 + def use(self):
70 + """
71 + Get the list of USE flags declared in the ebuild (C{IUSE}).
72 +
73 + @type: L{SpaceSepTuple}(L{PMUseFlag})
74 + """
75 + pass
76 +
77 @abstractproperty
78 def slotted(self):
79 """