def lint_tool_source_with(lint_context, tool_source, extra_modules=[]): import galaxy.tools.linters tool_xml = getattr(tool_source, "xml_tree", None) linter_modules = submodules.submodules(galaxy.tools.linters) linter_modules.extend(extra_modules) for module in linter_modules: tool_type = tool_source.parse_tool_type() or "default" lint_tool_types = getattr(module, "lint_tool_types", ["default"]) if not ("*" in lint_tool_types or tool_type in lint_tool_types): continue for (name, value) in inspect.getmembers(module): if callable(value) and name.startswith("lint_"): # Look at the first argument to the linter to decide # if we should lint the XML description or the abstract # tool parser object. first_arg = inspect.getargspec(value).args[0] if first_arg == "tool_xml": if tool_xml is None: # XML linter and non-XML tool, skip for now continue else: lint_context.lint(name, value, tool_xml) else: lint_context.lint(name, value, tool_source)
def lint_xml_with(lint_context, tool_xml, extra_modules=[]): import galaxy.tools.linters linter_modules = submodules.submodules(galaxy.tools.linters) linter_modules.extend(extra_modules) for module in linter_modules: for (name, value) in inspect.getmembers(module): if callable(value) and name.startswith("lint_"): lint_context.lint(name, value, tool_xml)
def _get_interface_modules(): interfaces = [] modules = submodules(sys.modules[__name__]) for module in modules: module_names = [getattr(module, _) for _ in dir(module)] classes = [_ for _ in module_names if inspect.isclass(_) and not _ == ContainerInterface and issubclass(_, ContainerInterface)] interfaces.extend(classes) return dict((x.container_type, x) for x in interfaces)
def _get_state_handlers_dict(): state_handlers = {} for module in submodules(galaxy.jobs.runners.state_handlers): for func in module.__all__: if func not in state_handlers: state_handlers[func] = [] state_handlers[func].append(getattr(module, func)) log.debug("Loaded '%s' state handler from module %s", func, module.__name__) return state_handlers
def _get_interface_modules(): interfaces = [] modules = submodules(sys.modules[__name__]) for module in modules: classes = filter( lambda x: inspect.isclass(x) and not x == ContainerInterface # noqa: E131 and issubclass(x, ContainerInterface), # noqa: E131 [getattr(module, x) for x in dir(module)]) interfaces.extend(classes) return dict([(x.container_type, x) for x in interfaces])
def lint_xml(tool_xml, level=LEVEL_ALL, fail_level=LEVEL_WARN): import galaxy.tools.linters lint_context = LintContext(level=level) linter_modules = submodules.submodules(galaxy.tools.linters) for module in linter_modules: for (name, value) in inspect.getmembers(module): if callable(value) and name.startswith("lint_"): lint_context.lint(module, name, value, tool_xml) found_warns = lint_context.found_warns found_errors = lint_context.found_errors if level == LEVEL_WARN and (found_warns or found_errors): return False else: return found_errors
def plugins_dict(module, plugin_type_identifier): """ Walk through all classes in submodules of module and find ones labelled with specified plugin_type_identifier and throw in a dictionary to allow constructions from plugins by these types later on. """ plugin_dict = {} for plugin_module in submodules( module ): # FIXME: this is not how one is suppose to use __all__ why did you do # this past John? for clazz in plugin_module.__all__: plugin_type = getattr( clazz, plugin_type_identifier, None ) if plugin_type: plugin_dict[ plugin_type ] = clazz return plugin_dict
def plugins_dict(module, plugin_type_identifier): """ Walk through all classes in submodules of module and find ones labelled with specified plugin_type_identifier and throw in a dictionary to allow constructions from plugins by these types later on. """ plugin_dict = {} for plugin_module in submodules(module): # FIXME: this is not how one is suppose to use __all__ why did you do # this past John? for clazz in plugin_module.__all__: plugin_type = getattr(clazz, plugin_type_identifier, None) if plugin_type: plugin_dict[plugin_type] = clazz return plugin_dict
def __plugin_modules( self ): import galaxy.jobs.metrics.instrumenters return submodules( galaxy.jobs.metrics.instrumenters )
def __resolver_modules(self): import galaxy.tools.deps.resolvers return submodules(galaxy.tools.deps.resolvers)
def __resolver_modules( self ): import galaxy.tools.deps.resolvers return submodules( galaxy.tools.deps.resolvers )