Revert "Photoshop: New style validations for New publisher"

This commit is contained in:
Petr Kalis 2021-12-22 16:40:20 +01:00 committed by GitHub
parent 4a2a929baa
commit 5dedd2655d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 18 additions and 203 deletions

View file

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Subset context</title>
<description>
## Invalid subset context
Asset name found '{found}' in subsets, expected '{expected}'.
### How to repair?
You can fix this with `Repair` button on the right. This will use '{expected}' asset name and overwrite '{found}' asset name in scene metadata.
After that restart `Publish` with a `Reload button`.
If this is unwanted, close workfile and open again, that way different asset value would be used for context information.
</description>
<detail>
### __Detailed Info__ (optional)
This might happen if you are reuse old workfile and open it in different context.
(Eg. you created subset "renderCompositingDefault" from asset "Robot' in "your_project_Robot_compositing.aep", now you opened this workfile in a context "Sloth" but existing subset for "Robot" asset stayed in the workfile.)
</detail>
</error>
</root>

View file

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Invalid name</title>
<description>
## Invalid name of subset
Name of subset is created from a layer name. Some characters (whitespace, '/' etc.) are not allowed because of publishing (files couldn't be saved on some OSes).
### How to repair?
You can fix this with `Repair` button on the right. This will remove invalid characters with safe character ('_' by default) in both subset names and matching group names.
After that restart `Publish` with a `Reload button`.
Or you use `Subset Manager` to delete existing subsets, remove created groups, rename layers that are used for their creation and use `Create` option in the Openpype menu to create them again.
Invalid characters and 'safe character' could be configured in Settings. Ask your OpenPype admin to modify them if necessary.
</description>
</error>
</root>

View file

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<error id="main">
<title>Subsets duplicated</title>
<description>
## Some subsets are duplicated
Created subsets must be unique.
Subsets '{duplicates_str}' are duplicated.
### How to repair?
Use `Subset Manager` to delete duplicated subset to have only unique subset names and restart `Publish` with a `Reload button`.
</description>
<detail>
### __Detailed Info__ (optional)
Subset names are created from layer names. Layer names are filtered for characters that would break publishing process when files are created.
This replacement process might result in duplicate names of subsets.
</detail>
</error>
</root>

View file

@ -1,9 +1,7 @@
from avalon import api
import pyblish.api
from avalon import photoshop
import openpype.api
from openpype.pipeline import PublishXmlValidationError
from avalon import photoshop
class ValidateInstanceAssetRepair(pyblish.api.Action):
@ -58,10 +56,4 @@ class ValidateInstanceAsset(pyblish.api.InstancePlugin):
f"If that's not correct value, close workfile and "
f"reopen via Workfiles!"
)
formatting_data = {
"found": instance_asset,
"expected": current_asset
}
if instance_asset != current_asset:
raise PublishXmlValidationError(self, msg,
formatting_data=formatting_data)
assert instance_asset == current_asset, msg

View file

@ -1,10 +1,8 @@
import re
import pyblish.api
from avalon import photoshop
import openpype.api
from openpype.pipeline import PublishXmlValidationError
from avalon import photoshop
class ValidateNamingRepair(pyblish.api.Action):
@ -71,18 +69,14 @@ class ValidateNaming(pyblish.api.InstancePlugin):
replace_char = ''
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 re.search(self.invalid_chars, instance.data["name"]), msg
formatting_data = {"error_msg": msg}
if re.search(self.invalid_chars, instance.data["name"]):
raise PublishXmlValidationError(self, msg,
formatting_data=formatting_data)
msg = "Subset \"{}\" is not allowed.".format(instance.data["subset"])
formatting_data = {"error_msg": msg}
if re.search(self.invalid_chars, instance.data["subset"]):
raise PublishXmlValidationError(self, msg,
formatting_data=formatting_data)
msg = "Subset \"{}\" is not allowed.{}".format(instance.data["subset"],
help_msg)
assert not re.search(self.invalid_chars, instance.data["subset"]), msg
@classmethod
def get_replace_chars(cls):

View file

@ -1,8 +1,5 @@
import collections
import pyblish.api
import openpype.api
from openpype.pipeline import PublishXmlValidationError
class ValidateSubsetUniqueness(pyblish.api.ContextPlugin):
@ -22,18 +19,8 @@ class ValidateSubsetUniqueness(pyblish.api.ContextPlugin):
if instance.data.get('publish'):
subset_names.append(instance.data.get('subset'))
duplicates = [item
for item, count in
collections.Counter(subset_names).items()
if count > 1]
if duplicates:
duplicates_str = ",".join(duplicates)
formatting_data = {"duplicates_str": duplicates_str}
msg = (
"Instance subset names {} are not unique.".format(
duplicates_str) +
" Remove duplicates via SubsetManager."
)
raise PublishXmlValidationError(self, msg,
formatting_data=formatting_data)
msg = (
"Instance subset names are not unique. " +
"Remove duplicates via SubsetManager."
)
assert len(subset_names) == len(set(subset_names)), msg

View file

@ -9,7 +9,6 @@ from .create import (
from .publish import (
PublishValidationError,
PublishXmlValidationError,
KnownPublishError,
OpenPypePyblishPluginMixin
)
@ -24,7 +23,6 @@ __all__ = (
"CreatedInstance",
"PublishValidationError",
"PublishXmlValidationError",
"KnownPublishError",
"OpenPypePyblishPluginMixin"
)

View file

@ -1,26 +1,20 @@
from .publish_plugins import (
PublishValidationError,
PublishXmlValidationError,
KnownPublishError,
OpenPypePyblishPluginMixin
)
from .lib import (
DiscoverResult,
publish_plugins_discover,
load_help_content_from_plugin,
load_help_content_from_filepath
publish_plugins_discover
)
__all__ = (
"PublishValidationError",
"PublishXmlValidationError",
"KnownPublishError",
"OpenPypePyblishPluginMixin",
"DiscoverResult",
"publish_plugins_discover",
"load_help_content_from_plugin",
"load_help_content_from_filepath"
"publish_plugins_discover"
)

View file

@ -1,8 +1,6 @@
import os
import sys
import types
import inspect
import xml.etree.ElementTree
import six
import pyblish.plugin
@ -30,61 +28,6 @@ class DiscoverResult:
self.plugins[item] = value
class HelpContent:
def __init__(self, title, description, detail=None):
self.title = title
self.description = description
self.detail = detail
def load_help_content_from_filepath(filepath):
"""Load help content from xml file.
Xml file may containt errors and warnings.
"""
errors = {}
warnings = {}
output = {
"errors": errors,
"warnings": warnings
}
if not os.path.exists(filepath):
return output
tree = xml.etree.ElementTree.parse(filepath)
root = tree.getroot()
for child in root:
child_id = child.attrib.get("id")
if child_id is None:
continue
# Make sure ID is string
child_id = str(child_id)
title = child.find("title").text
description = child.find("description").text
detail_node = child.find("detail")
detail = None
if detail_node is not None:
detail = detail_node.text
if child.tag == "error":
errors[child_id] = HelpContent(title, description, detail)
elif child.tag == "warning":
warnings[child_id] = HelpContent(title, description, detail)
return output
def load_help_content_from_plugin(plugin):
cls = plugin
if not inspect.isclass(plugin):
cls = plugin.__class__
plugin_filepath = inspect.getfile(cls)
plugin_dir = os.path.dirname(plugin_filepath)
basename = os.path.splitext(os.path.basename(plugin_filepath))[0]
filename = basename + ".xml"
filepath = os.path.join(plugin_dir, "help", filename)
return load_help_content_from_filepath(filepath)
def publish_plugins_discover(paths=None):
"""Find and return available pyblish plug-ins

View file

@ -1,6 +1,3 @@
from .lib import load_help_content_from_plugin
class PublishValidationError(Exception):
"""Validation error happened during publishing.
@ -15,34 +12,13 @@ class PublishValidationError(Exception):
description(str): Detailed description of an error. It is possible
to use Markdown syntax.
"""
def __init__(self, message, title=None, description=None, detail=None):
def __init__(self, message, title=None, description=None):
self.message = message
self.title = title or "< Missing title >"
self.description = description or message
self.detail = detail
super(PublishValidationError, self).__init__(message)
class PublishXmlValidationError(PublishValidationError):
def __init__(
self, plugin, message, key=None, formatting_data=None
):
if key is None:
key = "main"
if not formatting_data:
formatting_data = {}
result = load_help_content_from_plugin(plugin)
content_obj = result["errors"][key]
description = content_obj.description.format(**formatting_data)
detail = content_obj.detail
if detail:
detail = detail.format(**formatting_data)
super(PublishXmlValidationError, self).__init__(
message, content_obj.title, description, detail
)
class KnownPublishError(Exception):
"""Publishing crashed because of known error.