def for_path(path, temp_path=None): """Produce a class:`Runnable` for supplied path.""" runnable_type = None if os.path.isdir(path): runnable_type = RunnableType.directory elif looks_like_a_tool_cwl(path): runnable_type = RunnableType.cwl_tool elif looks_like_a_data_manager_xml(path): runnable_type = RunnableType.galaxy_datamanager elif looks_like_a_tool_xml(path): runnable_type = RunnableType.galaxy_tool elif is_a_yaml_with_class(path, ["GalaxyWorkflow"]): runnable_type = RunnableType.galaxy_workflow elif path.endswith(".ga"): runnable_type = RunnableType.galaxy_workflow elif looks_like_a_cwl_artifact(path, ["Workflow"]): runnable_type = RunnableType.cwl_workflow if runnable_type is None: error("Unable to determine runnable type for path [%s]" % path) raise ExitCodeException(EXIT_CODE_UNKNOWN_FILE_TYPE) if temp_path: path = _copy_runnable_tree(path, runnable_type, temp_path) return Runnable(path, runnable_type)
def for_path(path, temp_path=None): """Produce a class:`Runnable` for supplied path.""" runnable_type = None if os.path.isdir(path): runnable_type = RunnableType.directory elif looks_like_a_tool_cwl(path): runnable_type = RunnableType.cwl_tool elif looks_like_a_data_manager_xml(path): runnable_type = RunnableType.galaxy_datamanager elif looks_like_a_tool_xml(path): runnable_type = RunnableType.galaxy_tool elif is_a_yaml_with_class(path, ["GalaxyWorkflow"]): runnable_type = RunnableType.galaxy_workflow elif path.endswith(".ga"): runnable_type = RunnableType.galaxy_workflow elif looks_like_a_cwl_artifact(path, ["Workflow"]): runnable_type = RunnableType.cwl_workflow else: # Check to see if it is a Galaxy workflow with a different extension try: with open(path, "r") as f: as_dict = yaml.safe_load(f) if as_dict.get("a_galaxy_workflow", False): runnable_type = RunnableType.galaxy_workflow except Exception: pass if runnable_type is None: error("Unable to determine runnable type for path [%s]" % path) raise ExitCodeException(EXIT_CODE_UNKNOWN_FILE_TYPE) if temp_path: path = _copy_runnable_tree(path, runnable_type, temp_path) return Runnable(path, runnable_type)