mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
OP-1063 - added validator for source files for Standalone Publisher
This commit is contained in:
parent
049ea39a70
commit
6621b2c36e
1 changed files with 37 additions and 0 deletions
|
|
@ -0,0 +1,37 @@
|
|||
import pyblish.api
|
||||
import openpype.api
|
||||
|
||||
import os
|
||||
|
||||
|
||||
class ValidateSources(pyblish.api.InstancePlugin):
|
||||
"""Validates source files.
|
||||
|
||||
Loops through all 'files' in 'stagingDir' if actually exist. They might
|
||||
got deleted between starting of SP and now.
|
||||
|
||||
"""
|
||||
|
||||
order = openpype.api.ValidateContentsOrder
|
||||
label = "Check source files"
|
||||
|
||||
optional = True # only for unforeseeable cases
|
||||
|
||||
hosts = ["standalonepublisher"]
|
||||
|
||||
def process(self, instance):
|
||||
self.log.info("instance {}".format(instance.data))
|
||||
|
||||
for repr in instance.data["representations"]:
|
||||
files = []
|
||||
if isinstance(repr["files"], str):
|
||||
files.append(repr["files"])
|
||||
else:
|
||||
files = list(repr["files"])
|
||||
|
||||
for file_name in files:
|
||||
source_file = os.path.join(repr["stagingDir"],
|
||||
file_name)
|
||||
|
||||
if not os.path.exists(source_file):
|
||||
raise ValueError("File {} not found".format(source_file))
|
||||
Loading…
Add table
Add a link
Reference in a new issue