From 455ab48273d2d91f62a3afa78fdd617e17f60bb0 Mon Sep 17 00:00:00 2001 From: ud18010 Date: Mon, 20 Jul 2026 09:35:26 +0800 Subject: [PATCH] =?UTF-8?q?ModelTranslator:=20--rizom=20=E6=98=BE=E5=BC=8F?= =?UTF-8?q?=E8=B7=AF=E5=BE=84=E7=8B=AC=E5=8D=A0=E7=94=9F=E6=95=88=E2=80=94?= =?UTF-8?q?=E2=80=94=E6=97=A0=E6=95=88=E7=9B=B4=E6=8E=A5=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E4=B8=8D=E5=9B=9E=E8=90=BD=E9=BB=98=E8=AE=A4=E5=AE=89=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.8 --- Tools/ModelTranslator/rizom_unwrap.py | 9 +++++++-- Tools/ModelTranslator/tests/test_rizom_unwrap.py | 6 ++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Tools/ModelTranslator/rizom_unwrap.py b/Tools/ModelTranslator/rizom_unwrap.py index 8bcdcf14..1a4b694a 100644 --- a/Tools/ModelTranslator/rizom_unwrap.py +++ b/Tools/ModelTranslator/rizom_unwrap.py @@ -43,9 +43,14 @@ def registry_rizom_path(): def find_rizomuv(cli_arg=None, use_registry=True, default=DEFAULT_RIZOM): - """返回第一个真实存在的 rizomuv.exe;都不存在抛 RizomError。""" + """返回第一个真实存在的 rizomuv.exe;都不存在抛 RizomError。 + 显式指定 cli_arg 时独占生效:路径无效直接报错,不回落其它候选。""" + if cli_arg: + if os.path.isfile(cli_arg): + return cli_arg + raise RizomError("指定的 rizomuv.exe 不存在:%s" % cli_arg) reg = registry_rizom_path() if use_registry else None - cands = candidate_paths(cli_arg, os.environ.get("RIZOMUV_EXE"), reg, default) + cands = candidate_paths(None, os.environ.get("RIZOMUV_EXE"), reg, default) for p in cands: if os.path.isfile(p): return p diff --git a/Tools/ModelTranslator/tests/test_rizom_unwrap.py b/Tools/ModelTranslator/tests/test_rizom_unwrap.py index d3769b97..67cf70ab 100644 --- a/Tools/ModelTranslator/tests/test_rizom_unwrap.py +++ b/Tools/ModelTranslator/tests/test_rizom_unwrap.py @@ -29,6 +29,12 @@ class TestFindRizomuv(unittest.TestCase): ru.find_rizomuv("Z:/no/such/rizomuv.exe", use_registry=False, default="Z:/no/default.exe") + def test_explicit_cli_path_is_exclusive(self): + # 显式指定的路径不存在必须直接抛错,不得回落默认安装 + with self.assertRaises(ru.RizomError) as cm: + ru.find_rizomuv("Z:/explicit/bad.exe") + self.assertIn("Z:/explicit/bad.exe", str(cm.exception)) + def test_registry_value_is_real_exe_if_present(self): p = ru.registry_rizom_path() if p is None: