projects
/
tools
/
git-buildpackage.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
60ad28f
)
tristate: implement __nonzero__() method
author
Markus Lehtonen
<markus.lehtonen@linux.intel.com>
Mon, 2 Jun 2014 07:14:52 +0000
(10:14 +0300)
committer
Guido Günther
<agx@sigxcpu.org>
Fri, 20 Feb 2015 20:17:17 +0000
(21:17 +0100)
Returns False if tristate is 'off', otherwise True ('on' or 'auto').
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
gbp/tristate.py
patch
|
blob
|
history
diff --git
a/gbp/tristate.py
b/gbp/tristate.py
index 93610605e388b2dcf3c40e7e2f887a803206accd..0a800ecda2f4f53a8b2d5f6332fc73e30aeeed00 100644
(file)
--- a/
gbp/tristate.py
+++ b/
gbp/tristate.py
@@
-66,6
+66,17
@@
class Tristate(object):
else:
return 'off'
+ def __nonzero__(self):
+ """
+ >>> Tristate('on').__nonzero__()
+ True
+ >>> Tristate('auto').__nonzero__()
+ True
+ >>> Tristate('off').__nonzero__()
+ False
+ """
+ return self._state is not self.OFF
+
@property
def state(self):
"""Get current state"""