diff options
| author | Felix Domke <tmbinc@elitedvb.net> | 2006-07-30 22:56:43 +0000 |
|---|---|---|
| committer | Felix Domke <tmbinc@elitedvb.net> | 2006-07-30 22:56:43 +0000 |
| commit | 1557c715e461d5a7deb04bb008c6497441351bbe (patch) | |
| tree | 8a378b20ca3bebab0b2eca1742c10dfd746cb2a1 /lib/python/Components/Converter | |
| parent | b8783e5b26a7dd0601bece623c4cbfe19f57977b (diff) | |
| download | enigma2-1557c715e461d5a7deb04bb008c6497441351bbe.tar.gz enigma2-1557c715e461d5a7deb04bb008c6497441351bbe.zip | |
some minor speedups using caches and more selective updating
Diffstat (limited to 'lib/python/Components/Converter')
| -rw-r--r-- | lib/python/Components/Converter/ConditionalShowHide.py | 2 | ||||
| -rw-r--r-- | lib/python/Components/Converter/EventName.py | 5 | ||||
| -rw-r--r-- | lib/python/Components/Converter/EventTime.py | 10 | ||||
| -rw-r--r-- | lib/python/Components/Converter/Poll.py | 5 | ||||
| -rw-r--r-- | lib/python/Components/Converter/ServiceInfo.py | 22 | ||||
| -rw-r--r-- | lib/python/Components/Converter/ServiceName.py | 6 | ||||
| -rw-r--r-- | lib/python/Components/Converter/ServicePosition.py | 8 |
7 files changed, 40 insertions, 18 deletions
diff --git a/lib/python/Components/Converter/ConditionalShowHide.py b/lib/python/Components/Converter/ConditionalShowHide.py index 9f1f86b2..cc98288f 100644 --- a/lib/python/Components/Converter/ConditionalShowHide.py +++ b/lib/python/Components/Converter/ConditionalShowHide.py @@ -6,6 +6,6 @@ class ConditionalShowHide(Converter, object): Converter.__init__(self, type) self.invert = type == "Invert" - def changed(self): + def changed(self, what): for x in self.downstream_elements: x.visible = self.source.boolean diff --git a/lib/python/Components/Converter/EventName.py b/lib/python/Components/Converter/EventName.py index 2b95d945..f128133a 100644 --- a/lib/python/Components/Converter/EventName.py +++ b/lib/python/Components/Converter/EventName.py @@ -15,6 +15,11 @@ class EventName(Converter, object): self.type = self.NAME def getText(self): + if self.cache is None: + self.cache = self.__getText() + return self.cache + + def __getText(self): event = self.source.event if event is None: return "N/A" diff --git a/lib/python/Components/Converter/EventTime.py b/lib/python/Components/Converter/EventTime.py index 09fe6bff..4a73e0ac 100644 --- a/lib/python/Components/Converter/EventTime.py +++ b/lib/python/Components/Converter/EventTime.py @@ -30,6 +30,11 @@ class EventTime(Poll, Converter, object): raise str("'%s' is not <StartTime|EndTime|Remaining|Duration> for EventTime converter" % type) def getTime(self): + if self.cache is None or self.cache[0] is None: + self.cache = (self.__getTime(), self.cache and self.cache[1]) + return self.cache[0] + + def __getTime(self): assert self.type != self.PROGRESS event = self.source.event @@ -53,6 +58,11 @@ class EventTime(Poll, Converter, object): return (duration, None) def getValue(self): + if self.cache is None or self.cache[1] is None: + self.cache = (self.cache and self.cache[0], self.__getValue()) + return self.cache[1] + + def __getValue(self): assert self.type == self.PROGRESS event = self.source.event diff --git a/lib/python/Components/Converter/Poll.py b/lib/python/Components/Converter/Poll.py index 3ba5e87f..2b81e325 100644 --- a/lib/python/Components/Converter/Poll.py +++ b/lib/python/Components/Converter/Poll.py @@ -3,7 +3,7 @@ from enigma import eTimer class Poll(object): def __init__(self): self.__poll_timer = eTimer() - self.__poll_timer.timeout.get().append(self.changed) + self.__poll_timer.timeout.get().append(self.poll) self.__interval = 1000 self.__enabled = False @@ -20,3 +20,6 @@ class Poll(object): poll_interval = property(lambda self: self.__interval, __setInterval) poll_enabled = property(lambda self: self.__enabled, __setEnable) + + def poll(self): + self.changed((self.CHANGED_POLL,)) diff --git a/lib/python/Components/Converter/ServiceInfo.py b/lib/python/Components/Converter/ServiceInfo.py index f9b65c19..e1351c56 100644 --- a/lib/python/Components/Converter/ServiceInfo.py +++ b/lib/python/Components/Converter/ServiceInfo.py @@ -19,11 +19,11 @@ class ServiceInfo(Converter, object): }[type] self.interesting_events = { - self.HAS_TELETEXT: [iPlayableService.evEnd, iPlayableService.evUpdatedInfo], - self.IS_MULTICHANNEL: [iPlayableService.evUpdatedInfo, iPlayableService.evEnd], - self.IS_CRYPTED: [iPlayableService.evUpdatedInfo, iPlayableService.evEnd], - self.IS_WIDESCREEN: [iPlayableService.evUpdatedEventInfo, iPlayableService.evEnd], - self.SUBSERVICES_AVAILABLE: [iPlayableService.evUpdatedEventInfo, iPlayableService.evEnd] + self.HAS_TELETEXT: [iPlayableService.evUpdatedInfo], + self.IS_MULTICHANNEL: [iPlayableService.evUpdatedInfo], + self.IS_CRYPTED: [iPlayableService.evUpdatedInfo], + self.IS_WIDESCREEN: [iPlayableService.evUpdatedEventInfo], + self.SUBSERVICES_AVAILABLE: [iPlayableService.evUpdatedEventInfo] }[self.type] def getServiceInfoValue(self, info, what): @@ -33,6 +33,11 @@ class ServiceInfo(Converter, object): return info.getInfoString(what) def getBoolean(self): + if self.cache is None: + self.cache = self.__getBoolean() + return self.cache + + def __getBoolean(self): service = self.source.service info = service and service.info() if not info: @@ -62,7 +67,6 @@ class ServiceInfo(Converter, object): boolean = property(getBoolean) - def changed(self, *args): - if not len(args) or args[0] in [iPlayableService.evStart, iPlayableService.evEnd, - iPlayableService.evUpdatedInfo, iPlayableService.evUpdatedEventInfo]: - Converter.changed(self) + def changed(self, what): + if what[0] != self.CHANGED_SPECIFIC or what[1] in self.interesting_events: + Converter.changed(self, what) diff --git a/lib/python/Components/Converter/ServiceName.py b/lib/python/Components/Converter/ServiceName.py index 78a3dca2..cffe494d 100644 --- a/lib/python/Components/Converter/ServiceName.py +++ b/lib/python/Components/Converter/ServiceName.py @@ -31,6 +31,6 @@ class ServiceName(Converter, object): text = property(getText) - def changed(self, *args): - if not len(args) or args[0] in [iPlayableService.evStart, iPlayableService.evEnd]: - Converter.changed(self) + def changed(self, what): + if what[0] != self.CHANGED_SPECIFIC or what[1] in [iPlayableService.evStart]: + Converter.changed(self, what) diff --git a/lib/python/Components/Converter/ServicePosition.py b/lib/python/Components/Converter/ServicePosition.py index e072aa5e..dfb792ad 100644 --- a/lib/python/Components/Converter/ServicePosition.py +++ b/lib/python/Components/Converter/ServicePosition.py @@ -70,13 +70,13 @@ class ServicePosition(Converter, Poll, object): cutlist = property(getCutlist) text = property(getText) - def changed(self, *args): - cutlist_refresh = len(args) and args[0] in [iPlayableService.evCuesheetChanged, iPlayableService.evStart, iPlayableService.evEnd] - time_refresh = not len(args) or args[0] in [iPlayableService.evStart, iPlayableService.evEnd] + def changed(self, what): + cutlist_refresh = what[0] != self.CHANGED_SPECIFIC or what[1] in [iPlayableService.evCuesheetChanged] + time_refresh = what[0] == self.CHANGED_POLL or what[0] == self.CHANGED_SPECIFIC and what[1] in [iPlayableService.evCuesheetChanged] if cutlist_refresh: if self.type == self.TYPE_GAUGE: self.downstream_elements.cutlist_changed() if time_refresh: - self.downstream_elements.changed() + self.downstream_elements.changed(what) |
