Permalink
Browse files

Add pretty representation to BitwiseEnum type.

  • Loading branch information...
wagnerrp committed Sep 8, 2012
1 parent a625725 commit d29f6fb1642b9a1ff175f94f1b21947b38a317a0
Showing with 18 additions and 1 deletion.
  1. +18 −1 mythtv/bindings/python/MythTV/utility/enum.py
@@ -98,6 +98,23 @@ def _set_(self, other):
self.mode = other.mode
return self
def __iter__(self):
if self.mode == 0:
yield self.__class__(0)
else:
mode = self.mode
for m in self._values.values():
if m.value == 0: continue
if (m.value&mode) == m.value:
mode -= m.value
yield self.__class__(m.value)
def __str__(self):
modes = []
for mode in self:
modes.append(self._values[mode.mode].friendly)
return '|'.join(modes)
def __repr__(self):
return "<{0.__class__.__name__} {0.mode}>".format(self)
return "<{0.__class__.__name__} {0}>".format(self)

0 comments on commit d29f6fb

Please sign in to comment.