ServicePosition.py: add Option "ShowNoSeconds"
authorghost <andreas.monzner@multimedia-labs.de>
Tue, 9 Dec 2008 22:37:05 +0000 (23:37 +0100)
committerghost <andreas.monzner@multimedia-labs.de>
Tue, 9 Dec 2008 22:37:05 +0000 (23:37 +0100)
lib/python/Components/Converter/ServicePosition.py

index b488258b11a822926cb351cc6c9cbb7cf6a213cb..d7a55daea47ce81cc5f1bb4b04f8fcc7461ed5e1 100644 (file)
@@ -19,6 +19,7 @@ class ServicePosition(Converter, Poll, object):
                self.negate = 'Negate' in args
                self.detailed = 'Detailed' in args
                self.showHours = 'ShowHours' in args
+               self.showNoSeconds = 'ShowNoSeconds' in args
 
                if self.detailed:
                        self.poll_interval = 100
@@ -34,7 +35,7 @@ class ServicePosition(Converter, Poll, object):
                elif type == "Gauge":
                        self.type = self.TYPE_GAUGE
                else:
-                       raise "type must be {Length|Position|Remaining|Gauge} with optional arguments {Negate|Detailed|ShowHours}"
+                       raise "type must be {Length|Position|Remaining|Gauge} with optional arguments {Negate|Detailed|ShowHours|NoSeconds}"
 
                self.poll_enabled = self.type != self.TYPE_LENGTH
 
@@ -94,9 +95,15 @@ class ServicePosition(Converter, Poll, object):
 
                        if not self.detailed:
                                if self.showHours:
-                                       return sign + "%d:%02d:%02d" % (l/3600, l%3600/60, l%60)
+                                       if self.showNoSeconds:
+                                               return sign + "%d:%02d" % (l/3600, l%3600/60)
+                                       else:
+                                               return sign + "%d:%02d:%02d" % (l/3600, l%3600/60, l%60)
                                else:
-                                       return sign + "%d:%02d" % (l/60, l%60)
+                                       if self.showNoSeconds:
+                                               return sign + "%d" % (l/60)
+                                       else:
+                                               return sign + "%d:%02d" % (l/60, l%60)
                        else:
                                if self.showHours:
                                        return sign + "%d:%02d:%02d:%03d" % ((l/3600/90000), (l/90000)%3600/60, (l/90000)%60, (l%90000)/90)