From 46c06ce20d8324aa70ec88ed8f898046a7d48b53 Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Wed, 21 Aug 2019 16:09:31 +0100 Subject: [PATCH 1/2] Publish comments from NukeStudio. --- .../publish/integrate_ftrack_comments.py | 24 ++++++++++++++++ .../nukestudio/publish/collect_shots.py | 28 +++++++++++++++++-- 2 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 pype/plugins/ftrack/publish/integrate_ftrack_comments.py diff --git a/pype/plugins/ftrack/publish/integrate_ftrack_comments.py b/pype/plugins/ftrack/publish/integrate_ftrack_comments.py new file mode 100644 index 0000000000..889a78e254 --- /dev/null +++ b/pype/plugins/ftrack/publish/integrate_ftrack_comments.py @@ -0,0 +1,24 @@ +import pyblish.api + + +class IntegrateFtrackComments(pyblish.api.InstancePlugin): + """Create comments in Ftrack.""" + + order = pyblish.api.IntegratorOrder + label = "Integrate Comments to Ftrack." + families = ["shot"] + + def process(self, instance): + session = instance.context.data["ftrackSession"] + + entity = session.query( + "Shot where name is \"{}\"".format(instance.data["item"].name()) + ).one() + + notes = [] + for comment in instance.data["comments"]: + notes.append(session.create("Note", {"content": comment})) + + entity["notes"].extend(notes) + + session.commit() diff --git a/pype/plugins/nukestudio/publish/collect_shots.py b/pype/plugins/nukestudio/publish/collect_shots.py index 9fc14536fb..928dfd645b 100644 --- a/pype/plugins/nukestudio/publish/collect_shots.py +++ b/pype/plugins/nukestudio/publish/collect_shots.py @@ -30,6 +30,24 @@ class CollectShots(api.ContextPlugin): 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"] = [] @@ -37,8 +55,14 @@ class CollectShots(api.ContextPlugin): data["name"] = data["subset"] + "_" + data["asset"] - data["label"] = data["asset"] + " - " + data["subset"] + " - tasks: {} - assetbuilds: {}".format( - data["tasks"], [x["name"] for x in data.get("assetbuilds", [])] + data["label"] = ( + "{} - {} - tasks:{} - assetbuilds:{} - comments:{}".format( + data["asset"], + data["subset"], + data["tasks"], + [x["name"] for x in data.get("assetbuilds", [])], + len(data["comments"]) + ) ) # Create instance. From 752af5e5cc93168b818d65c36cff8c3b9ea4bc2d Mon Sep 17 00:00:00 2001 From: Toke Jepsen Date: Wed, 18 Sep 2019 10:26:51 +0100 Subject: [PATCH 2/2] 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"]) + )