collector fixes

This commit is contained in:
Ondřej Samohel 2020-10-27 17:13:52 +01:00
parent 53e5e0c33c
commit 1b69c712f1
No known key found for this signature in database
GPG key ID: 8A29C663C672C2B7
5 changed files with 42 additions and 15 deletions

View file

@ -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();

View file

@ -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 '<shell>' 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'))

View file

@ -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)

View file

@ -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():

1
pype/vendor/OpenHarmony vendored Submodule

@ -0,0 +1 @@
Subproject commit 8d318c68182a29fa520653c4dc36b8737e0cb2aa