fbi_theme_preview_v1.py 文件源码

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

项目:FBIThemePreviewer 作者: jurassicplayer 项目源码 文件源码
def loadConfig(self, config_dict, filename, argb_check=False):
        print("Loading config: {}".format(filename))
        if os.path.isfile(filename):
            with open(filename) as f:
                config_content = [line.rstrip('\n') for line in f]
            malformed_color = []
            for key in config_dict:
                for line in config_content:
                    value = line.split("=")[1]
                    if key == line.split("=")[0]:
                        if argb_check:
                            argbstring = re.compile(r'[a-fA-F0-9]{8}$')
                            if argbstring.match(value):
                                A = value[:2]
                                RGB = swapRGBBGR(value[2:])
                                config_dict.update({key : {'rgb' : RGB, 'alpha' : A} })
                            else:
                                malformed_color.append(line)
                        else:
                            if key == "screen_gap" or key == "anim_duration":
                                try:
                                    value = int(value)
                                except:
                                    value = config_dict[key]
                            config_dict.update({key : value})
            if malformed_color:
                malformed_color.sort()
                messagebox.showwarning("Error", "Malformed text color (ABGR):\n{}".format('\n'.join(malformed_color)))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号