backuprestore.py 文件源码

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

项目:script.skin.helper.skinbackup 作者: marcelveldt 项目源码 文件源码
def clean_oldbackups(self):
        '''auto clean old backups'''
        backuppath = self.addon.getSetting("backup_path").decode("utf-8")
        max_backups = self.addon.getSetting("max_old_backups")
        if max_backups:
            max_backups = int(max_backups)
            all_files = []
            for filename in xbmcvfs.listdir(backuppath)[1]:
                if ".zip" in filename and "Skinbackup" in filename:
                    filename = filename.decode("utf-8")
                    filepath = backuppath + filename
                    filestat = xbmcvfs.Stat(filepath)
                    modified = filestat.st_mtime()
                    del filestat
                    log_msg(modified)
                    all_files.append((filepath, modified))
            if len(all_files) > max_backups:
                from operator import itemgetter
                old_files = sorted(all_files, key=itemgetter(1), reverse=True)[max_backups - 1:]
                for backupfile in old_files:
                    delete_file(backupfile[0])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号