From 752af5e5cc93168b818d65c36cff8c3b9ea4bc2d Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Wed, 18 Sep 2019 10:26:51 +0100 Subject: [PATCH] Separate comments collection to plugin. --- .../nukestudio/publish/collect_shots.py | 23 ++---------- .../publish/collect_tag_comments.py | 35 +++++++++++++++++++ 2 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 pype/plugins/nukestudio/publish/collect_tag_comments.py diff --git a/pype/plugins/nukestudio/publish/collect_shots.py b/pype/plugins/nukestudio/publish/collect_shots.py index 77346d2ec3..455e25bf82 100644 --- a/pype/plugins/nukestudio/publish/collect_shots.py +++ b/pype/plugins/nukestudio/publish/collect_shots.py @@ -32,24 +32,6 @@ class CollectShots(api.InstancePlugin): for key, value in instance.data.iteritems(): data[key] = value - # Collect comments. - data["comments"] = [] - - # Exclude non-tagged instances. - for tag in instance.data["tags"]: - if tag["name"].lower() == "comment": - data["comments"].append( - tag.metadata().dict()["tag.note"] - ) - - # Find tags on the source clip. - tags = instance.data["item"].source().tags() - for tag in tags: - if tag.name().lower() == "comment": - data["comments"].append( - tag.metadata().dict()["tag.note"] - ) - data["family"] = "shot" data["families"] = [] @@ -58,12 +40,11 @@ class CollectShots(api.InstancePlugin): data["name"] = data["subset"] + "_" + data["asset"] data["label"] = ( - "{} - {} - tasks:{} - assetbuilds:{} - comments:{}".format( + "{} - {} - tasks:{} - assetbuilds:{}".format( data["asset"], data["subset"], data["tasks"], - [x["name"] for x in data.get("assetbuilds", [])], - len(data["comments"]) + [x["name"] for x in data.get("assetbuilds", [])] ) ) diff --git a/pype/plugins/nukestudio/publish/collect_tag_comments.py b/pype/plugins/nukestudio/publish/collect_tag_comments.py new file mode 100644 index 0000000000..1ec98e3d3b --- /dev/null +++ b/pype/plugins/nukestudio/publish/collect_tag_comments.py @@ -0,0 +1,35 @@ +from pyblish import api + + +class CollectClipTagComments(api.InstancePlugin): + """Collect comments from tags on selected track items and their sources.""" + + order = api.CollectorOrder + 0.013 + label = "Collect Comments" + hosts = ["nukestudio"] + families = ["clip"] + + def process(self, instance): + # Collect comments. + instance.data["comments"] = [] + + # Exclude non-tagged instances. + for tag in instance.data["tags"]: + if tag["name"].lower() == "comment": + instance.data["comments"].append( + tag.metadata().dict()["tag.note"] + ) + + # Find tags on the source clip. + tags = instance.data["item"].source().tags() + for tag in tags: + if tag.name().lower() == "comment": + instance.data["comments"].append( + tag.metadata().dict()["tag.note"] + ) + + # Update label with comments counter. + instance.data["label"] = "{} - comments:{}".format( + instance.data["label"], + len(instance.data["comments"]) + )