diff --git a/pype/modules/websocket_server/clients/photoshop_client.py b/pype/modules/websocket_server/clients/photoshop_client.py index eea297954f..bf72c1bc5a 100644 --- a/pype/modules/websocket_server/clients/photoshop_client.py +++ b/pype/modules/websocket_server/clients/photoshop_client.py @@ -18,17 +18,19 @@ class PhotoshopClientStub(): self.websocketserver = WebSocketServer.get_instance() self.client = self.websocketserver.get_client() - def read(self, layer): + def read(self, layer, layers_meta=None): """ Parses layer metadata from Headline field of active document - :param layer: + :param layer: Layer("id": XXX, "name":'YYY') @@ -38,13 +40,14 @@ class PhotoshopClientStub(): triggered :return: None """ - layers_data = self._get_layers_metadata() + if not layers_meta: + 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_data: - layers_data[str(layer.id)].update(data) + if str(layer.id) in layers_meta and layers_meta[str(layer.id)]: + layers_meta[str(layer.id)].update(data) else: - layers_data[str(layer.id)] = data + layers_meta[str(layer.id)] = data # Ensure only valid ids are stored. if not all_layers: @@ -52,9 +55,9 @@ class PhotoshopClientStub(): layer_ids = [layer.id for layer in all_layers] cleaned_data = {} - for id in layers_data: + for id in layers_meta: if int(id) in layer_ids: - cleaned_data[id] = layers_data[id] + cleaned_data[id] = layers_meta[id] payload = json.dumps(cleaned_data, indent=4) diff --git a/pype/plugins/photoshop/publish/collect_instances.py b/pype/plugins/photoshop/publish/collect_instances.py index 82a0c35311..47584272d2 100644 --- a/pype/plugins/photoshop/publish/collect_instances.py +++ b/pype/plugins/photoshop/publish/collect_instances.py @@ -2,8 +2,9 @@ import pythoncom import pyblish.api -from pype.modules.websocket_server.clients.photoshop_client \ - import PhotoshopClientStub +from pype.modules.websocket_server.clients.photoshop_client import ( + PhotoshopClientStub +) class CollectInstances(pyblish.api.ContextPlugin): @@ -30,14 +31,9 @@ class CollectInstances(pyblish.api.ContextPlugin): photoshop_client = PhotoshopClientStub() layers = photoshop_client.get_layers() - + layers_meta = photoshop_client._get_layers_metadata() for layer in layers: - layer_data = photoshop_client.read(layer) - self.log.info("layer_data {}".format(layer_data)) - - photoshop_client.imprint(layer, layer_data, layers) - new_layer_data = photoshop_client.read(layer) - assert layer_data == new_layer_data + layer_data = photoshop_client.read(layer, layers_meta) # Skip layers without metadata. if layer_data is None: