def setUp(self): B3TestCase.setUp(self) when(self.console.config).get_external_plugins_dir().thenReturn(external_plugins_dir) self.conf = CfgConfigParser(testplugin_config_file) self.plugin_list = [ {'name': 'admin', 'conf': '@b3/conf/plugin_admin.ini', 'path': None, 'disabled': False}, ] fp, pathname, description = imp.find_module('testplugin1', [os.path.join(b3.getB3Path(True), '..', 'tests', 'plugins', 'fakeplugins')]) pluginModule1 = imp.load_module('testplugin1', fp, pathname, description) if fp: fp.close() fp, pathname, description = imp.find_module('testplugin3', [os.path.join(b3.getB3Path(True), '..', 'tests', 'plugins', 'fakeplugins')]) pluginModule3 = imp.load_module('testplugin3', fp, pathname, description) if fp: fp.close() fp, pathname, description = imp.find_module('admin', [os.path.join(b3.getB3Path(True), 'plugins')]) adminModule = imp.load_module('admin', fp, pathname, description) if fp: fp.close() when(self.console.config).get_plugins().thenReturn(self.plugin_list) when(self.console).pluginImport('admin', ANY).thenReturn(adminModule) when(self.console).pluginImport('testplugin1', ANY).thenReturn(pluginModule1) when(self.console).pluginImport('testplugin3', ANY).thenReturn(pluginModule3)
def _getpath(self, path): """Return an absolute path name and expand the user prefix (~), @b3 and @conf""" if path[0:3] == '@b3': path = "%s/%s" % (b3.getB3Path(), path[3:]) elif path[0:6] == '@conf/' or path[0:6] == '@conf\\': path = "%s/%s" % (b3.getConfPath(), path[5:]) return os.path.normpath(os.path.expanduser(path))
def getpath(self, section, setting): """Return an absolute path name and expand the user prefix (~)""" path = self.get(section, setting) if path[0:3] == "@b3": path = "%s/%s" % (b3.getB3Path(), path[3:]) elif path[0:6] == "@conf/" or path[0:6] == "@conf\\": path = "%s/%s" % (b3.getConfPath(), path[5:]) return os.path.normpath(os.path.expanduser(path))
def getpath(self, section, setting): """Return an absolute path name and expand the user prefix (~)""" path = self.get(section, setting) if path[0:3] == '@b3': path = "%s/%s" % (b3.getB3Path(), path[3:]) elif path[0:6] == '@conf/' or path[0:6] == '@conf\\': path = os.path.join(b3.getConfPath(), path[6:]) return os.path.normpath(os.path.expanduser(path))
def load(fileName): if os.path.splitext(fileName)[1].lower() == ".xml": config = XmlConfigParser() else: config = CfgConfigParser() fileName = os.path.normpath(fileName) if fileName[0:4] == "@b3\\" or fileName[0:4] == "@b3/": fileName = os.path.normpath("%s/%s" % (b3.getB3Path(), fileName[3:])) elif fileName[0:6] == "@conf\\" or fileName[0:6] == "@conf/": fileName = os.path.normpath("%s/%s" % (b3.getConfPath(), fileName[5:])) if config.load(fileName): return config else: return None
def load(fileName): if os.path.splitext(fileName)[1].lower() == '.xml': config = XmlConfigParser() else: config = CfgConfigParser() fileName = os.path.normpath(fileName) if fileName[0:4] == '@b3\\' or fileName[0:4] == '@b3/': fileName = os.path.normpath("%s/%s" % (b3.getB3Path(), fileName[3:])) elif fileName[0:6] == '@conf\\' or fileName[0:6] == '@conf/': fileName = os.path.normpath("%s/%s" % (b3.getConfPath(), fileName[5:])) if config.load(fileName): return config else: return None
def load_html_template(self, template): """ Loads template file from the file system. """ # build template file path _template_path = os.path.join(getConfPath(), 'templates/autodoc/') _template_file = _template_path + template self._console.verbose('AUTODOC: looking for %s' % _template_file) if not os.path.isfile(_template_file): _template_path = os.path.join(getB3Path(), 'conf/templates/autodoc/') _template_file = _template_path + template self._console.verbose('AUTODOC: looking for %s' % _template_file) self._console.debug('AUTODOC: Template = %s' % _template_file) # open template with open(_template_file, 'r') as template_file: template_data = template_file.read() return template_data