예제 #1
0
 def tryImport(self, name, dir):
     """
     Imports a brush module. Called by importBrushModules
     :param name, name of the module to import.
     """
     embeded = bool(dir == "stock-brushes")
     try:
         path = os.path.join(dir, (name + ".py"))
         if isinstance(path, unicode) and DEF_ENC != "UTF-8":
             path = path.encode(DEF_ENC)
         globals()[name] = m = imp.load_source(name, path)
         if not embeded:
             old_trn_path = albow.translate.getLangPath()
             if "trn" in sys.modules.keys():
                 del sys.modules["trn"]
             import albow.translate as trn
             trn_path = os.path.join(directories.brushesDir, name)
             if os.path.exists(trn_path):
                 trn.setLangPath(trn_path)
                 trn.buildTranslation(config.settings.langCode.get())
             m.trn = trn
             albow.translate.setLangPath(old_trn_path)
             albow.translate.buildTranslation(config.settings.langCode.get())
             self.editor.mcedit.set_update_ui(True)
             self.editor.mcedit.set_update_ui(False)
         m.materials = self.editor.level.materials
         m.tool = self
         m.createInputs(m)
         return m
     except Exception as e:
         print traceback.format_exc()
         alert(_(u"Exception while importing brush mode {}. See console for details.\n\n{}").format(name, e))
         return object()
예제 #2
0
 def tryImport(self, name, dir):
     """
     Imports a brush module. Called by importBrushModules
     :param name, name of the module to import.
     """
     embeded = bool(dir == "stock-brushes")
     try:
         path = os.path.join(dir, (name + ".py"))
         if isinstance(path, unicode) and DEF_ENC != "UTF-8":
             path = path.encode(DEF_ENC)
         globals()[name] = m = imp.load_source(name, path)
         if not embeded:
             old_trn_path = albow.translate.getLangPath()
             if "trn" in sys.modules.keys():
                 del sys.modules["trn"]
             import albow.translate as trn
             trn_path = os.path.join(directories.brushesDir, name)
             if os.path.exists(trn_path):
                 trn.setLangPath(trn_path)
                 trn.buildTranslation(config.settings.langCode.get())
             m.trn = trn
             albow.translate.setLangPath(old_trn_path)
             albow.translate.buildTranslation(config.settings.langCode.get())
             self.editor.mcedit.set_update_ui(True)
             self.editor.mcedit.set_update_ui(False)
         m.materials = self.editor.level.materials
         m.tool = self
         m.createInputs(m)
         return m
     except Exception as e:
         print traceback.format_exc()
         alert(_(u"Exception while importing brush mode {}. See console for details.\n\n{}").format(name, e))
         return object()