From 372c6d89c37e1d67aea8caab69667d55e5b6f34d Mon Sep 17 00:00:00 2001 From: 2-REC Date: Fri, 4 Nov 2022 15:26:33 +0700 Subject: [PATCH 1/2] Setting from other plugin --- .../publish/validate_texture_workfiles.py | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/standalonepublisher/plugins/publish/validate_texture_workfiles.py b/openpype/hosts/standalonepublisher/plugins/publish/validate_texture_workfiles.py index 56ea82f6b6..a25b80438d 100644 --- a/openpype/hosts/standalonepublisher/plugins/publish/validate_texture_workfiles.py +++ b/openpype/hosts/standalonepublisher/plugins/publish/validate_texture_workfiles.py @@ -1,5 +1,7 @@ +import os import pyblish.api +from openpype.settings import get_project_settings from openpype.pipeline.publish import ( ValidateContentsOrder, PublishXmlValidationError, @@ -18,23 +20,40 @@ class ValidateTextureBatchWorkfiles(pyblish.api.InstancePlugin): families = ["texture_batch_workfile"] optional = True + #TODO(2-rec): remove/change comment # from presets main_workfile_extensions = ['mra'] def process(self, instance): if instance.data["family"] == "workfile": ext = instance.data["representations"][0]["ext"] - if ext not in self.main_workfile_extensions: + main_workfile_extensions = self.get_main_workfile_extensions() + if ext not in main_workfile_extensions: self.log.warning("Only secondary workfile present!") return if not instance.data.get("resources"): msg = "No secondary workfile present for workfile '{}'". \ format(instance.data["name"]) - ext = self.main_workfile_extensions[0] + ext = main_workfile_extensions[0] formatting_data = {"file_name": instance.data["name"], "extension": ext} raise PublishXmlValidationError(self, msg, formatting_data=formatting_data ) + + @classmethod + def get_main_workfile_extensions(cls): + project_settings = get_project_settings(os.environ["AVALON_PROJECT"]) + + #TODO: find better way? (depends on other plugin) + try: + extensions = (project_settings["standalonepublisher"] + ["publish"] + ["CollectTextures"] + ["main_workfile_extensions"]) + except KeyError: + extensions = cls.main_workfile_extensions + + return extensions From ee921e0bd4f384a3a94707d706f251e4aa997927 Mon Sep 17 00:00:00 2001 From: Derek Severin Date: Sat, 3 Dec 2022 17:04:02 +0700 Subject: [PATCH 2/2] Removed class variable and TODOs --- .../plugins/publish/validate_texture_workfiles.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/openpype/hosts/standalonepublisher/plugins/publish/validate_texture_workfiles.py b/openpype/hosts/standalonepublisher/plugins/publish/validate_texture_workfiles.py index a25b80438d..a7ae02a2eb 100644 --- a/openpype/hosts/standalonepublisher/plugins/publish/validate_texture_workfiles.py +++ b/openpype/hosts/standalonepublisher/plugins/publish/validate_texture_workfiles.py @@ -20,10 +20,6 @@ class ValidateTextureBatchWorkfiles(pyblish.api.InstancePlugin): families = ["texture_batch_workfile"] optional = True - #TODO(2-rec): remove/change comment - # from presets - main_workfile_extensions = ['mra'] - def process(self, instance): if instance.data["family"] == "workfile": ext = instance.data["representations"][0]["ext"] @@ -43,17 +39,19 @@ class ValidateTextureBatchWorkfiles(pyblish.api.InstancePlugin): formatting_data=formatting_data ) - @classmethod - def get_main_workfile_extensions(cls): + @staticmethod + def get_main_workfile_extensions(): project_settings = get_project_settings(os.environ["AVALON_PROJECT"]) - #TODO: find better way? (depends on other plugin) try: extensions = (project_settings["standalonepublisher"] ["publish"] ["CollectTextures"] ["main_workfile_extensions"]) except KeyError: - extensions = cls.main_workfile_extensions + raise Exception("Setting 'Main workfile extensions' not found." + " The setting must be set for the" + " 'Collect Texture' publish plugin of the" + " 'Standalone Publish' tool.") return extensions