diff --git a/pype/plugins/global/publish/collect_anatomy.py b/pype/plugins/global/publish/collect_anatomy.py new file mode 100644 index 0000000000..b053a3a0d1 --- /dev/null +++ b/pype/plugins/global/publish/collect_anatomy.py @@ -0,0 +1,20 @@ +""" +Requires: + None +Provides: + context -> anatomy (pypeapp.Anatomy) +""" + +from pypeapp import Anatomy +import pyblish.api + + +class CollectTemplates(pyblish.api.ContextPlugin): + """Collect Anatomy into Context""" + + order = pyblish.api.CollectorOrder + label = "Collect Templates" + + def process(self, context): + context.data['anatomy'] = Anatomy() + self.log.info("Anatomy templates collected...") diff --git a/pype/plugins/global/publish/collect_comment.py b/pype/plugins/global/publish/collect_comment.py index 5bbd1da2a1..22970665a1 100644 --- a/pype/plugins/global/publish/collect_comment.py +++ b/pype/plugins/global/publish/collect_comment.py @@ -1,3 +1,10 @@ +""" +Requires: + None +Provides: + context -> comment (str) +""" + import pyblish.api diff --git a/pype/plugins/global/publish/collect_context.py b/pype/plugins/global/publish/collect_context.py index 31ab95259c..b718f18fa8 100644 --- a/pype/plugins/global/publish/collect_context.py +++ b/pype/plugins/global/publish/collect_context.py @@ -1,3 +1,18 @@ +""" +Requires: + environment -> SAPUBLISH_INPATH + environment -> SAPUBLISH_OUTPATH + +Provides: + context -> returnJsonPath (str) + context -> project + context -> asset + instance -> destination_list (list) + instance -> representations (list) + instance -> source (list) + instance -> representations +""" + import os import pyblish.api from avalon import io diff --git a/pype/plugins/global/publish/collect_context_label.py b/pype/plugins/global/publish/collect_context_label.py index ec8e0f7cdc..9c07d7de5b 100644 --- a/pype/plugins/global/publish/collect_context_label.py +++ b/pype/plugins/global/publish/collect_context_label.py @@ -1,3 +1,10 @@ +""" +Requires: + context -> currentFile (str) +Provides: + context -> label (str) +""" + import os import pyblish.api diff --git a/pype/plugins/global/publish/collect_current_shell_file.py b/pype/plugins/global/publish/collect_current_shell_file.py index a467459bc8..961cad86a1 100644 --- a/pype/plugins/global/publish/collect_current_shell_file.py +++ b/pype/plugins/global/publish/collect_current_shell_file.py @@ -1,3 +1,11 @@ +""" +Requires: + None + +Provides: + context -> currentFile (str) +""" + import os import pyblish.api diff --git a/pype/plugins/global/publish/collect_deadline_user.py b/pype/plugins/global/publish/collect_deadline_user.py index 624e455251..125f9d0d26 100644 --- a/pype/plugins/global/publish/collect_deadline_user.py +++ b/pype/plugins/global/publish/collect_deadline_user.py @@ -1,3 +1,11 @@ +""" +Requires: + environment -> DEADLINE_PATH + +Provides: + context -> deadlineUser (str) +""" + import os import subprocess @@ -54,4 +62,3 @@ class CollectDeadlineUser(pyblish.api.ContextPlugin): self.log.info("Found Deadline user: {}".format(user)) context.data['deadlineUser'] = user - diff --git a/pype/plugins/global/publish/collect_filesequences.py b/pype/plugins/global/publish/collect_filesequences.py index 33531549cb..73f3a459c8 100644 --- a/pype/plugins/global/publish/collect_filesequences.py +++ b/pype/plugins/global/publish/collect_filesequences.py @@ -1,3 +1,13 @@ +""" +Requires: + environment -> PYPE_PUBLISH_PATHS + context -> workspaceDir + +Provides: + context -> user (str) + instance -> new instance +""" + import os import re import copy diff --git a/pype/plugins/global/publish/collect_machine_name.py b/pype/plugins/global/publish/collect_machine_name.py index 02360cff04..72ef68f8ed 100644 --- a/pype/plugins/global/publish/collect_machine_name.py +++ b/pype/plugins/global/publish/collect_machine_name.py @@ -1,3 +1,11 @@ +""" +Requires: + none + +Provides: + context -> machine (str) +""" + import pyblish.api diff --git a/pype/plugins/global/publish/collect_output_repre_config.py b/pype/plugins/global/publish/collect_output_repre_config.py index 5595e29cab..f02199e778 100644 --- a/pype/plugins/global/publish/collect_output_repre_config.py +++ b/pype/plugins/global/publish/collect_output_repre_config.py @@ -1,5 +1,11 @@ -import os -import json +""" +Requires: + config_data -> ftrack.output_representation + +Provides: + context -> output_repre_config (str) +""" + import pyblish.api from pypeapp import config diff --git a/pype/plugins/global/publish/collect_presets.py b/pype/plugins/global/publish/collect_presets.py index 7e0d3e2f4b..abf85a6f01 100644 --- a/pype/plugins/global/publish/collect_presets.py +++ b/pype/plugins/global/publish/collect_presets.py @@ -1,3 +1,12 @@ +""" +Requires: + config_data -> colorspace.default + config_data -> dataflow.default + +Provides: + context -> presets +""" + from pyblish import api from pypeapp import config diff --git a/pype/plugins/global/publish/collect_project_data.py b/pype/plugins/global/publish/collect_project_data.py index de51ad880c..acdbc2c41f 100644 --- a/pype/plugins/global/publish/collect_project_data.py +++ b/pype/plugins/global/publish/collect_project_data.py @@ -1,8 +1,15 @@ +""" +Requires: + None + +Provides: + context -> projectData +""" + import pyblish.api import pype.api as pype - class CollectProjectData(pyblish.api.ContextPlugin): """Collecting project data from avalon db""" diff --git a/pype/plugins/global/publish/collect_templates.py b/pype/plugins/global/publish/collect_templates.py index fe48e97c03..8113f1d763 100644 --- a/pype/plugins/global/publish/collect_templates.py +++ b/pype/plugins/global/publish/collect_templates.py @@ -1,16 +1,86 @@ +""" +Requires: + session -> AVALON_PROJECT + context -> anatomy (pypeapp.Anatomy) + instance -> subset + instance -> asset + instance -> family -import pype.api as pype -from pypeapp import Anatomy +Provides: + instance -> template + instance -> assumedTemplateData + instance -> assumedDestination +""" +import os + +from avalon import io, api import pyblish.api -class CollectTemplates(pyblish.api.ContextPlugin): - """Inject the current working file into context""" +class CollectTemplates(pyblish.api.InstancePlugin): + """Fill templates with data needed for publish""" - order = pyblish.api.CollectorOrder - label = "Collect Templates" + order = pyblish.api.CollectorOrder + 0.1 + label = "Collect and fill Templates" - def process(self, context): - context.data['anatomy'] = Anatomy() - self.log.info("Anatomy templates collected...") + def process(self, instance): + # get all the stuff from the database + subset_name = instance.data["subset"] + asset_name = instance.data["asset"] + project_name = api.Session["AVALON_PROJECT"] + + project = io.find_one({"type": "project", + "name": project_name}, + projection={"config": True, "data": True}) + + template = project["config"]["template"]["publish"] + anatomy = instance.context.data['anatomy'] + + asset = io.find_one({"type": "asset", + "name": asset_name, + "parent": project["_id"]}) + + assert asset, ("No asset found by the name '{}' " + "in project '{}'".format(asset_name, project_name)) + silo = asset['silo'] + + subset = io.find_one({"type": "subset", + "name": subset_name, + "parent": asset["_id"]}) + + # assume there is no version yet, we start at `1` + version = None + version_number = 1 + if subset is not None: + version = io.find_one({"type": "version", + "parent": subset["_id"]}, + sort=[("name", -1)]) + + # if there is a subset there ought to be version + if version is not None: + version_number += int(version["name"]) + + hierarchy = asset['data']['parents'] + if hierarchy: + # hierarchy = os.path.sep.join(hierarchy) + hierarchy = os.path.join(*hierarchy) + + template_data = {"root": api.Session["AVALON_PROJECTS"], + "project": {"name": project_name, + "code": project['data']['code']}, + "silo": silo, + "family": instance.data['family'], + "asset": asset_name, + "subset": subset_name, + "version": version_number, + "hierarchy": hierarchy, + "representation": "TEMP"} + + instance.data["template"] = template + instance.data["assumedTemplateData"] = template_data + + # We take the parent folder of representation 'filepath' + instance.data["assumedDestination"] = os.path.dirname( + (anatomy.format(template_data)).publish.path + ) diff --git a/pype/plugins/global/publish/integrate_assumed_destination.py b/pype/plugins/global/publish/integrate_assumed_destination.py index 6999ce6ab8..3bbd4cf33b 100644 --- a/pype/plugins/global/publish/integrate_assumed_destination.py +++ b/pype/plugins/global/publish/integrate_assumed_destination.py @@ -30,7 +30,8 @@ class IntegrateAssumedDestination(pyblish.api.InstancePlugin): "resources") # Clean the path - mock_destination = os.path.abspath(os.path.normpath(mock_destination)).replace("\\", "/") + mock_destination = os.path.abspath( + os.path.normpath(mock_destination)).replace("\\", "/") # Define resource destination and transfers resources = instance.data.get("resources", list()) @@ -38,7 +39,8 @@ class IntegrateAssumedDestination(pyblish.api.InstancePlugin): for resource in resources: # Add destination to the resource - source_filename = os.path.basename(resource["source"]).replace("\\", "/") + source_filename = os.path.basename( + resource["source"]).replace("\\", "/") destination = os.path.join(mock_destination, source_filename) # Force forward slashes to fix issue with software unable @@ -53,7 +55,8 @@ class IntegrateAssumedDestination(pyblish.api.InstancePlugin): files = resource['files'] for fsrc in files: fname = os.path.basename(fsrc) - fdest = os.path.join(mock_destination, fname).replace("\\", "/") + fdest = os.path.join( + mock_destination, fname).replace("\\", "/") transfers.append([fsrc, fdest]) instance.data["resources"] = resources