mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 19:58:36 +00:00
fix(anim_glb): use shared report path guard
This commit is contained in:
@ -673,6 +673,15 @@ class ExportTest(unittest.TestCase):
|
||||
"--part", hex(self.offsets[1]), "--report", self.packs)
|
||||
self.assertEqual(r.returncode, 2)
|
||||
|
||||
def test_same_nonexistent_glb_and_report_paths_are_refused(self):
|
||||
out = os.path.join(self.tmp.name, "not-created", "same.glb")
|
||||
r = self.run_tool(self.packs, out, "--skeleton", hex(self.offsets[0]), "--part", hex(self.offsets[1]),
|
||||
"--report", out)
|
||||
self.assertEqual(r.returncode, 2, r.stderr)
|
||||
self.assertIn("the GLB and the report are the same path", r.stderr)
|
||||
self.assertFalse(os.path.exists(out))
|
||||
self.assertFalse(os.path.exists(os.path.dirname(out)))
|
||||
|
||||
def test_report_directory_is_refused_before_writing_a_glb(self):
|
||||
out = os.path.join(self.tmp.name, "out.glb")
|
||||
report = os.path.join(self.tmp.name, "report")
|
||||
|
||||
@ -61,6 +61,7 @@ import anim_index # noqa: E402
|
||||
from file_mode import published_mode # noqa: E402
|
||||
import glb_writer # noqa: E402
|
||||
from pool_workers import process_workers # noqa: E402
|
||||
from report_paths import same_report_path # noqa: E402
|
||||
import skin_streams # noqa: E402
|
||||
|
||||
SYSTEM = 0x50000000
|
||||
@ -618,10 +619,6 @@ def parse_offset(text):
|
||||
raise argparse.ArgumentTypeError(f"not an offset: {text!r}") from None
|
||||
|
||||
|
||||
def same_path(first, second):
|
||||
return anim_clips.same_output_path(first, second)
|
||||
|
||||
|
||||
def export(args):
|
||||
started = time.monotonic()
|
||||
report = {"archive": os.path.basename(args.archive), "parts": [], "clips": [], "counts": collections.Counter()}
|
||||
@ -772,11 +769,11 @@ def main(argv=None):
|
||||
outputs = [p for p in (args.out, args.report) if p]
|
||||
for o in outputs:
|
||||
for i in inputs:
|
||||
if os.path.exists(o) and same_path(i, o):
|
||||
if os.path.exists(o) and same_report_path(i, o):
|
||||
ap.error(f"{o} is an input; refusing to overwrite it")
|
||||
if args.report and os.path.isdir(args.report):
|
||||
ap.error(f"--report is a directory: {args.report}")
|
||||
if args.out and args.report and same_path(args.out, args.report):
|
||||
if args.out and args.report and same_report_path(args.out, args.report):
|
||||
ap.error("the GLB and the report are the same path")
|
||||
if args.clip or args.dictionary is not None:
|
||||
if args.coverage:
|
||||
|
||||
Reference in New Issue
Block a user