mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
added validation or workfile metadata on workfile publishing
This commit is contained in:
parent
55cc40a3d0
commit
b629742e34
1 changed files with 49 additions and 0 deletions
|
|
@ -0,0 +1,49 @@
|
|||
import json
|
||||
|
||||
import pyblish.api
|
||||
from avalon.tvpaint import save_file
|
||||
|
||||
|
||||
class ValidateWorkfileMetadataRepair(pyblish.api.Action):
|
||||
"""Store current context into workfile metadata."""
|
||||
|
||||
label = "Use current context"
|
||||
icon = "wrench"
|
||||
on = "failed"
|
||||
|
||||
def process(self, context, plugin):
|
||||
"""Save current workfile which should trigger storing of metadata."""
|
||||
current_file = context.data["currentFile"]
|
||||
# Save file should trigger
|
||||
save_file(current_file)
|
||||
|
||||
|
||||
class ValidateWorkfileMetadata(pyblish.api.ContextPlugin):
|
||||
"""Validate if wokrfile contain required metadata for publising."""
|
||||
|
||||
label = "Validate Workfile Metadata"
|
||||
order = pyblish.api.ValidatorOrder
|
||||
|
||||
families = ["workfile"]
|
||||
|
||||
required_keys = {"project", "asset", "task"}
|
||||
|
||||
def process(self, context):
|
||||
workfile_context = context.data["workfile_context"]
|
||||
if not workfile_context:
|
||||
raise AssertionError(
|
||||
"Current workfile is missing whole metadata about context."
|
||||
)
|
||||
|
||||
missing_keys = []
|
||||
for key in self.required_keys:
|
||||
value = workfile_context.get(key)
|
||||
if not value:
|
||||
missing_keys.append(key)
|
||||
|
||||
if missing_keys:
|
||||
raise AssertionError(
|
||||
"Current workfile is missing metadata about {}.".format(
|
||||
", ".join(missing_keys)
|
||||
)
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue