diff --git a/pype/plugins/global/publish/collect_templates.py b/pype/plugins/global/publish/collect_templates.py new file mode 100644 index 0000000000..f420c0a0f7 --- /dev/null +++ b/pype/plugins/global/publish/collect_templates.py @@ -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 diff --git a/pype/plugins/global/publish/integrate.py b/pype/plugins/global/publish/integrate.py index 2c69445fbe..a8145d9cc3 100644 --- a/pype/plugins/global/publish/integrate.py +++ b/pype/plugins/global/publish/integrate.py @@ -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]) diff --git a/pype/plugins/global/publish/validate_templates.py b/pype/plugins/global/publish/validate_templates.py new file mode 100644 index 0000000000..f806104bb2 --- /dev/null +++ b/pype/plugins/global/publish/validate_templates.py @@ -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)