mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 05:42:15 +01:00
start testing pype templates in publishing
This commit is contained in:
parent
7b9ea27f39
commit
c4fede895c
3 changed files with 81 additions and 7 deletions
21
pype/plugins/global/publish/collect_templates.py
Normal file
21
pype/plugins/global/publish/collect_templates.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
from maya import cmds
|
||||
from app.api import (
|
||||
Templates
|
||||
)
|
||||
|
||||
import pyblish.api
|
||||
|
||||
|
||||
class CollectTemplates(pyblish.api.ContextPlugin):
|
||||
"""Inject the current working file into context"""
|
||||
|
||||
order = pyblish.api.CollectorOrder
|
||||
label = "Collect Templates"
|
||||
|
||||
def process(self, context):
|
||||
"""Inject the current working file"""
|
||||
templates = Templates()
|
||||
context.data['anatomy'] = templates.anatomy
|
||||
for key in templates.anatomy:
|
||||
self.log.info(str(key) + ": " + str(templates.anatomy[key]))
|
||||
# return
|
||||
|
|
@ -136,14 +136,24 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
|
|||
# \|________|
|
||||
#
|
||||
root = api.registered_root()
|
||||
# template_data = {"root": root,
|
||||
# "project": PROJECT,
|
||||
# "silo": asset['silo'],
|
||||
# "asset": ASSET,
|
||||
# "subset": subset["name"],
|
||||
# "version": version["name"]}
|
||||
template_data = {"root": root,
|
||||
"project": PROJECT,
|
||||
"project": {"name": PROJECT,
|
||||
"code": "prjX"},
|
||||
"silo": asset['silo'],
|
||||
"asset": ASSET,
|
||||
"family": instance.data['family'],
|
||||
"subset": subset["name"],
|
||||
"version": version["name"]}
|
||||
"VERSION": version["name"],
|
||||
"hierarchy": "ep101"}
|
||||
|
||||
template_publish = project["config"]["template"]["publish"]
|
||||
anatomy = instance.context.data['anatomy']
|
||||
|
||||
# Find the representations to transfer amongst the files
|
||||
# Each should be a single representation (as such, a single extension)
|
||||
|
|
@ -176,10 +186,8 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
|
|||
for fname in collection:
|
||||
|
||||
src = os.path.join(stagingdir, fname)
|
||||
dst = os.path.join(
|
||||
template_publish.format(**template_data),
|
||||
fname
|
||||
)
|
||||
anatomy_filled = anatomy.format(template_data)
|
||||
dst = anatomy_filled.publish.path
|
||||
|
||||
instance.data["transfers"].append([src, dst])
|
||||
|
||||
|
|
@ -201,7 +209,10 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
|
|||
template_data["representation"] = ext[1:]
|
||||
|
||||
src = os.path.join(stagingdir, fname)
|
||||
dst = template_publish.format(**template_data)
|
||||
anatomy_filled = anatomy.format(template_data)
|
||||
self.log.info(anatomy_filled)
|
||||
dst = anatomy_filled.publish.path
|
||||
self.log.info(dst)
|
||||
|
||||
instance.data["transfers"].append([src, dst])
|
||||
|
||||
|
|
|
|||
42
pype/plugins/global/publish/validate_templates.py
Normal file
42
pype/plugins/global/publish/validate_templates.py
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import pyblish.api
|
||||
from app.api import (
|
||||
Templates
|
||||
)
|
||||
|
||||
class ValidateTemplates(pyblish.api.ContextPlugin):
|
||||
"""Check if all templates were filed"""
|
||||
|
||||
label = "Validate Templates"
|
||||
order = pyblish.api.ValidatorOrder - 0.1
|
||||
hosts = ["maya", "houdini", "nuke"]
|
||||
|
||||
def process(self, context):
|
||||
|
||||
anatomy = context.data["anatomy"]
|
||||
if not anatomy:
|
||||
raise RuntimeError("Did not find templates")
|
||||
else:
|
||||
data = { "project": {"name": "D001_projectsx",
|
||||
"code": "prjX"},
|
||||
"representation": "exr",
|
||||
"VERSION": 3,
|
||||
"SUBVERSION": 10,
|
||||
"task": "animation",
|
||||
"asset": "sh001",
|
||||
"hierarchy": "ep101/sq01/sh010"}
|
||||
|
||||
|
||||
anatomy = context.data["anatomy"].format(data)
|
||||
self.log.info(anatomy.work.path)
|
||||
|
||||
data = { "project": {"name": "D001_projectsy",
|
||||
"code": "prjY"},
|
||||
"representation": "abc",
|
||||
"VERSION": 1,
|
||||
"SUBVERSION": 5,
|
||||
"task": "lookdev",
|
||||
"asset": "bob",
|
||||
"hierarchy": "ep101/sq01/bob"}
|
||||
|
||||
anatomy = context.data["anatomy"].format(data)
|
||||
self.log.info(anatomy.work.file)
|
||||
Loading…
Add table
Add a link
Reference in a new issue