From 805d67b185691d7b5ff997d69a5b53460d69a66a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <101191390+HIllya51@users.noreply.github.com> Date: Wed, 17 Jul 2024 16:10:17 +0800 Subject: [PATCH] fix --- LunaTranslator/LunaTranslator/LunaTranslator.py | 14 ++++++++++++-- LunaTranslator/LunaTranslator/myutils/utils.py | 7 ------- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/LunaTranslator/LunaTranslator/LunaTranslator.py b/LunaTranslator/LunaTranslator/LunaTranslator.py index dfa0b0bb..a076f93a 100644 --- a/LunaTranslator/LunaTranslator/LunaTranslator.py +++ b/LunaTranslator/LunaTranslator/LunaTranslator.py @@ -23,6 +23,7 @@ from myutils.utils import ( find_or_create_uid, checkpostusing, stringfyerror, + targetmod, ) from myutils.wrapper import threader from gui.showword import searchwordW @@ -119,7 +120,7 @@ class MAINUI: class klass(kls): @property def using(self): - if 'using_X' in dir(self): + if "using_X" in dir(self): try: return self.using_X except: @@ -1188,7 +1189,7 @@ class MAINUI: def parsedefaultfont(self): for k in ["fonttype", "fonttype2", "settingfonttype"]: if globalconfig[k] == "": - l = "ja" if k=="fonttype" else getlanguse() + l = "ja" if k == "fonttype" else getlanguse() set_font_default(l, k) # globalconfig[k] = QFontDatabase.systemFont( # QFontDatabase.SystemFont.GeneralFont @@ -1197,6 +1198,7 @@ class MAINUI: def loadui(self): self.installeventfillter() self.parsedefaultfont() + self.loadmetadatas() self.translation_ui = QUnFrameWindow() self.translation_ui.show() self.translation_ui.aftershowdosomething() @@ -1256,6 +1258,14 @@ class MAINUI: self.__filter = WindowEventFilter() # keep ref QApplication.instance().installEventFilter(self.__filter) + def loadmetadatas(self): + + for k in globalconfig["metadata"]: + try: + targetmod[k] = importlib.import_module(f"metadata.{k}").searcher(k) + except: + print_exc() + def checklang(self): if globalconfig["language_setted_2.4.5"] == False: diff --git a/LunaTranslator/LunaTranslator/myutils/utils.py b/LunaTranslator/LunaTranslator/myutils/utils.py index 875b5135..7efb550e 100644 --- a/LunaTranslator/LunaTranslator/myutils/utils.py +++ b/LunaTranslator/LunaTranslator/myutils/utils.py @@ -655,13 +655,6 @@ class LRUCache: self.put(key) return _ - -for k in globalconfig["metadata"]: - try: - targetmod[k] = importlib.import_module(f"metadata.{k}").searcher(k) - except: - print_exc() - globalcachedmodule = {}