This repository has been archived by the owner on Sep 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1597 from pypeclub/feature/1548-tvpaint-publish-w…
…orkfile
- Loading branch information
Showing
4 changed files
with
95 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
openpype/hosts/tvpaint/plugins/publish/collect_workfile.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
)) |
49 changes: 49 additions & 0 deletions
49
openpype/hosts/tvpaint/plugins/publish/validate_workfile_metadata.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters