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