added collector and validator for workfile family

This commit is contained in:
Jakub Trllo 2022-02-21 17:23:35 +01:00
parent d62a09729a
commit 026d9688fe
2 changed files with 55 additions and 0 deletions

View file

@ -0,0 +1,31 @@
import os
import pyblish.api
class CollectWorkfile(pyblish.api.InstancePlugin):
"""Collect representation of workfile instances."""
label = "Collect Workfile"
order = pyblish.api.CollectorOrder - 0.49
families = ["workfile"]
hosts = ["traypublisher"]
def process(self, instance):
if "representations" not in instance.data:
instance.data["representations"] = []
repres = instance.data["representations"]
creator_attributes = instance.data["creator_attributes"]
filepath = creator_attributes["filepath"]
instance.data["sourceFilepath"] = filepath
staging_dir = os.path.dirname(filepath)
filename = os.path.basename(filepath)
ext = os.path.splitext(filename)[-1]
repres.append({
"ext": ext,
"name": ext,
"stagingDir": staging_dir,
"files": filename
})

View file

@ -0,0 +1,24 @@
import os
import pyblish.api
from openpype.pipeline import PublishValidationError
class ValidateWorkfilePath(pyblish.api.InstancePlugin):
"""Validate existence of workfile instance existence."""
label = "Collect Workfile"
order = pyblish.api.ValidatorOrder - 0.49
families = ["workfile"]
hosts = ["traypublisher"]
def process(self, instance):
filepath = instance.data["sourceFilepath"]
if not filepath:
raise PublishValidationError((
"Filepath of 'workfile' instance \"{}\" is not set"
).format(instance.data["name"]))
if not os.path.exists(filepath):
raise PublishValidationError((
"Filepath of 'workfile' instance \"{}\" does not exist: {}"
).format(instance.data["name"], filepath))