handle additional arguments
[enigma2.git] / lib / python / Components / Converter / ServiceName.py
1 from Components.Converter.Converter import Converter
2 from enigma import iServiceInformation, iPlayableService
3
4 class ServiceName(Converter, object):
5         NAME = 0
6         PROVIDER = 1
7
8         def __init__(self, type, *args, **kwargs):
9                 Converter.__init__(self)
10                 if type == "Provider":
11                         self.type = self.PROVIDER
12                 else:
13                         self.type = self.NAME
14
15         def getServiceInfoValue(self, info, what):
16                 v = info.getInfo(what)
17                 if v != -2:
18                         return "N/A"
19                 return info.getInfoString(what)
20
21         def getText(self):
22                 service = self.source.service
23                 info = service and service.info()
24                 if info is None:
25                         return ""
26                 
27                 if self.type == self.NAME:
28                         return info.getName()
29                 elif self.type == self.PROVIDER:
30                         return self.getServiceInfoValue(info, iServiceInformation.sProvider)
31
32         text = property(getText)
33
34         def changed(self, *args):
35                 if not len(args) or args[0] in [iPlayableService.evStart, iPlayableService.evEnd]:
36                         Converter.changed(self)