ModelTranslator: fix QR engine docstring, add glob discovery test
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
55654e8d33
commit
e7dcf71d35
@@ -8,7 +8,7 @@ QR_TIMEOUT = 120.0 # 引擎轮询超时(秒)
|
||||
|
||||
def find_qr_engine():
|
||||
"""定位 QuadRemesher 的 xremesh.exe;找不到返回 None。
|
||||
顺序:QR_ENGINE 环境变量 -> 标准 addon 路径(取最高 Blender 版本目录)。"""
|
||||
顺序:QR_ENGINE 环境变量 -> 标准 addon 路径(取字典序最大目录,当前 Blender 5.x 下即最高版本)。"""
|
||||
env = os.environ.get("QR_ENGINE")
|
||||
if env and os.path.isfile(env):
|
||||
return env
|
||||
|
||||
@@ -83,6 +83,20 @@ class TestFindQrEngine(unittest.TestCase):
|
||||
os.environ["APPDATA"] = tempfile.mkdtemp()
|
||||
self.assertIsNone(qb.find_qr_engine())
|
||||
|
||||
def test_globs_addon_path_picks_last(self):
|
||||
root = tempfile.mkdtemp()
|
||||
os.environ.pop("QR_ENGINE", None)
|
||||
os.environ["APPDATA"] = root
|
||||
base = os.path.join(root, "Blender Foundation", "Blender")
|
||||
for ver in ("4.2", "5.0"):
|
||||
eng_dir = os.path.join(base, ver, "scripts", "addons",
|
||||
"QuadRemesher", "Engine")
|
||||
os.makedirs(eng_dir)
|
||||
open(os.path.join(eng_dir, "xremesh.exe"), "w").close()
|
||||
chosen = qb.find_qr_engine()
|
||||
self.assertIsNotNone(chosen)
|
||||
self.assertIn(os.path.join("5.0", "scripts"), chosen)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user