OP-4504 - added collector for originalDirname

This commit is contained in:
Petr Kalis 2022-12-14 14:41:52 +01:00
parent 8a267f6c34
commit 9bf00f9cfe
2 changed files with 43 additions and 16 deletions

View file

@ -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)

View file

@ -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)