1 class PiconResolver(object):
3 def getPngName(ref, nameCache, findPicon):
5 if len(x) < 11: # skip invalid service references
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, "")
12 pngname = findPicon(name)
15 pngname = findPicon('_'.join(x[:10]))
17 if x[0] in ('4097', '8193'):
18 # lookup 1_* instead of 4097_*
19 pngname = findPicon('1_'+'_'.join(x[1:10]))
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")
29 nameCache["default"] = pngname
31 nameCache[name] = pngname