From 1b69c712f14d25bcf256cdd9fb44360312a9294b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Tue, 27 Oct 2020 17:13:52 +0100 Subject: [PATCH] collector fixes --- .../harmony/js/publish/CollectCurrentFile.js | 28 +++++++++++++++++++ .../global/publish/collect_scene_version.py | 6 +++- .../harmony/publish/collect_current_file.py | 20 +++++-------- .../harmony/publish/collect_palettes.py | 2 +- pype/vendor/OpenHarmony | 1 + 5 files changed, 42 insertions(+), 15 deletions(-) create mode 100644 pype/hosts/harmony/js/publish/CollectCurrentFile.js create mode 160000 pype/vendor/OpenHarmony diff --git a/pype/hosts/harmony/js/publish/CollectCurrentFile.js b/pype/hosts/harmony/js/publish/CollectCurrentFile.js new file mode 100644 index 0000000000..61cf31ef9d --- /dev/null +++ b/pype/hosts/harmony/js/publish/CollectCurrentFile.js @@ -0,0 +1,28 @@ +/* global PypeHarmony:writable, include */ +// *************************************************************************** +// * CollectCurrentFile * +// *************************************************************************** + + +// check if PypeHarmony is defined and if not, load it. +if (typeof PypeHarmony !== 'undefined') { + var PYPE_HARMONY_JS = System.getenv('PYPE_HARMONY_JS'); + include(PYPE_HARMONY_JS + '/pype_harmony.js'); +} + + +/** + * @namespace + * @classdesc Collect Current file + */ +var CollectCurrentFile = function() {}; + +CollectCurrentFile.prototype.collect = function() { + return ( + scene.currentProjectPath() + '/' + + scene.currentVersionName() + '.xstage' + ); +}; + +// add self to Pype Loaders +PypeHarmony.Publish.CollectCurrentFile = new CollectCurrentFile(); diff --git a/pype/plugins/global/publish/collect_scene_version.py b/pype/plugins/global/publish/collect_scene_version.py index 8c2bacf6e1..de2d0d282e 100644 --- a/pype/plugins/global/publish/collect_scene_version.py +++ b/pype/plugins/global/publish/collect_scene_version.py @@ -19,12 +19,16 @@ class CollectSceneVersion(pyblish.api.ContextPlugin): if "unreal" in pyblish.api.registered_hosts(): return + assert context.data.get('currentFile'), "Cannot get curren file" filename = os.path.basename(context.data.get('currentFile')) if '' in filename: return - rootVersion = int(pype.get_version_from_path(filename)) + version = pype.get_version_from_path(filename) + assert version, "Cannot determine version" + + rootVersion = int(version) context.data['version'] = rootVersion self.log.info("{}".format(type(rootVersion))) self.log.info('Scene Version: %s' % context.data.get('version')) diff --git a/pype/plugins/harmony/publish/collect_current_file.py b/pype/plugins/harmony/publish/collect_current_file.py index 40c154e847..86b7066018 100644 --- a/pype/plugins/harmony/publish/collect_current_file.py +++ b/pype/plugins/harmony/publish/collect_current_file.py @@ -1,3 +1,5 @@ +# -*- coding: utf-8 -*- +"""Collect information about current file.""" import os import pyblish.api @@ -5,24 +7,16 @@ from avalon import harmony class CollectCurrentFile(pyblish.api.ContextPlugin): - """Inject the current working file into context""" + """Inject the current working file into context.""" order = pyblish.api.CollectorOrder - 0.5 label = "Current File" hosts = ["harmony"] def process(self, context): - """Inject the current working file""" - sig = harmony.signature() - func = """function %s() - { - return ( - scene.currentProjectPath() + "/" + - scene.currentVersionName() + ".xstage" - ); - } - %s - """ % (sig, sig) + """Inject the current working file.""" + self_name = self.__class__.__name__ - current_file = harmony.send({"function": func})["result"] + current_file = harmony.send( + {"function": f"PypeHarmony.Publish.{self_name}.collect"})["result"] context.data["currentFile"] = os.path.normpath(current_file) diff --git a/pype/plugins/harmony/publish/collect_palettes.py b/pype/plugins/harmony/publish/collect_palettes.py index e4e2dffd43..0900f3c3ff 100644 --- a/pype/plugins/harmony/publish/collect_palettes.py +++ b/pype/plugins/harmony/publish/collect_palettes.py @@ -19,7 +19,7 @@ class CollectPalettes(pyblish.api.ContextPlugin): self_name = self.__class__.__name__ palettes = harmony.send( { - "function": f"PypeHarmony.Loaders.{self_name}.getPalettes", + "function": f"PypeHarmony.Publish.{self_name}.getPalettes", })["result"] for name, id in palettes.items(): diff --git a/pype/vendor/OpenHarmony b/pype/vendor/OpenHarmony new file mode 160000 index 0000000000..8d318c6818 --- /dev/null +++ b/pype/vendor/OpenHarmony @@ -0,0 +1 @@ +Subproject commit 8d318c68182a29fa520653c4dc36b8737e0cb2aa