mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 13:52:15 +01:00
Harmony - use regex search for filtering allowed tasks in collecting palettes
This commit is contained in:
parent
7e97e8de27
commit
cc47f5d2ef
1 changed files with 11 additions and 1 deletions
|
|
@ -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({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue