From bf52e20ac1d227427cddfdef1437e33a55ab502b Mon Sep 17 00:00:00 2001 From: Felix Domke Date: Mon, 14 Apr 2008 23:27:01 +0000 Subject: add 'progress' source, 'progress to text' converter --- lib/python/Components/Converter/Makefile.am | 3 +-- lib/python/Components/Converter/ProgressToText.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 lib/python/Components/Converter/ProgressToText.py (limited to 'lib/python/Components/Converter') diff --git a/lib/python/Components/Converter/Makefile.am b/lib/python/Components/Converter/Makefile.am index 0fff9c8d..331a6dc0 100644 --- a/lib/python/Components/Converter/Makefile.am +++ b/lib/python/Components/Converter/Makefile.am @@ -5,5 +5,4 @@ install_PYTHON = \ Poll.py RemainingToText.py StringList.py ServiceName.py FrontendInfo.py ServiceInfo.py \ ConditionalShowHide.py ServicePosition.py ValueRange.py RdsInfo.py Streaming.py \ StaticMultiList.py ServiceTime.py MovieInfo.py MenuEntryCompare.py StringListSelection.py \ - ValueBitTest.py TunerInfo.py ConfigEntryTest.py TemplatedMultiContent.py - + ValueBitTest.py TunerInfo.py ConfigEntryTest.py TemplatedMultiContent.py ProgressToText.py \ No newline at end of file diff --git a/lib/python/Components/Converter/ProgressToText.py b/lib/python/Components/Converter/ProgressToText.py new file mode 100644 index 00000000..0ad3a88c --- /dev/null +++ b/lib/python/Components/Converter/ProgressToText.py @@ -0,0 +1,22 @@ +from Components.Converter.Converter import Converter +from Components.Element import cached + +class ProgressToText(Converter, object): + def __init__(self, type): + Converter.__init__(self, type) + self.in_percent = "InPercent" in type.split(',') + + @cached + def getText(self): + r = self.source.range + v = self.source.value + + if self.in_percent: + if r: + return "%d %%" % (v * 100 / r) + else: + return None + else: + return "%d / %d" % (v, r) + + text = property(getText) -- cgit v1.2.3