mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 08:54:53 +01:00
OP-3908 - added missed xml help
Added optionality to validator as
This commit is contained in:
parent
a73318474c
commit
1a6cc379ee
2 changed files with 45 additions and 15 deletions
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<root>
|
||||
<error id="main">
|
||||
<title>Asset does not match</title>
|
||||
<description>
|
||||
## Collected asset name is not same as in context
|
||||
|
||||
{msg}
|
||||
### How to repair?
|
||||
{repair_msg}
|
||||
If that's not correct value, close workfile and reopen via Workfiles to get
|
||||
proper context asset name OR disable this validator and publish again
|
||||
if you are publishing to different context deliberately.
|
||||
|
||||
(Context means combination of project, asset name and task name.)
|
||||
</description>
|
||||
</error>
|
||||
</root>
|
||||
|
|
@ -1,7 +1,11 @@
|
|||
import pyblish.api
|
||||
|
||||
from openpype.pipeline import legacy_io
|
||||
from openpype.pipeline.publish import ValidateContentsOrder
|
||||
from openpype.pipeline.publish import (
|
||||
ValidateContentsOrder,
|
||||
PublishXmlValidationError,
|
||||
OptionalPyblishPluginMixin
|
||||
)
|
||||
from openpype.hosts.photoshop import api as photoshop
|
||||
|
||||
|
||||
|
|
@ -31,30 +35,38 @@ class ValidateInstanceAssetRepair(pyblish.api.Action):
|
|||
stub.imprint(instance[0], data)
|
||||
|
||||
|
||||
class ValidateInstanceAsset(pyblish.api.InstancePlugin):
|
||||
class ValidateInstanceAsset(OptionalPyblishPluginMixin,
|
||||
pyblish.api.InstancePlugin):
|
||||
"""Validate the instance asset is the current selected context asset.
|
||||
|
||||
As it might happen that multiple worfiles are opened, switching
|
||||
between them would mess with selected context.
|
||||
In that case outputs might be output under wrong asset!
|
||||
As it might happen that multiple worfiles are opened, switching
|
||||
between them would mess with selected context.
|
||||
In that case outputs might be output under wrong asset!
|
||||
|
||||
Repair action will use Context asset value (from Workfiles or Launcher)
|
||||
Closing and reopening with Workfiles will refresh Context value.
|
||||
Repair action will use Context asset value (from Workfiles or Launcher)
|
||||
Closing and reopening with Workfiles will refresh Context value.
|
||||
"""
|
||||
|
||||
label = "Validate Instance Asset"
|
||||
hosts = ["photoshop"]
|
||||
optional = True
|
||||
actions = [ValidateInstanceAssetRepair]
|
||||
order = ValidateContentsOrder
|
||||
|
||||
def process(self, instance):
|
||||
instance_asset = instance.data["asset"]
|
||||
current_asset = legacy_io.Session["AVALON_ASSET"]
|
||||
msg = (
|
||||
f"Instance asset {instance_asset} is not the same "
|
||||
f"as current context {current_asset}. PLEASE DO:\n"
|
||||
f"Repair with 'A' action to use '{current_asset}'.\n"
|
||||
f"If that's not correct value, close workfile and "
|
||||
f"reopen via Workfiles!"
|
||||
)
|
||||
assert instance_asset == current_asset, msg
|
||||
|
||||
if instance_asset != current_asset:
|
||||
msg = (
|
||||
f"Instance asset {instance_asset} is not the same "
|
||||
f"as current context {current_asset}."
|
||||
|
||||
)
|
||||
repair_msg = (
|
||||
f"Repair with 'Repair' button to use '{current_asset}'.\n"
|
||||
)
|
||||
formatting_data = {"msg": msg,
|
||||
"repair_msg": repair_msg}
|
||||
raise PublishXmlValidationError(self, msg,
|
||||
formatting_data=formatting_data)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue