4.5.1r7
[enigma2.git] / usr / lib / enigma2 / python / Tools / PiconResolver.py
1 class PiconResolver(object):
2         @staticmethod
3         def getPngName(ref, nameCache, findPicon):
4                 x = ref.split(':')
5                 if len(x) < 11: # skip invalid service references
6                         return ""
7                 del x[x[10] and 11 or 10:] # remove name and empty path
8                 x[1]='0' #replace flags field
9                 name = '_'.join(x).strip('_')
10                 pngname = nameCache.get(name, "")
11                 if pngname == "":
12                         pngname = findPicon(name)
13                         if pngname == "":
14                                 # lookup without path
15                                 pngname = findPicon('_'.join(x[:10]))
16                                 if pngname == "":
17                                         if x[0] in ('4097', '8193'): 
18                                                 # lookup 1_* instead of 4097_*
19                                                 pngname = findPicon('1_'+'_'.join(x[1:10]))
20                                         # DVB-T(2)
21                                         elif int(x[0]) == 1 and (int(x[6], 16) & 0xFFFF0000) == 0xEEEE0000:
22                                                 x[6] = '{:02X}'.format(0xEEEE0000)
23                                                 pngname = findPicon('1_'+'_'.join(x[1:10]))
24                                         if pngname == "": # no picon for service found
25                                                 pngname = nameCache.get("default", "")
26                                                 if pngname == "": # no default yet in cache..
27                                                         pngname = findPicon("picon_default")
28                                                         if pngname != "":
29                                                                 nameCache["default"] = pngname
30                 if pngname != "":
31                         nameCache[name] = pngname
32                 return pngname