Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Harmony - use regex search for filtering allowed tasks in collecting … #1048

Merged
merged 1 commit into from
Feb 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion pype/hosts/harmony/plugins/publish/collect_palettes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""Collect palettes from Harmony."""
import os
import json
import re

import pyblish.api
from avalon import harmony
Expand All @@ -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."""
Expand All @@ -22,6 +25,13 @@ def process(self, context):
"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({
Expand Down