import_vdf.py 文件源码

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

项目:sc-controller 作者: kozec 项目源码 文件源码
def _parse_profile_list(self, i, filename):
        """
        Parses sharedconfig.vdf and loads game and profile IDs. That is later
        decoded into name of game and profile name.

        Called from _load_profiles, in thread. Exceptions are catched and logged
        from there.
        Calls GLib.idle_add to send loaded data into UI.
        """
        data = parse_vdf(open(filename, "r"))
        # Sanity check
        if "userroamingconfigstore" not in data: return
        if "controller_config" not in data["userroamingconfigstore"]: return
        # Grab config
        cc = data["userroamingconfigstore"]["controller_config"]
        # Go through all games
        listitems = []
        for gameid in cc:
            if "selected" in cc[gameid] and cc[gameid]["selected"].startswith("workshop"):
                profile_id = cc[gameid]["selected"].split("/")[-1]
                listitems.append(( i, gameid, profile_id, None ))
                i += 1
                if len(listitems) > 10:
                    GLib.idle_add(self.fill_list, listitems)
                    listitems = []

        GLib.idle_add(self.fill_list, listitems)
        return i
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号