Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Feature/643 mark publishable instances in photoshop #1095

Merged
12 changes: 12 additions & 0 deletions pype/hosts/photoshop/plugins/create/create_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,17 @@ def process(self):
groups.append(group)

for group in groups:
long_names = []
if group.long_name:
for directory in group.long_name[::-1]:
name = directory.replace(stub.PUBLISH_ICON, '').\
replace(stub.LOADED_ICON, '')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

continuation line over-indented for hanging indent

long_names.append(name)

self.data.update({"subset": "image" + group.name})
self.data.update({"uuid": str(group.id)})
self.data.update({"long_name": "_".join(long_names)})
stub.imprint(group, self.data)
# reusing existing group, need to rename afterwards
if not create_group:
stub.rename_layer(group.id, stub.PUBLISH_ICON + group.name)
9 changes: 8 additions & 1 deletion pype/hosts/photoshop/plugins/publish/collect_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def process(self, context):
stub = photoshop.stub()
layers = stub.get_layers()
layers_meta = stub.get_layers_metadata()
instance_names = []
for layer in layers:
layer_data = stub.read(layer, layers_meta)

Expand All @@ -41,14 +42,20 @@ def process(self, context):
# self.log.info("%s skipped, it was empty." % layer.Name)
# continue

instance = context.create_instance(layer.name)
instance = context.create_instance(layer_data["subset"])
instance.append(layer)
instance.data.update(layer_data)
instance.data["families"] = self.families_mapping[
layer_data["family"]
]
instance.data["publish"] = layer.visible
instance_names.append(layer_data["subset"])

# Produce diagnostic message for any graphical
# user interface interested in visualising it.
self.log.info("Found: \"%s\" " % instance.data["name"])
self.log.info("instance: {} ".format(instance.data))

if len(instance_names) != len(set(instance_names)):
self.log.warning("Duplicate instances found. " +
"Remove unwanted via SubsetManager")
11 changes: 9 additions & 2 deletions pype/hosts/photoshop/plugins/publish/validate_naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ def process(self, context, plugin):
for instance in instances:
self.log.info("validate_naming instance {}".format(instance))
name = instance.data["name"].replace(" ", "_")
name = name.replace(instance.data["family"], '')
instance[0].Name = name
data = stub.read(instance[0])
data["subset"] = "image" + name
stub.imprint(instance[0], data)

name = stub.PUBLISH_ICON + name
stub.rename_layer(instance.data["uuid"], name)

return True


Expand All @@ -46,8 +50,11 @@ class ValidateNaming(pyblish.api.InstancePlugin):
actions = [ValidateNamingRepair]

def process(self, instance):
msg = "Name \"{}\" is not allowed.".format(instance.data["name"])
help_msg = ' Use Repair action (A) in Pyblish to fix it.'
msg = "Name \"{}\" is not allowed.{}".format(instance.data["name"],
help_msg)
assert " " not in instance.data["name"], msg

msg = "Subset \"{}\" is not allowed.".format(instance.data["subset"])
msg = "Subset \"{}\" is not allowed.{}".format(instance.data["subset"],
help_msg)
assert " " not in instance.data["subset"], msg
26 changes: 26 additions & 0 deletions pype/hosts/photoshop/plugins/publish/validate_unique_subsets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import pyblish.api
import pype.api


class ValidateSubsetUniqueness(pyblish.api.ContextPlugin):
"""
Validate that all subset's names are unique.
"""

label = "Validate Subset Uniqueness"
hosts = ["photoshop"]
order = pype.api.ValidateContentsOrder
families = ["image"]

def process(self, context):
subset_names = []

for instance in context:
if instance.data.get('publish'):
subset_names.append(instance.data.get('subset'))

msg = (
"Instance subset names are not unique. " +
"Remove duplicates via SubsetManager."
)
assert len(subset_names) == len(set(subset_names)), msg
3 changes: 3 additions & 0 deletions pype/modules/websocket_server/hosts/photoshop.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ async def sceneinventory_route(self):
async def projectmanager_route(self):
self._tool_route("projectmanager")

async def subsetmanager_route(self):
self._tool_route("subsetmanager")

def _tool_route(self, tool_name):
"""The address accessed when clicking on the buttons."""
partial_method = functools.partial(photoshop.show, tool_name)
Expand Down
Loading