mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Validate mark in and out.
# Conflicts: # openpype/hosts/tvpaint/plugins/publish/validate_marks.py
This commit is contained in:
parent
a4143f5b1d
commit
a7a72d4f6f
1 changed files with 66 additions and 0 deletions
66
openpype/hosts/tvpaint/plugins/publish/validate_marks.py
Normal file
66
openpype/hosts/tvpaint/plugins/publish/validate_marks.py
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
import json
|
||||
|
||||
import pyblish.api
|
||||
from avalon.tvpaint import lib
|
||||
|
||||
|
||||
class ValidateMarksRepair(pyblish.api.Action):
|
||||
"""Repair the marks."""
|
||||
|
||||
label = "Repair"
|
||||
icon = "wrench"
|
||||
on = "failed"
|
||||
|
||||
def process(self, context, plugin):
|
||||
expected_data = ValidateMarks().get_expected_data(context)
|
||||
lib.execute_george("tv_markin {} set".format(expected_data["markIn"]))
|
||||
lib.execute_george(
|
||||
"tv_markout {} set".format(expected_data["markOut"])
|
||||
)
|
||||
|
||||
|
||||
class ValidateMarks(pyblish.api.ContextPlugin):
|
||||
"""Validate mark in and out are enabled."""
|
||||
|
||||
label = "Validate Marks"
|
||||
order = pyblish.api.ValidatorOrder
|
||||
optional = True
|
||||
actions = [ValidateMarksRepair]
|
||||
|
||||
def get_expected_data(self, context):
|
||||
return {
|
||||
"markIn": context.data["assetEntity"]["data"]["frameStart"] - 1,
|
||||
"markInState": True,
|
||||
"markOut": context.data["assetEntity"]["data"]["frameEnd"] - 1,
|
||||
"markOutState": True
|
||||
}
|
||||
|
||||
def process(self, context):
|
||||
# Marks return as "{frame - 1} {state} ", example "0 set".
|
||||
result = lib.execute_george("tv_markin")
|
||||
mark_in_frame, mark_in_state, _ = result.split(" ")
|
||||
|
||||
result = lib.execute_george("tv_markout")
|
||||
mark_out_frame, mark_out_state, _ = result.split(" ")
|
||||
|
||||
current_data = {
|
||||
"markIn": int(mark_in_frame),
|
||||
"markInState": mark_in_state == "set",
|
||||
"markOut": int(mark_out_frame),
|
||||
"markOutState": mark_out_state == "set"
|
||||
}
|
||||
expected_data = self.get_expected_data(context)
|
||||
invalid = {}
|
||||
for k in current_data.keys():
|
||||
if current_data[k] != expected_data[k]:
|
||||
invalid[k] = {
|
||||
"current": current_data[k],
|
||||
"expected_data": expected_data[k]
|
||||
}
|
||||
|
||||
if invalid:
|
||||
raise AssertionError(
|
||||
"Marks does not match database:\n{}".format(
|
||||
json.dumps(invalid, sort_keys=True, indent=4)
|
||||
)
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue