LcdPicon.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:enigma2 作者: OpenLD 项目源码 文件源码
def getLcdPiconName(serviceName):
    #remove the path and name fields, and replace ':' by '_'
    sname = '_'.join(GetWithAlternative(serviceName).split(':', 10)[:10])
    pngname = findLcdPicon(sname)
    if not pngname:
        fields = sname.split('_', 3)
        if len(fields) > 2 and fields[2] != '1': #fallback to 1 for services with different service types
            fields[2] = '1'
        if len(fields) > 0 and fields[0] != '1': #fallback to 1 for other reftypes
            fields[0] = '1'
        pngname = findLcdPicon('_'.join(fields))
    if not pngname: # picon by channel name
        name = ServiceReference(serviceName).getServiceName()
        name = unicodedata.normalize('NFKD', unicode(name, 'utf_8', errors='ignore')).encode('ASCII', 'ignore')
        name = re.sub('[^a-z0-9]', '', name.replace('&', 'and').replace('+', 'plus').replace('*', 'star').lower())
        if len(name) > 0:
            pngname = findLcdPicon(name)
            if not pngname and len(name) > 2 and name.endswith('hd'):
                pngname = findLcdPicon(name[:-2])
    return pngname
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号