Capture M16 gap execution artifacts
This commit is contained in:
90
tools/web/check-action-clear-useless-actions-desktop.py
Normal file
90
tools/web/check-action-clear-useless-actions-desktop.py
Normal file
@@ -0,0 +1,90 @@
|
||||
#!/usr/bin/env python3
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
def action_report(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],
|
||||
})
|
||||
channels.sort(key=lambda value: (value["path"], value["index"]))
|
||||
return {
|
||||
"name": action.name,
|
||||
"users": action.users,
|
||||
"fakeUser": bool(action.use_fake_user),
|
||||
"channels": channels,
|
||||
}
|
||||
|
||||
|
||||
def state_report():
|
||||
actions = {
|
||||
action.name: action_report(action)
|
||||
for action in bpy.data.actions
|
||||
if action.name.startswith("WebGapAnimClearUseless")
|
||||
}
|
||||
used = bpy.data.objects.get("WebGapAnimClearUselessUsedObject")
|
||||
if used is None or used.animation_data is None or used.animation_data.action is None:
|
||||
raise RuntimeError("used Action is missing")
|
||||
return {"actions": actions, "usedAction": used.animation_data.action.name}
|
||||
|
||||
|
||||
def main():
|
||||
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
||||
if len(arguments) != 2:
|
||||
raise SystemExit("usage: blender -b --python check-action-clear-useless-actions-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 = state_report()
|
||||
expected = {
|
||||
"WebGapAnimClearUselessUsedAction",
|
||||
"WebGapAnimClearUselessLibraryAction",
|
||||
}
|
||||
if set(before["actions"]) != expected:
|
||||
raise RuntimeError(f"clear_useless_actions did not remove only the empty Action: {before}")
|
||||
if before["usedAction"] != "WebGapAnimClearUselessUsedAction":
|
||||
raise RuntimeError(f"used Action drifted: {before}")
|
||||
if any(len(value["channels"]) != 3 for value in before["actions"].values()):
|
||||
raise RuntimeError(f"preserved Actions have unexpected curves: {before}")
|
||||
|
||||
descriptor, temporary = tempfile.mkstemp(prefix="m16-anim-clear-useless-actions-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 = state_report()
|
||||
finally:
|
||||
pathlib.Path(temporary).unlink(missing_ok=True)
|
||||
if before != after:
|
||||
raise RuntimeError("anim.clear_useless_actions save/reopen drift")
|
||||
report = {
|
||||
"schemaVersion": 1,
|
||||
"task": "M16-GAP-00172",
|
||||
"operation": "ANIM_CLEAR_USELESS_ACTIONS_DESKTOP",
|
||||
"fixture": str(fixture),
|
||||
"fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(),
|
||||
"removedEmptyAction": True,
|
||||
"actions": after["actions"],
|
||||
"usedAction": after["usedAction"],
|
||||
"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("anim-clear-useless-actions-desktop-ok removedEmpty=true preserved=2 saveReopen=exact")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user