Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

TVPaint: Publish workfile. #1597

Merged
merged 13 commits into from
May 31, 2021
3 changes: 2 additions & 1 deletion openpype/hosts/tvpaint/plugins/publish/collect_instances.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'os' imported but unused

import json
import copy
import pyblish.api
Expand Down Expand Up @@ -109,7 +110,7 @@ def _create_review_instance_data(self, context):

return {
"family": "review",
"asset": context.data["workfile_context"]["asset"],
"asset": context.data["asset"],
# Dummy subset name
"subset": "reviewMain"
}
Expand Down
43 changes: 43 additions & 0 deletions openpype/hosts/tvpaint/plugins/publish/collect_workfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import os
import json
import pyblish.api
from avalon import io


class CollectWorkfile(pyblish.api.ContextPlugin):
label = "Collect Workfile"
order = pyblish.api.CollectorOrder - 1
hosts = ["tvpaint"]

def process(self, context):
current_file = context.data["currentFile"]

self.log.info(
"Workfile path used for workfile family: {}".format(current_file)
)

dirpath, filename = os.path.split(current_file)
basename, ext = os.path.splitext(filename)
instance = context.create_instance(name=basename)

task_name = io.Session["AVALON_TASK"]
subset_name = "workfile" + task_name.capitalize()

# Create Workfile instance
instance.data.update({
"subset": subset_name,
"asset": context.data["asset"],
"label": subset_name,
"publish": True,
"family": "workfile",
"families": ["workfile"],
"representations": [{
"name": ext.lstrip("."),
"ext": ext.lstrip("."),
"files": filename,
"stagingDir": dirpath
}]
})
self.log.info("Collected workfile instance: {}".format(
json.dumps(instance.data, indent=4)
))
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
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"]

actions = [ValidateWorkfileMetadataRepair]

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)
)
)
2 changes: 1 addition & 1 deletion openpype/plugins/publish/extract_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,7 @@ def video_filters(self):
def _convert_string_to_values(self, orig_string_value):
string_value = orig_string_value.strip().lower()
if not string_value:
return
return [PixValueRelative(0), PixValueRelative(0)]

# Replace "px" (and spaces before) with single space
string_value = re.sub(r"([ ]+)?px", " ", string_value)
Expand Down