diff options
author | Markus Lehtonen <markus.lehtonen@linux.intel.com> | 2012-11-27 11:24:19 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2012-11-27 18:09:13 +0100 |
commit | c9011f78dd2a9c35f9fb5be4e77b08b775d25cc7 (patch) | |
tree | 827ff51374742ce8a72a1af98a60e7ea14bd6ef2 /gbp/tristate.py | |
parent | 5176d2a810b481702677417548c2ff8f79684e63 (diff) |
Tristate: allow to init from another Tristate object
Signed-off-by: Markus Lehtonen <markus.lehtonen@linux.intel.com>
Diffstat (limited to 'gbp/tristate.py')
-rw-r--r-- | gbp/tristate.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/gbp/tristate.py b/gbp/tristate.py index 67b1052..2fd9652 100644 --- a/gbp/tristate.py +++ b/gbp/tristate.py @@ -39,6 +39,8 @@ class Tristate(object): self._state = self.AUTO else: self._state = self.OFF + elif type(val) is Tristate: + self._state = val.state else: raise TypeError @@ -65,6 +67,11 @@ class Tristate(object): if state.lower() in self._VALID_NAMES: return True + @property + def state(self): + """Get current state""" + return self._state + def is_auto(self): return [False, True][self._state == self.AUTO] |