mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Revert "Photoshop: New style validations for New publisher"
This commit is contained in:
parent
4a2a929baa
commit
5dedd2655d
10 changed files with 18 additions and 203 deletions
|
|
@ -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>
|
|
||||||
|
|
@ -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>
|
|
||||||
|
|
@ -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>
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
from avalon import api
|
from avalon import api
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
from avalon import photoshop
|
|
||||||
|
|
||||||
import openpype.api
|
import openpype.api
|
||||||
from openpype.pipeline import PublishXmlValidationError
|
from avalon import photoshop
|
||||||
|
|
||||||
|
|
||||||
class ValidateInstanceAssetRepair(pyblish.api.Action):
|
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"If that's not correct value, close workfile and "
|
||||||
f"reopen via Workfiles!"
|
f"reopen via Workfiles!"
|
||||||
)
|
)
|
||||||
formatting_data = {
|
assert instance_asset == current_asset, msg
|
||||||
"found": instance_asset,
|
|
||||||
"expected": current_asset
|
|
||||||
}
|
|
||||||
if instance_asset != current_asset:
|
|
||||||
raise PublishXmlValidationError(self, msg,
|
|
||||||
formatting_data=formatting_data)
|
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,8 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
from avalon import photoshop
|
|
||||||
|
|
||||||
import openpype.api
|
import openpype.api
|
||||||
from openpype.pipeline import PublishXmlValidationError
|
from avalon import photoshop
|
||||||
|
|
||||||
|
|
||||||
class ValidateNamingRepair(pyblish.api.Action):
|
class ValidateNamingRepair(pyblish.api.Action):
|
||||||
|
|
@ -71,18 +69,14 @@ class ValidateNaming(pyblish.api.InstancePlugin):
|
||||||
replace_char = ''
|
replace_char = ''
|
||||||
|
|
||||||
def process(self, instance):
|
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}
|
msg = "Subset \"{}\" is not allowed.{}".format(instance.data["subset"],
|
||||||
if re.search(self.invalid_chars, instance.data["name"]):
|
help_msg)
|
||||||
raise PublishXmlValidationError(self, msg,
|
assert not re.search(self.invalid_chars, instance.data["subset"]), 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)
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_replace_chars(cls):
|
def get_replace_chars(cls):
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,5 @@
|
||||||
import collections
|
|
||||||
|
|
||||||
import pyblish.api
|
import pyblish.api
|
||||||
import openpype.api
|
import openpype.api
|
||||||
from openpype.pipeline import PublishXmlValidationError
|
|
||||||
|
|
||||||
|
|
||||||
class ValidateSubsetUniqueness(pyblish.api.ContextPlugin):
|
class ValidateSubsetUniqueness(pyblish.api.ContextPlugin):
|
||||||
|
|
@ -22,18 +19,8 @@ class ValidateSubsetUniqueness(pyblish.api.ContextPlugin):
|
||||||
if instance.data.get('publish'):
|
if instance.data.get('publish'):
|
||||||
subset_names.append(instance.data.get('subset'))
|
subset_names.append(instance.data.get('subset'))
|
||||||
|
|
||||||
duplicates = [item
|
msg = (
|
||||||
for item, count in
|
"Instance subset names are not unique. " +
|
||||||
collections.Counter(subset_names).items()
|
"Remove duplicates via SubsetManager."
|
||||||
if count > 1]
|
)
|
||||||
|
assert len(subset_names) == len(set(subset_names)), msg
|
||||||
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)
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ from .create import (
|
||||||
|
|
||||||
from .publish import (
|
from .publish import (
|
||||||
PublishValidationError,
|
PublishValidationError,
|
||||||
PublishXmlValidationError,
|
|
||||||
KnownPublishError,
|
KnownPublishError,
|
||||||
OpenPypePyblishPluginMixin
|
OpenPypePyblishPluginMixin
|
||||||
)
|
)
|
||||||
|
|
@ -24,7 +23,6 @@ __all__ = (
|
||||||
"CreatedInstance",
|
"CreatedInstance",
|
||||||
|
|
||||||
"PublishValidationError",
|
"PublishValidationError",
|
||||||
"PublishXmlValidationError",
|
|
||||||
"KnownPublishError",
|
"KnownPublishError",
|
||||||
"OpenPypePyblishPluginMixin"
|
"OpenPypePyblishPluginMixin"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,26 +1,20 @@
|
||||||
from .publish_plugins import (
|
from .publish_plugins import (
|
||||||
PublishValidationError,
|
PublishValidationError,
|
||||||
PublishXmlValidationError,
|
|
||||||
KnownPublishError,
|
KnownPublishError,
|
||||||
OpenPypePyblishPluginMixin
|
OpenPypePyblishPluginMixin
|
||||||
)
|
)
|
||||||
|
|
||||||
from .lib import (
|
from .lib import (
|
||||||
DiscoverResult,
|
DiscoverResult,
|
||||||
publish_plugins_discover,
|
publish_plugins_discover
|
||||||
load_help_content_from_plugin,
|
|
||||||
load_help_content_from_filepath
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
"PublishValidationError",
|
"PublishValidationError",
|
||||||
"PublishXmlValidationError",
|
|
||||||
"KnownPublishError",
|
"KnownPublishError",
|
||||||
"OpenPypePyblishPluginMixin",
|
"OpenPypePyblishPluginMixin",
|
||||||
|
|
||||||
"DiscoverResult",
|
"DiscoverResult",
|
||||||
"publish_plugins_discover",
|
"publish_plugins_discover"
|
||||||
"load_help_content_from_plugin",
|
|
||||||
"load_help_content_from_filepath"
|
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import types
|
import types
|
||||||
import inspect
|
|
||||||
import xml.etree.ElementTree
|
|
||||||
|
|
||||||
import six
|
import six
|
||||||
import pyblish.plugin
|
import pyblish.plugin
|
||||||
|
|
@ -30,61 +28,6 @@ class DiscoverResult:
|
||||||
self.plugins[item] = value
|
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):
|
def publish_plugins_discover(paths=None):
|
||||||
"""Find and return available pyblish plug-ins
|
"""Find and return available pyblish plug-ins
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,3 @@
|
||||||
from .lib import load_help_content_from_plugin
|
|
||||||
|
|
||||||
|
|
||||||
class PublishValidationError(Exception):
|
class PublishValidationError(Exception):
|
||||||
"""Validation error happened during publishing.
|
"""Validation error happened during publishing.
|
||||||
|
|
||||||
|
|
@ -15,34 +12,13 @@ class PublishValidationError(Exception):
|
||||||
description(str): Detailed description of an error. It is possible
|
description(str): Detailed description of an error. It is possible
|
||||||
to use Markdown syntax.
|
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.message = message
|
||||||
self.title = title or "< Missing title >"
|
self.title = title or "< Missing title >"
|
||||||
self.description = description or message
|
self.description = description or message
|
||||||
self.detail = detail
|
|
||||||
super(PublishValidationError, self).__init__(message)
|
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):
|
class KnownPublishError(Exception):
|
||||||
"""Publishing crashed because of known error.
|
"""Publishing crashed because of known error.
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue