From cc47f5d2ef9f1a7f126d8de23d7519c3e925ff71 Mon Sep 17 00:00:00 2001 From: Petr Kalis Date: Tue, 23 Feb 2021 17:07:07 +0100 Subject: [PATCH] Harmony - use regex search for filtering allowed tasks in collecting palettes --- .../harmony/plugins/publish/collect_palettes.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pype/hosts/harmony/plugins/publish/collect_palettes.py b/pype/hosts/harmony/plugins/publish/collect_palettes.py index 26b83ff171..e6795f894b 100644 --- a/pype/hosts/harmony/plugins/publish/collect_palettes.py +++ b/pype/hosts/harmony/plugins/publish/collect_palettes.py @@ -2,6 +2,7 @@ """Collect palettes from Harmony.""" import os import json +import re import pyblish.api from avalon import harmony @@ -11,8 +12,10 @@ class CollectPalettes(pyblish.api.ContextPlugin): """Gather palettes from scene when publishing templates.""" label = "Palettes" - order = pyblish.api.CollectorOrder + order = pyblish.api.CollectorOrder + 0.003 hosts = ["harmony"] + # list of regexes for task names where collecting should happen + allowed_tasks = [] def process(self, context): """Collector entry point.""" @@ -22,6 +25,13 @@ class CollectPalettes(pyblish.api.ContextPlugin): "function": f"PypeHarmony.Publish.{self_name}.getPalettes", })["result"] + # skip collecting if not in allowed task + if self.allowed_tasks: + task_name = context.data["anatomyData"]["task"].lower() + if (not any([re.search(pattern, task_name) + for pattern in self.allowed_tasks])): + return + for name, id in palettes.items(): instance = context.create_instance(name) instance.data.update({