diff --git a/openpype/plugins/publish/collect_resources_path.py b/openpype/plugins/publish/collect_resources_path.py index ea86ab93b4..dcd80fbbdf 100644 --- a/openpype/plugins/publish/collect_resources_path.py +++ b/openpype/plugins/publish/collect_resources_path.py @@ -106,19 +106,3 @@ class CollectResourcesPath(pyblish.api.InstancePlugin): self.log.debug("publishDir: \"{}\"".format(publish_folder)) self.log.debug("resourcesDir: \"{}\"".format(resources_folder)) - - # parse folder name and file name for online and source templates - # currentFile comes from hosts workfiles - # source comes from Publisher - current_file = instance.data.get("currentFile") - source = instance.data.get("source") - source_file = current_file or source - if source_file and os.path.exists(source_file): - self.log.debug("Parsing paths for {}".format(source_file)) - if not instance.data.get("originalBasename"): - instance.data["originalBasename"] = \ - os.path.basename(source_file) - - if not instance.data.get("originalDirname"): - instance.data["originalDirname"] = \ - os.path.dirname(source_file) diff --git a/openpype/plugins/publish/collect_source_for_source.py b/openpype/plugins/publish/collect_source_for_source.py new file mode 100644 index 0000000000..345daa6fe8 --- /dev/null +++ b/openpype/plugins/publish/collect_source_for_source.py @@ -0,0 +1,43 @@ +""" +Requires: + instance -> currentFile + instance -> source + +Provides: + instance -> originalBasename + instance -> originalDirname +""" + +import os +import copy + +import pyblish.api + + +class CollectSourceForSource(pyblish.api.InstancePlugin): + """Collects source location of file for instance. + + Used for 'source' template name which handles in place publishing. + For this kind of publishing files are present with correct file name + pattern and correct location. + """ + + label = "Collect Source" + order = pyblish.api.CollectorOrder + 0.495 + + def process(self, instance): + # parse folder name and file name for online and source templates + # currentFile comes from hosts workfiles + # source comes from Publisher + current_file = instance.data.get("currentFile") + source = instance.data.get("source") + source_file = current_file or source + if source_file and os.path.exists(source_file): + self.log.debug("Parsing paths for {}".format(source_file)) + if not instance.data.get("originalBasename"): + instance.data["originalBasename"] = \ + os.path.basename(source_file) + + if not instance.data.get("originalDirname"): + instance.data["originalDirname"] = \ + os.path.dirname(source_file)