Skip to content

Commit

Permalink
Move template loader to lib and maya api
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoitConnan authored and ClementHector committed Feb 8, 2022
1 parent 9aecac0 commit 713af51
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
from openpype.plugins.load.abstract_load_template import AbstractTemplateLoader
import importlib

cmds = None


def init_cmds():
global cmds
cmds = cmds or importlib.import_module('maya').cmds
from openpype.lib.abstract_load_template import AbstractTemplateLoader
from maya import cmds


ATTRIBUTES = ['builder_type', 'representation', 'families',
Expand All @@ -15,10 +8,6 @@ def init_cmds():

class TemplateLoader(AbstractTemplateLoader):

def __init__(self):
init_cmds()
super(TemplateLoader, self).__init__()

def import_template(self, path):
self.newNodes = cmds.file(path, i=True, returnNewNodes=True)

Expand Down
Empty file.
File renamed without changes.
24 changes: 15 additions & 9 deletions openpype/lib/build_template.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
import avalon
from openpype.hosts.maya.plugins.init.template_loader \
import TemplateLoader as maya_TemplateLoader

import importlib

def get_concrete_template_loader():
concrete_loaders = {
'maya': maya_TemplateLoader
concrete_loaders_modules = {
'maya': 'openpype.hosts.maya.api.template_loader'
}

dcc = avalon.io.Session['AVALON_APP']
loader = concrete_loaders.get(dcc)
if not loader:
raise ValueError('DCC not found for template')
return loader
module_path = concrete_loaders_modules.get(dcc, None)

if not module_path:
raise ValueError("Template not found for DCC '{}'".format(dcc))

module = importlib.import_module(module_path)
if not hasattr(module, 'TemplateLoader'):
raise ValueError("Linked module '{}' does not implement a template loader".format(module_path))

concrete_loader = module.TemplateLoader

return concrete_loader


class BuildWorkfileTemplate:
Expand Down
Empty file removed openpype/plugins/__init__.py
Empty file.
Empty file removed openpype/plugins/load/__init__.py
Empty file.

0 comments on commit 713af51

Please sign in to comment.