diff --git a/LunaTranslator/LunaTranslator/LunaTranslator.py b/LunaTranslator/LunaTranslator/LunaTranslator.py index 724bc4fd..98aeea60 100644 --- a/LunaTranslator/LunaTranslator/LunaTranslator.py +++ b/LunaTranslator/LunaTranslator/LunaTranslator.py @@ -91,7 +91,12 @@ class MAINUI: @threader def safeloadprocessmodels(self): - for model in ["noundict", "gongxiangcishu", "transerrorfix", "myprocess"]: + for model, d, k in [ + ("noundict", noundictconfig, "use"), + ("transerrorfix", transerrorfixdictconfig, "use"), + ("gongxiangcishu", globalconfig["gongxiangcishu"], "use"), + ("myprocess", globalconfig, "selfdefinedprocesspair"), + ]: try: if model == "myprocess": mm = "myprocess" @@ -101,7 +106,17 @@ class MAINUI: checkpath = "./LunaTranslator/transoptimi/" + model + ".py" if os.path.exists(checkpath) == False: continue - klass = importlib.import_module(mm).Process() + Process = importlib.import_module(mm).Process + + def __(kls, _d, _k): + class klass(kls): + @property + def using(self): + return _d[_k] + + return klass() + + klass = __(Process, d, k) process_before = klass.process_before process_after = klass.process_after self.processmethods.append(klass) diff --git a/LunaTranslator/LunaTranslator/myutils/utils.py b/LunaTranslator/LunaTranslator/myutils/utils.py index 16308d73..a2fb8812 100644 --- a/LunaTranslator/LunaTranslator/myutils/utils.py +++ b/LunaTranslator/LunaTranslator/myutils/utils.py @@ -326,10 +326,6 @@ def POSTSOLVE(line): ff.write( """ class Process: - @property - def using(self): - return True - def process_before(self, text): context = {} return text, context diff --git a/LunaTranslator/LunaTranslator/transoptimi/gongxiangcishu.py b/LunaTranslator/LunaTranslator/transoptimi/gongxiangcishu.py index 733c6285..112fd235 100644 --- a/LunaTranslator/LunaTranslator/transoptimi/gongxiangcishu.py +++ b/LunaTranslator/LunaTranslator/transoptimi/gongxiangcishu.py @@ -87,9 +87,6 @@ def vnrshareddict(self): class Process: - @property - def using(self): - return globalconfig["gongxiangcishu"]["use"] def __init__(self) -> None: self.status = None @@ -133,4 +130,4 @@ class Process: for key, value in self.sorted_vnrshareddict_post: if key in res: res = res.replace(key, value["text"]) - return res \ No newline at end of file + return res diff --git a/LunaTranslator/LunaTranslator/transoptimi/noundict.py b/LunaTranslator/LunaTranslator/transoptimi/noundict.py index 123b2f62..a597e4d0 100644 --- a/LunaTranslator/LunaTranslator/transoptimi/noundict.py +++ b/LunaTranslator/LunaTranslator/transoptimi/noundict.py @@ -3,9 +3,6 @@ import gobject, re class Process: - @property - def using(self): - return noundictconfig["use"] def process_before(self, content): diff --git a/LunaTranslator/LunaTranslator/transoptimi/transerrorfix.py b/LunaTranslator/LunaTranslator/transoptimi/transerrorfix.py index 9100a0af..53c86843 100644 --- a/LunaTranslator/LunaTranslator/transoptimi/transerrorfix.py +++ b/LunaTranslator/LunaTranslator/transoptimi/transerrorfix.py @@ -3,9 +3,6 @@ from myutils.utils import parsemayberegexreplace class Process: - @property - def using(self): - return transerrorfixdictconfig["use"] def process_before(self, content):