import_vdf.py 文件源码

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

项目:sc-controller 作者: kozec 项目源码 文件源码
def _load_game_names(self):
        """
        Loads names for game ids in q_games.

        This is done in thread (not in same thread as _load_profiles),
        because it involves searching for apropriate file and parsing it
        entirely.

        Calls GLib.idle_add to send loaded data into UI.
        """
        sa_path = self._find_steamapps()
        while True:
            self._s_games.acquire(True) # Wait until something is added to the queue
            try:
                index, gameid = self._q_games.popleft()
            except IndexError:
                break
            if gameid.isdigit():
                name = _("Unknown App ID %s") % (gameid)
                filename = os.path.join(sa_path, "appmanifest_%s.acf" % (gameid,))
                self._lock.acquire()
                if os.path.exists(filename):
                    try:
                        data = parse_vdf(open(filename, "r"))
                        name = data['appstate']['name']
                    except Exception, e:
                        log.error("Failed to load app manifest for '%s'", gameid)
                        log.exception(e)
                else:
                    log.warning("Skiping non-existing app manifest '%s'", filename)
                self._lock.release()
            else:
                name = gameid
            GLib.idle_add(self._set_game_name, index, name)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号