take care of servicegroups in doublecheck
[enigma2.git] / lib / python / Components / Converter / ProgressToText.py
1 from Components.Converter.Converter import Converter
2 from Components.Element import cached
3
4 class ProgressToText(Converter, object):
5         def __init__(self, type):
6                 Converter.__init__(self, type)
7                 self.in_percent = "InPercent" in type.split(',')
8
9         @cached
10         def getText(self):
11                 r = self.source.range
12                 v = self.source.value
13
14                 if self.in_percent:
15                         if r:
16                                 return "%d %%" % (v * 100 / r)
17                         else:
18                                 return None
19                 else:
20                         return "%d / %d" % (v, r)
21
22         text = property(getText)