diff --git a/openpype/hosts/testhost/plugins/publish/collect_context.py b/openpype/hosts/testhost/plugins/publish/collect_context.py index 158e8404d3..0a0e5f84d2 100644 --- a/openpype/hosts/testhost/plugins/publish/collect_context.py +++ b/openpype/hosts/testhost/plugins/publish/collect_context.py @@ -1,18 +1,3 @@ -""" -Requires: - environment -> SAPUBLISH_INPATH - environment -> SAPUBLISH_OUTPATH - -Provides: - context -> returnJsonPath (str) - context -> project - context -> asset - instance -> destination_list (list) - instance -> representations (list) - instance -> source (list) - instance -> representations -""" - import pyblish.api from avalon import io @@ -32,7 +17,7 @@ class CollectContextDataTestHost( """ label = "Collect Context - Test Host" - order = pyblish.api.CollectorOrder - 0.49 + order = pyblish.api.CollectorOrder - 0.5 hosts = ["testhost"] @classmethod @@ -59,16 +44,17 @@ class CollectContextDataTestHost( instance_families = in_data.get("families") or [] instance = context.create_instance(subset) - instance.data.update( - { - "subset": subset, - "asset": in_data["asset"], - "label": subset, - "name": subset, - "family": in_data["family"], - "families": instance_families - } - ) + instance.data.update({ + "subset": subset, + "asset": in_data["asset"], + "label": subset, + "name": subset, + "family": in_data["family"], + "families": instance_families + }) + for key, value in in_data.items(): + if key not in instance.data: + instance.data[key] = value self.log.info("collected instance: {}".format(instance.data)) self.log.info("parsing data: {}".format(in_data)) diff --git a/openpype/hosts/testhost/plugins/publish/collect_instance_1.py b/openpype/hosts/testhost/plugins/publish/collect_instance_1.py new file mode 100644 index 0000000000..eee12d02fb --- /dev/null +++ b/openpype/hosts/testhost/plugins/publish/collect_instance_1.py @@ -0,0 +1,56 @@ +import json +import pyblish.api +from avalon import io + +from openpype.hosts.testhost import api +from openpype.pipeline import ( + OpenPypePyblishPluginMixin, + attribute_definitions +) + + +class CollectInstanceOneTestHost( + pyblish.api.InstancePlugin, OpenPypePyblishPluginMixin +): + """ + Collecting temp json data sent from a host context + and path for returning json data back to hostself. + """ + + label = "Collect Instance 1 - Test Host" + order = pyblish.api.CollectorOrder - 0.3 + hosts = ["testhost"] + + @classmethod + def get_attribute_defs(cls): + return [ + attribute_definitions.NumberDef( + "version", + default=1, + minimum=1, + maximum=999, + decimals=0, + label="Version" + ) + ] + + def process(self, instance): + self._debug_log(instance) + + publish_attributes = instance.data.get("publish_attributes") + if not publish_attributes: + return + + values = publish_attributes.get(self.__class__.__name__) + if not values: + return + + instance.data["version"] = values["version"] + + def _debug_log(self, instance): + def _default_json(value): + return str(value) + + self.log.info( + json.dumps(instance.data, indent=4, default=_default_json) + )