Skip to content

Commit

Permalink
Merge pull request #59 from quadproduction/release/1.11.0
Browse files Browse the repository at this point in the history
release/1.11.0
  • Loading branch information
BenSouchet authored Jul 10, 2024
2 parents 2c0a7e3 + 662f9db commit 9a7e062
Show file tree
Hide file tree
Showing 20 changed files with 259 additions and 382 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Unique Layer Name Validator</title>
<description>
## Multiple element names aren't unique

Layers or Groups share the same name, this is not valid.

### How to repair?

You can select the detected layers with the "Select Layers" button on the right, then you need to change the names and make them all unique.
</description>
</error>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ class ValidateBlendMode(
active = False

def process(self, context):

if not self.is_active(context.data):
return

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import pyblish.api
from openpype.pipeline.publish import (
ValidateContentsOrder,
PublishXmlValidationError,
OptionalPyblishPluginMixin
)
from openpype.hosts.photoshop import api as photoshop


class ValidateLayersNameUniquenessRepair(pyblish.api.Action):
"""Select the layers that haven't a unique name"""

label = "Select Layers"
icon = "briefcase"
on = "failed"

def process(self, context, plugin):
stub = photoshop.stub()
stub.select_layers(layer for layer in context.data['transientData'][ValidateLayersNameUniqueness.__name__])

return True


class ValidateLayersNameUniqueness(
OptionalPyblishPluginMixin,
pyblish.api.ContextPlugin
):
"""Validate if all the layers have unique names"""

label = "Validate Layers Name Uniqueness"
hosts = ["photoshop"]
order = ValidateContentsOrder
families = ["image"]
actions = [ValidateLayersNameUniquenessRepair]
optional = True
active = True

def process(self, context):
if not self.is_active(context.data):
return

return_list = list()
msg = ""

stub = photoshop.stub()
layers = stub.get_layers()

layer_list = [layer.name for layer in layers]
duplicates = set()

for layer in layers:
if layer_list.count(layer.name) == 1:
continue

return_list.append(layer)
if layer.name not in duplicates:
duplicates.add(layer.name)
msg = "{}\n\n The name {} is not unique.".format(msg, layer.name)

if return_list:
if not context.data.get('transientData'):
context.data['transientData'] = dict()

context.data['transientData'][self.__class__.__name__] = return_list
raise PublishXmlValidationError(self, msg)
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def process(self, context):
project_name = os.environ['AVALON_PROJECT']
project_settings = get_project_settings(project_name)
try:
layers_types_colors = project_settings['fix_custom_settings']['photoshop']['types_colors']
layers_types_colors = project_settings['quad_custom_settings']['hosts']['photoshop']['types_colors']
except KeyError as err:
msg = "Layers types colors has not been found in settings. ValidateNomenclature plugin can't be executed."
logging.error(msg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ def process(self, context):
project_settings = get_project_settings(project_name)

try:
self.types_colors = project_settings['fix_custom_settings']['photoshop']['types_colors']
self.groups_templates = project_settings['fix_custom_settings']['photoshop']['groups']['templates']
self.layers_templates = project_settings['fix_custom_settings']['photoshop']['layers']['templates']
self.groups_expressions = project_settings['fix_custom_settings']['photoshop']['groups']['expressions']
self.layers_expressions = project_settings['fix_custom_settings']['photoshop']['layers']['expressions']
self.types_colors = project_settings['quad_custom_settings']['hosts']['photoshop']['types_colors']
self.groups_templates = project_settings['quad_custom_settings']['hosts']['photoshop']['groups']['templates']
self.layers_templates = project_settings['quad_custom_settings']['hosts']['photoshop']['layers']['templates']
self.groups_expressions = project_settings['quad_custom_settings']['hosts']['photoshop']['groups']['expressions']
self.layers_expressions = project_settings['quad_custom_settings']['hosts']['photoshop']['layers']['expressions']

except KeyError as err:
msg = "Types colors, templates or expressions are missing from settings. ValidateNomenclature plugin can't be executed."
Expand Down Expand Up @@ -205,6 +205,10 @@ def _remove_format_specifications(self, template):

def rename(self, template, layer, group_index, layer_index=None):
layer_type = self.types_colors.get(layer.color_code, '??')

# Removing all whitespace characters
layer.name = re.sub(r'\s+', '', layer.name)

new_layer_name = template.format(
**self._pack_layer_data(layer, layer_type, group_index, layer_index)
)
Expand Down
2 changes: 1 addition & 1 deletion quad_pyblish_module/plugins/tvpaint/create/create_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TVPaintJsonCreator(TVPaintAutoCreator):

def apply_settings(self, project_settings, system_settings):
plugin_settings = (
project_settings["fix_custom_settings"]["tvpaint"]["create"][
project_settings["quad_custom_settings"]["hosts"]["tvpaint"]["create"][
"create_json"]
)
self.default_variant = plugin_settings["default_variant"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TVPaintPlayblastCreator(TVPaintAutoCreator):

def apply_settings(self, project_settings, system_settings):
plugin_settings = (
project_settings["fix_custom_settings"]["tvpaint"]["create"]["create_playblast"]
project_settings["quad_custom_settings"]["hosts"]["tvpaint"]["create"]["create_playblast"]
)
self.mark_for_review = plugin_settings["mark_for_review"]
self.active_on_create = plugin_settings["active_on_create"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TVPaintPublishLayoutCreator(TVPaintAutoCreator):
family = "render"
subset_template_family_filter = "publish.sequence"
identifier = "publish.sequence"
label = "Publish frame(s)"
label = "Publish Layout"
icon = "fa.file-image-o"
host_name = "tvpaint"

Expand All @@ -25,7 +25,7 @@ class TVPaintPublishLayoutCreator(TVPaintAutoCreator):

def apply_settings(self, project_settings, system_settings):
plugin_settings = (
project_settings["fix_custom_settings"]["tvpaint"]["create"]["create_publish_layout"]
project_settings["quad_custom_settings"]["hosts"]["tvpaint"]["create"]["create_publish_layout"]
)
self.active_on_create = plugin_settings["active_on_create"]
self.keep_layers_transparency = plugin_settings["keep_layers_transparency"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ExtractJson(pyblish.api.ContextPlugin):
project_name = os.environ['AVALON_PROJECT']
project_settings = get_project_settings(project_name)

enabled = project_settings['fix_custom_settings']['tvpaint']['publish'][
enabled = project_settings['quad_custom_settings']['hosts']['tvpaint']['publish'][
'ExtractJson']['enabled']

def process(self, context):
Expand Down
2 changes: 1 addition & 1 deletion quad_pyblish_module/plugins/tvpaint/publish/extract_psd.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ExtractPsd(pyblish.api.InstancePlugin):
project_name = os.environ['AVALON_PROJECT']
project_settings = get_project_settings(project_name)

enabled = project_settings['fix_custom_settings']['tvpaint']['publish'][
enabled = project_settings['quad_custom_settings']['hosts']['tvpaint']['publish'][
'ExtractPsd'].get('enabled', False)

staging_dir_prefix = "tvpaint_export_json_psd_"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class IntegrateJson(pyblish.api.ContextPlugin):
project_name = os.environ['AVALON_PROJECT']
project_settings = get_project_settings(project_name)

enabled = project_settings['fix_custom_settings']['tvpaint']['publish'][
enabled = project_settings['quad_custom_settings']['hosts']['tvpaint']['publish'][
'ExtractJson']['enabled']

def process(self, context):
Expand Down
2 changes: 1 addition & 1 deletion quad_pyblish_module/quad_pyblish_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ class AddonSettingsDef(JsonFilesSettingsDef):
# recommended as schemas and templates may have name clashes across
# multiple addons
# - it is also recommended that prefix has addon name in it
schema_prefix = "fix_custom_settings"
schema_prefix = "quad_custom_settings"

def get_settings_root_path(self):
"""Implemented abstract class of JsonFilesSettingsDef.
Expand Down
Loading

0 comments on commit 9a7e062

Please sign in to comment.