From c336a822b423282f46b59dc9b2e6de3e8fe63d63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=81=8D=E5=85=AE=E6=83=9A=E5=85=AE?= <1173718158@qq.com> Date: Mon, 23 Dec 2024 01:39:03 +0800 Subject: [PATCH] . --- .github/scripts/build_lunatranslator.py | 3 ++ py/LunaTranslator/cishu/mdict.py | 44 +++++++++++-------------- py/files/defaultconfig/static_data.json | 5 ++- py/requirements.txt | 2 +- py/requirements_qt6.txt | 2 +- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/.github/scripts/build_lunatranslator.py b/.github/scripts/build_lunatranslator.py index 7abccd68..453eacc2 100644 --- a/.github/scripts/build_lunatranslator.py +++ b/.github/scripts/build_lunatranslator.py @@ -285,6 +285,9 @@ def downloadbass(): ) subprocess.run(f"curl -LO https://www.un4seen.com/files/z/2/bass_aac24.zip") subprocess.run(f"7z x bass_aac24.zip -oALL") + for _dir, _, _fs in os.walk('ALL'): + for _f in _fs: + print(os.path.normpath(os.path.abspath(os.path.join(_dir, _f)))) shutil.move( "ALL/bass_aac.dll", f"{rootDir}/files/plugins/DLL32", diff --git a/py/LunaTranslator/cishu/mdict.py b/py/LunaTranslator/cishu/mdict.py index 0820eec2..053c3cda 100644 --- a/py/LunaTranslator/cishu/mdict.py +++ b/py/LunaTranslator/cishu/mdict.py @@ -2078,17 +2078,13 @@ class mdict(cishubase): print_exc() - def init(self): - try: - with open("userconfig/mdict_config.json", "r", encoding="utf8") as ff: - self.extraconf = json.loads(ff.read()) - except: - self.extraconf = {} - paths = self.config["paths"] - + def checkpath(self): + if self.config["paths"] == self.paths: + return + self.paths = self.config["paths"] self.builders = [] self.dedump = set() - for f in paths: + for f in self.paths: if f.strip() == "": continue if not os.path.exists(f): @@ -2103,6 +2099,14 @@ class mdict(cishubase): _f = os.path.join(_dir, _f) self.init_once_mdx(_f) + def init(self): + try: + with open("userconfig/mdict_config.json", "r", encoding="utf8") as ff: + self.extraconf = json.loads(ff.read()) + except: + self.extraconf = {} + self.paths = None + self.checkpath() try: with open( gobject.getuserconfigdir("mdict_config.json"), "w", encoding="utf8" @@ -2333,14 +2337,6 @@ class mdict(cishubase): skip = True idx += 1 - class shitrule(AtRule): - def __init__(self, __): - super().__init__(0, 0, " ", " ", [], []) - self.__ = __ - - def _serialize_to(self, _): - return _(self.__) - def parserules(rules): # print(stylesheet) for i, rule in enumerate(rules.copy()): @@ -2348,17 +2344,12 @@ class mdict(cishubase): if not rule.content: # @charset "UTF-8"; continue - internal = "".join([_.serialize() for _ in rule.content]) - internal = parse_stylesheet(internal, True, True) + internal = parse_stylesheet(rule.content, True, True) if len(internal) and isinstance(internal[0], ParseError): # @font-face continue # @....{ .klas{} } - internal = parserules(internal) - _ = [] - rule.content = internal - rule._serialize_to(_.append) - rules[i] = shitrule("".join(_)) + rule.content = parserules(internal) elif isinstance(rule, QualifiedRule): parseaqr(rules[i]) return rules @@ -2436,7 +2427,9 @@ class mdict(cishubase): # print(keys) for k in keys: __safe = [] - for content in sorted(set(self.searchthread_internal(index, k, __safe))): + for content in sorted( + set(self.searchthread_internal(index, k, __safe)) + ): results.append(self.parseashtml(content)) except: @@ -2605,6 +2598,7 @@ if (content.style.display === 'block') { return content def search(self, word): + self.checkpath() allres = [] audiob64vals = {} hrefsrcvals = {} diff --git a/py/files/defaultconfig/static_data.json b/py/files/defaultconfig/static_data.json index c15dd50c..bdc23881 100644 --- a/py/files/defaultconfig/static_data.json +++ b/py/files/defaultconfig/static_data.json @@ -1335,7 +1335,8 @@ "./files/plugins/DLL32/winsharedutils32.dll", "./files/plugins/DLL32/libmecab.dll", "./files/plugins/DLL32/bass.dll", - "./files/plugins/DLL32/bass_spx.dll" + "./files/plugins/DLL32/bass_spx.dll", + "./files/plugins/DLL32/bass_aac.dll" ], "shared": [ "./files/plugins/shareddllproxy32.exe", @@ -1354,6 +1355,7 @@ "./files/plugins/DLL64/libcurl-x64.dll", "./files/plugins/DLL64/bass.dll", "./files/plugins/DLL64/bass_spx.dll", + "./files/plugins/DLL64/bass_aac.dll", "./files/plugins/DLL64/brotlicommon.dll", "./files/plugins/DLL64/brotlidec.dll" ], @@ -1365,6 +1367,7 @@ "./files/plugins/DLL32/libcurl.dll", "./files/plugins/DLL32/bass.dll", "./files/plugins/DLL32/bass_spx.dll", + "./files/plugins/DLL32/bass_aac.dll", "./files/plugins/DLL32/brotlicommon.dll", "./files/plugins/DLL32/brotlidec.dll" ] diff --git a/py/requirements.txt b/py/requirements.txt index cdae2e80..8f588e96 100644 --- a/py/requirements.txt +++ b/py/requirements.txt @@ -1,4 +1,4 @@ PyQt5==5.15.10 PyQt5-Qt5==5.15.2 webviewpy==1.4.0 -tinycss2 \ No newline at end of file +tinycss2==1.4.0 \ No newline at end of file diff --git a/py/requirements_qt6.txt b/py/requirements_qt6.txt index 31cdef16..0fe9a538 100644 --- a/py/requirements_qt6.txt +++ b/py/requirements_qt6.txt @@ -1,4 +1,4 @@ PyQt6==6.7.0 PyQt6-Qt6==6.7.0 webviewpy==1.4.0 -tinycss2 \ No newline at end of file +tinycss2==1.4.0 \ No newline at end of file