some minor speedups using caches and more selective updating
[enigma2.git] / lib / python / Components / Converter / EventName.py
1 from Components.Converter.Converter import Converter
2
3 class EventName(Converter, object):
4         NAME = 0
5         SHORT_DESCRIPTION = 1
6         EXTENDED_DESCRIPTION = 2
7
8         def __init__(self, type):
9                 Converter.__init__(self, type)
10                 if type == "Description":
11                         self.type = self.SHORT_DESCRIPTION
12                 elif type == "ExtendedDescription":
13                         self.type = self.EXTENDED_DESCRIPTION
14                 else:
15                         self.type = self.NAME
16
17         def getText(self):
18                 if self.cache is None:
19                         self.cache = self.__getText()
20                 return self.cache
21
22         def __getText(self):
23                 event = self.source.event
24                 if event is None:
25                         return "N/A"
26                         
27                 if self.type == self.NAME:
28                         return event.getEventName()
29                 elif self.type == self.SHORT_DESCRIPTION:
30                         return event.getShortDescription()
31                 elif self.type == self.EXTENDED_DESCRIPTION:
32                         return event.getExtendedDescription()
33                         
34         text = property(getText)