Merge pull request #1048 from pypeclub/3.0/bugfix/harmony_regex_filtering

Harmony - use regex search for filtering allowed tasks in collecting …
This commit is contained in:
Milan Kolar 2021-02-24 09:47:26 +01:00 committed by GitHub
commit 708d296d4b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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({