This commit is contained in:
恍兮惚兮 2024-04-14 17:49:23 +08:00
parent 9638fda582
commit 7404c1911c
5 changed files with 18 additions and 16 deletions

View File

@ -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)

View File

@ -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

View File

@ -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
return res

View File

@ -3,9 +3,6 @@ import gobject, re
class Process:
@property
def using(self):
return noundictconfig["use"]
def process_before(self, content):

View File

@ -3,9 +3,6 @@ from myutils.utils import parsemayberegexreplace
class Process:
@property
def using(self):
return transerrorfixdictconfig["use"]
def process_before(self, content):