4.3.0r12
[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 == "" and x[0] == '4097':
17                                         # lookup 1_* instead of 4097_*
18                                         pngname = findPicon('1_'+'_'.join(x[1:10]))
19                                         if pngname == "": # no picon for service found
20                                                 pngname = nameCache.get("default", "")
21                                                 if pngname == "": # no default yet in cache..
22                                                         pngname = findPicon("picon_default")
23                                                         if pngname != "":
24                                                                 nameCache["default"] = pngname
25                 if pngname != "":
26                         nameCache[name] = pngname
27                 return pngname