support <Camera> token for directories

This commit is contained in:
Ondrej Samohel 2021-09-23 16:42:54 +02:00
parent 7d2d621c9a
commit de69cd69c7
No known key found for this signature in database
GPG key ID: 02376E18990A97C6
2 changed files with 27 additions and 0 deletions

View file

@ -205,12 +205,14 @@ class CollectMayaRender(pyblish.api.ContextPlugin):
# replace relative paths with absolute. Render products are
# returned as list of dictionaries.
publish_meta_path = None
for aov in exp_files:
full_paths = []
for file in aov[aov.keys()[0]]:
full_path = os.path.join(workspace, "renders", file)
full_path = full_path.replace("\\", "/")
full_paths.append(full_path)
publish_meta_path = os.path.dirname(full_path)
aov_dict[aov.keys()[0]] = full_paths
frame_start_render = int(self.get_render_attribute(
@ -236,6 +238,24 @@ class CollectMayaRender(pyblish.api.ContextPlugin):
frame_end_handle = frame_end_render
full_exp_files.append(aov_dict)
# find common path to store metadata
# so if image prefix is branching to many directories
# metadata file will be located in top-most common
# directory.
# TODO: use `os.path.commonpath()` after switch to Python 3
common_publish_meta_path = os.path.splitdrive(
publish_meta_path)[0]
if common_publish_meta_path:
common_publish_meta_path += os.path.sep
for part in publish_meta_path.split("/"):
common_publish_meta_path = os.path.join(
common_publish_meta_path, part)
if part == expected_layer_name:
break
common_publish_meta_path = common_publish_meta_path.replace("\\", "/")
self.log.info("Publish meta path: {}".format(common_publish_meta_path))
self.log.info(full_exp_files)
self.log.info("collecting layer: {}".format(layer_name))
# Get layer specific settings, might be overrides
@ -268,6 +288,7 @@ class CollectMayaRender(pyblish.api.ContextPlugin):
# which was submitted originally
"source": filepath,
"expectedFiles": full_exp_files,
"publishRenderMetadataFolder": common_publish_meta_path,
"resolutionWidth": cmds.getAttr("defaultResolution.width"),
"resolutionHeight": cmds.getAttr("defaultResolution.height"),
"pixelAspect": cmds.getAttr("defaultResolution.pixelAspect"),

View file

@ -351,6 +351,12 @@ class MayaSubmitDeadline(pyblish.api.InstancePlugin):
f.replace(orig_scene, new_scene)
)
instance.data["expectedFiles"] = [new_exp]
if instance.data.get("publishRenderMetadataFolder"):
instance.data["publishRenderMetadataFolder"] = \
instance.data["publishRenderMetadataFolder"].replace(
orig_scene, new_scene
)
self.log.info("Scene name was switched {} -> {}".format(
orig_scene, new_scene
))