Complete M16 action select circle parity
This commit is contained in:
80
tools/web/check-action-copy-desktop.py
Normal file
80
tools/web/check-action-copy-desktop.py
Normal file
@@ -0,0 +1,80 @@
|
||||
#!/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("WebGapCopyObject")
|
||||
if obj is None or obj.animation_data is None or obj.animation_data.action is None:
|
||||
raise RuntimeError("WebGapCopyObject Action is missing")
|
||||
action = obj.animation_data.action
|
||||
channels = []
|
||||
for layer in action.layers:
|
||||
for strip in layer.strips:
|
||||
for bag in strip.channelbags:
|
||||
for curve in bag.fcurves:
|
||||
channels.append({
|
||||
"path": curve.data_path,
|
||||
"index": curve.array_index,
|
||||
"frames": [round(float(keyframe.co.x), 6) for keyframe in curve.keyframe_points],
|
||||
"selected": [bool(keyframe.select_control_point) for keyframe in curve.keyframe_points],
|
||||
})
|
||||
channels.sort(key=lambda value: (value["path"], value["index"]))
|
||||
return {"name": action.name, "channels": channels}
|
||||
|
||||
|
||||
def main():
|
||||
arguments = sys.argv[sys.argv.index("--") + 1:]
|
||||
if len(arguments) != 2:
|
||||
raise SystemExit("usage: blender -b --python check-action-copy-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()
|
||||
expected = [[False, True, False]] * 3
|
||||
if before["name"] != "WebGapCopyObjectAction" or [channel["selected"] for channel in before["channels"]] != expected:
|
||||
raise RuntimeError(f"unexpected action.copy source selection: {before}")
|
||||
window = bpy.context.window
|
||||
screen = window.screen
|
||||
area = next(candidate for candidate in screen.areas if candidate.type == "DOPESHEET_EDITOR")
|
||||
region = next(candidate for candidate in area.regions if candidate.type == "WINDOW")
|
||||
with bpy.context.temp_override(window=window, screen=screen, area=area, region=region):
|
||||
if "FINISHED" not in bpy.ops.action.copy():
|
||||
raise RuntimeError("ACTION_OT_copy did not finish")
|
||||
after_copy = action_report()
|
||||
if after_copy != before:
|
||||
raise RuntimeError(f"action.copy changed Main data: {before} != {after_copy}")
|
||||
descriptor, temporary = tempfile.mkstemp(prefix="m16-action-copy-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.copy save/reopen drift: {before} != {after}")
|
||||
report = {
|
||||
"schemaVersion": 1,
|
||||
"task": "M16-GAP-00116",
|
||||
"operation": "ACTION_COPY_DESKTOP",
|
||||
"fixture": str(fixture),
|
||||
"fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(),
|
||||
"copiedFrames": [3.0],
|
||||
"action": after,
|
||||
"saveReopen": "EXACT",
|
||||
"mainMutation": "NONE",
|
||||
"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-copy-desktop-ok channels=3 copiedFrame=3 mainMutation=none saveReopen=exact")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user