OP-2766 - Hound

This commit is contained in:
Petr Kalis 2022-03-23 13:49:50 +01:00
parent a684f6cd4e
commit d211471ea0
4 changed files with 16 additions and 11 deletions

View file

@ -151,7 +151,7 @@ def list_instances():
layers_meta = stub.get_layers_metadata()
if layers_meta:
for instance in layers_meta:
if instance.get("id") == "pyblish.avalon.instance": # TODO only this way?
if instance.get("id") == "pyblish.avalon.instance":
instances.append(instance)
return instances
@ -266,4 +266,4 @@ def get_context_title():
project_name = avalon.api.Session["AVALON_PROJECT"]
asset_name = avalon.api.Session["AVALON_ASSET"]
task_name = avalon.api.Session["AVALON_TASK"]
return "{}/{}/{}".format(project_name, asset_name, task_name)
return "{}/{}/{}".format(project_name, asset_name, task_name)

View file

@ -39,7 +39,9 @@ class ImageCreator(Creator):
if pre_create_data.get("use_selection"):
only_single_item_selected = len(top_level_selected_items) == 1
for selected_item in top_level_selected_items:
if only_single_item_selected or pre_create_data.get("create_multiple"):
if (
only_single_item_selected or
pre_create_data.get("create_multiple")):
if selected_item.group:
groups_to_create.append(selected_item)
else:
@ -85,13 +87,15 @@ class ImageCreator(Creator):
self._add_instance_to_context(new_instance)
# reusing existing group, need to rename afterwards
if not create_empty_group:
stub.rename_layer(group.id, stub.PUBLISH_ICON + created_group_name)
stub.rename_layer(group.id,
stub.PUBLISH_ICON + created_group_name)
def update_instances(self, update_list):
self.log.debug("update_list:: {}".format(update_list))
for created_inst, _changes in update_list:
if created_inst.get("layer"):
created_inst.pop("layer") # not storing PSItem layer to metadata
# not storing PSItem layer to metadata
created_inst.pop("layer")
api.stub().imprint(created_inst.get("instance_id"),
created_inst.data_to_store())
@ -107,7 +111,8 @@ class ImageCreator(Creator):
def get_pre_create_attr_defs(self):
output = [
lib.BoolDef("use_selection", default=True, label="Create only for selected"),
lib.BoolDef("use_selection", default=True,
label="Create only for selected"),
lib.BoolDef("create_multiple",
default=True,
label="Create separate instance for each selected")
@ -138,5 +143,3 @@ class ImageCreator(Creator):
def _clean_highlights(self, stub, item):
return item.replace(stub.PUBLISH_ICON, '').replace(stub.LOADED_ICON,
'')

View file

@ -45,7 +45,8 @@ class CollectInstances(pyblish.api.ContextPlugin):
if "container" in layer_meta_data["id"]:
continue
if not layer_meta_data.get("active", True): # active might not be in legacy meta
# active might not be in legacy meta
if not layer_meta_data.get("active", True):
continue
instance = instance_by_layer_id.get(str(layer_item.id))

View file

@ -31,10 +31,11 @@ class ValidateNamingRepair(pyblish.api.Action):
for instance in instances:
self.log.debug("validate_naming instance {}".format(instance))
current_layer_state = stub.get_layer(instance.data["layer"].id)
self.log.debug("current_layer_state instance {}".format(current_layer_state))
self.log.debug("current_layer{}".format(current_layer_state))
layer_meta = stub.read(current_layer_state)
instance_id = layer_meta.get("instance_id") or layer_meta.get("uuid")
instance_id = (layer_meta.get("instance_id") or
layer_meta.get("uuid"))
if not instance_id:
self.log.warning("Unable to repair, cannot find layer")
continue