47 lines
2.2 KiB
Python
47 lines
2.2 KiB
Python
#!/usr/bin/env python3
|
|
import hashlib
|
|
import json
|
|
import os
|
|
import pathlib
|
|
import sys
|
|
import tempfile
|
|
|
|
import bpy
|
|
|
|
|
|
def action_report():
|
|
obj = bpy.data.objects.get("WebGapMarkersMakeLocalObject")
|
|
if obj is None or obj.animation_data is None or obj.animation_data.action is None:
|
|
raise RuntimeError("WebGapMarkersMakeLocalObject Action is missing")
|
|
action = obj.animation_data.action
|
|
return {"name": action.name, "markers": sorted(({"name": marker.name, "frame": marker.frame} for marker in action.pose_markers), key=lambda value: (value["frame"], value["name"]))}
|
|
|
|
|
|
def main():
|
|
arguments = sys.argv[sys.argv.index("--") + 1:]
|
|
if len(arguments) != 2:
|
|
raise SystemExit("usage: blender -b --python check-action-markers-make-local-desktop.py -- FIXTURE REPORT")
|
|
fixture, output = (pathlib.Path(value).resolve() for value in arguments)
|
|
bpy.ops.wm.open_mainfile(filepath=str(fixture), load_ui=False)
|
|
before = action_report()
|
|
if before != {"name": "WebGapMarkersMakeLocalObjectAction", "markers": [{"name": "LocalActionMarker", "frame": 3}]}:
|
|
raise RuntimeError(f"unexpected action.markers_make_local result: {before}")
|
|
descriptor, temporary = tempfile.mkstemp(prefix="m16-action-markers-local-reopen-", suffix=".blend")
|
|
os.close(descriptor)
|
|
try:
|
|
bpy.ops.wm.save_as_mainfile(filepath=temporary, check_existing=False, compress=True)
|
|
bpy.ops.wm.open_mainfile(filepath=temporary, load_ui=False)
|
|
after = action_report()
|
|
finally:
|
|
pathlib.Path(temporary).unlink(missing_ok=True)
|
|
if before != after:
|
|
raise RuntimeError(f"action.markers_make_local save/reopen drift: {before} != {after}")
|
|
report = {"schemaVersion": 1, "task": "M16-GAP-00127", "operation": "ACTION_MARKERS_MAKE_LOCAL_DESKTOP", "fixture": str(fixture), "fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(), "marker": after["markers"][0], "action": after, "saveReopen": "EXACT", "blenderVersion": bpy.app.version_string}
|
|
output.parent.mkdir(parents=True, exist_ok=True)
|
|
output.write_text(json.dumps(report, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
|
print("action-markers-make-local-desktop-ok markers=1 frame=3 saveReopen=exact")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|