backuprestore.py 文件源码

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

项目:script.skin.helper.skinbackup 作者: marcelveldt 项目源码 文件源码
def backup_skinshortcuts_properties(propertiesfile, dest_path):
        '''parse skinshortcuts properties file and translate images'''
        # look for any backgrounds and translate them
        propfile = xbmcvfs.File(propertiesfile)
        data = propfile.read()
        propfile.close()
        allprops = eval(data) if data else []
        for count, prop in enumerate(allprops):
            if prop[2] == "background":
                background = prop[3] if prop[3] else ""
                defaultid = prop[1]
                if background.endswith(".jpg") or background.endswith(".png") or background.endswith(".gif"):
                    background = get_clean_image(background)
                    extension = background.split(".")[-1]
                    newthumb = os.path.join(dest_path, "%s-background-%s.%s" %
                                            (xbmc.getSkinDir(), normalize_string(defaultid), extension))
                    newthumb_vfs = "special://profile/addon_data/script.skinshortcuts/%s-background-%s.%s" % (
                        xbmc.getSkinDir(), normalize_string(defaultid), extension)
                    if xbmcvfs.exists(background):
                        copy_file(background, newthumb)
                        allprops[count] = [prop[0], prop[1], prop[2], newthumb_vfs]
        # write updated properties file
        propfile = xbmcvfs.File(propertiesfile, "w")
        propfile.write(repr(allprops))
        propfile.close()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号