diff --git a/pype/modules/websocket_server/clients/photoshop_client.py b/pype/modules/websocket_server/clients/photoshop_client.py index 00e5355786..330c2ceff0 100644 --- a/pype/modules/websocket_server/clients/photoshop_client.py +++ b/pype/modules/websocket_server/clients/photoshop_client.py @@ -26,7 +26,7 @@ class PhotoshopClientStub(): :return: """ if layers_meta is None: - layers_meta = self._get_layers_metadata() + layers_meta = self.get_layers_metadata() return layers_meta.get(str(layer.id)) @@ -38,10 +38,13 @@ class PhotoshopClientStub(): :param all_layers: - for performance, could be injected for usage in loop, if not, single call will be triggered + :param layers_meta: json representation from Headline + (for performance - provide only if imprint is in + loop - value should be same) :return: None """ if not layers_meta: - layers_meta = self._get_layers_metadata() + layers_meta = self.get_layers_metadata() # json.dumps writes integer values in a dictionary to string, so # anticipating it here. if str(layer.id) in layers_meta and layers_meta[str(layer.id)]: @@ -83,25 +86,20 @@ class PhotoshopClientStub(): def get_layers_in_layers(self, layers): """ Return all layers that belong to layers (might be groups). - :param layers: - :return: + :param layers: + :return: """ all_layers = self.get_layers() - print("get_layers_in_layers {}".format(layers)) - print("get_layers_in_layers len {}".format(len(layers))) - print("get_layers_in_layers type {}".format(type(layers))) ret = [] parent_ids = set([lay.id for lay in layers]) - print("parent_ids ".format(parent_ids)) + for layer in all_layers: - print("layer {}".format(layer)) parents = set(layer.parents) - print("parents {}".format(layer)) if len(parent_ids & parents) > 0: ret.append(layer) if layer.id in parent_ids: ret.append(layer) - print("ret {}".format(ret)) + return ret def group_selected_layers(self): @@ -140,7 +138,8 @@ class PhotoshopClientStub(): :return: full path with name """ res = self.websocketserver.call( - self.client.call('Photoshop.get_active_document_full_name')) + self.client.call + ('Photoshop.get_active_document_full_name')) return res @@ -188,7 +187,7 @@ class PhotoshopClientStub(): layer_id=layer_id, visibility=visibility)) - def _get_layers_metadata(self): + def get_layers_metadata(self): """ Reads layers metadata from Headline from active document in PS. (Headline accessible by File > File Info) @@ -242,7 +241,3 @@ class PhotoshopClientStub(): for d in layers_data: ret.append(namedtuple('Layer', d.keys())(*d.values())) return ret - - - - diff --git a/pype/plugins/photoshop/publish/collect_instances.py b/pype/plugins/photoshop/publish/collect_instances.py index 47584272d2..7e433bc92f 100644 --- a/pype/plugins/photoshop/publish/collect_instances.py +++ b/pype/plugins/photoshop/publish/collect_instances.py @@ -31,7 +31,7 @@ class CollectInstances(pyblish.api.ContextPlugin): photoshop_client = PhotoshopClientStub() layers = photoshop_client.get_layers() - layers_meta = photoshop_client._get_layers_metadata() + layers_meta = photoshop_client.get_layers_metadata() for layer in layers: layer_data = photoshop_client.read(layer, layers_meta) diff --git a/pype/plugins/photoshop/publish/extract_image.py b/pype/plugins/photoshop/publish/extract_image.py index 4cbac38ce7..e32444c641 100644 --- a/pype/plugins/photoshop/publish/extract_image.py +++ b/pype/plugins/photoshop/publish/extract_image.py @@ -3,8 +3,9 @@ import os import pype.api from avalon import photoshop -from pype.modules.websocket_server.clients.photoshop_client import \ - PhotoshopClientStub +from pype.modules.websocket_server.clients.photoshop_client import ( + PhotoshopClientStub +) class ExtractImage(pype.api.Extractor): @@ -23,12 +24,6 @@ class ExtractImage(pype.api.Extractor): staging_dir = self.staging_dir(instance) self.log.info("Outputting image to {}".format(staging_dir)) - layers = [] - for image_instance in instance.context: - if image_instance.data["family"] != "image": - continue - layers.append(image_instance[0]) - # Perform extraction photoshop_client = PhotoshopClientStub() files = {} @@ -37,7 +32,7 @@ class ExtractImage(pype.api.Extractor): with photoshop.maintained_visibility(): # Hide all other layers. extract_ids = set([ll.id for ll in photoshop_client. - get_layers_in_layers(layers)]) + get_layers_in_layers([instance[0]])]) for layer in photoshop_client.get_layers(): # limit unnecessary calls to client