Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standalone: settings improvements #3355

Merged
merged 7 commits into from
Jun 23, 2022
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from pprint import pformat
import re
from copy import deepcopy
import pyblish.api
Expand All @@ -21,6 +22,7 @@ class CollectHierarchyInstance(pyblish.api.ContextPlugin):
families = ["shot"]

# presets
shot_rename = True
shot_rename_template = None
shot_rename_search_patterns = None
shot_add_hierarchy = None
Expand All @@ -46,7 +48,7 @@ def rename_with_hierarchy(self, instance):
parent_name = instance.context.data["assetEntity"]["name"]
clip = instance.data["item"]
clip_name = os.path.splitext(clip.name)[0].lower()
if self.shot_rename_search_patterns:
if self.shot_rename_search_patterns and self.shot_rename:
search_text += parent_name + clip_name
instance.data["anatomyData"].update({"clip_name": clip_name})
for type, pattern in self.shot_rename_search_patterns.items():
Expand All @@ -56,9 +58,9 @@ def rename_with_hierarchy(self, instance):
continue
instance.data["anatomyData"][type] = match[-1]

# format to new shot name
instance.data["asset"] = self.shot_rename_template.format(
**instance.data["anatomyData"])
# format to new shot name
instance.data["asset"] = self.shot_rename_template.format(
**instance.data["anatomyData"])

def create_hierarchy(self, instance):
asset_doc = instance.context.data["assetEntity"]
Expand Down Expand Up @@ -87,7 +89,7 @@ def create_hierarchy(self, instance):
})

hierarchy = list()
if self.shot_add_hierarchy:
if self.shot_add_hierarchy.get("enabled"):
parent_template_patern = re.compile(r"\{([a-z]*?)\}")
# fill the parents parts from presets
shot_add_hierarchy = self.shot_add_hierarchy.copy()
Expand Down Expand Up @@ -131,8 +133,8 @@ def create_hierarchy(self, instance):
instance.data["parents"] = parents

# print
self.log.debug(f"Hierarchy: {hierarchy}")
self.log.debug(f"parents: {parents}")
self.log.warning(f"Hierarchy: {hierarchy}")
self.log.info(f"parents: {parents}")

tasks_to_add = dict()
if self.shot_add_tasks:
Expand Down Expand Up @@ -163,6 +165,9 @@ def create_hierarchy(self, instance):
})

def process(self, context):
self.log.info("self.shot_add_hierarchy: {}".format(
pformat(self.shot_add_hierarchy)
))
for instance in context:
if instance.data["family"] in self.families:
self.processing_instance(instance)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@ def process(self, instance):
# Generate mov file.
fps = instance.data["fps"]
video_file_path = instance.data["editorialSourcePath"]
extensions = instance.data.get("extensions", [".mov"])
extensions = instance.data.get("extensions", ["mov"])

for ext in extensions:
self.log.info("Processing ext: `{}`".format(ext))

if not ext.startswith("."):
ext = "." + ext

clip_trimed_path = os.path.join(
staging_dir, instance.data["name"] + ext)
# # check video file metadata
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,12 +257,14 @@
]
},
"CollectHierarchyInstance": {
"shot_rename": true,
"shot_rename_template": "{project[code]}_{_sequence_}_{_shot_}",
"shot_rename_search_patterns": {
"_sequence_": "(\\d{4})(?=_\\d{4})",
"_shot_": "(\\d{4})(?!_\\d{4})"
"_sequence_": "(sc\\d{3})",
"_shot_": "(sh\\d{3})"
},
"shot_add_hierarchy": {
"enabled": true,
"parents_path": "{project}/{folder}/{sequence}",
"parents": {
"project": "{project[name]}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@
"label": "Collect Instance Hierarchy",
"is_group": true,
"children": [
{
"type": "boolean",
"key": "shot_rename",
"label": "Shot Rename"
},
{
"type": "text",
"key": "shot_rename_template",
Expand All @@ -289,7 +294,13 @@
"type": "dict",
"key": "shot_add_hierarchy",
"label": "Shot hierarchy",
"checkbox_key": "enabled",
"children": [
{
"type": "boolean",
"key": "enabled",
"label": "Enabled"
},
{
"type": "text",
"key": "parents_path",
Expand Down Expand Up @@ -343,8 +354,8 @@
"type": "number",
"key": "timeline_frame_start",
"label": "Timeline start frame",
"default": 900000,
"minimum": 1,
"default": 90000,
"minimum": 0,
"maximum": 10000000
},
{
Expand Down