def get_config_obj(pathname): """Get the suite config object in the given file.""" # Named executors or suites are specified as the basename of the file, without the .yml # extension. if not fs.is_yaml_file(pathname) and not os.path.dirname(pathname): if pathname not in _config.NAMED_SUITES: # pylint: disable=unsupported-membership-test # Expand 'pathname' to full path. return None pathname = _config.NAMED_SUITES[pathname] # pylint: disable=unsubscriptable-object if not fs.is_yaml_file(pathname) or not os.path.isfile(pathname): raise optparse.OptionValueError("Expected a suite YAML config, but got '%s'" % pathname) return utils.load_yaml_file(pathname)
def get_config_obj(cls, suite_name): """Get the suite config object in the given file.""" # Named executors or suites are specified as the basename of the file, without the .yml # extension. if not fs.is_yaml_file(suite_name) and not os.path.dirname(suite_name): named_suites = cls.get_named_suites() if suite_name not in named_suites: # pylint: disable=unsupported-membership-test return None suite_name = named_suites[suite_name] # pylint: disable=unsubscriptable-object if not fs.is_yaml_file(suite_name) or not os.path.isfile(suite_name): raise ValueError("Expected a suite YAML config, but got '%s'" % suite_name) return utils.load_yaml_file(suite_name)
def get_all_yamls(target_dir): """Get all YAML files in the given directory.""" all_files = {} root = os.path.abspath(target_dir) files = os.listdir(root) for filename in files: (short_name, ext) = os.path.splitext(filename) if ext in (".yml", ".yaml"): pathname = os.path.join(root, filename) if not fs.is_yaml_file(pathname) or not os.path.isfile(pathname): raise optparse.OptionValueError( "Expected a suite YAML config, but got '%s'" % pathname) all_files[short_name] = load_yaml_file(pathname) return all_files
def get_config_obj(cls, suite_name): """Get the suite config object in the given file.""" if suite_name in cls.get_named_suites(): # Check if is a named suite first for efficiency. suite_path = cls.get_named_suites()[suite_name] elif fs.is_yaml_file(suite_name): # Check if is a path to a YAML file. if os.path.isfile(suite_name): suite_path = suite_name else: raise ValueError("Expected a suite YAML config, but got '%s'" % suite_name) else: # Not an explicit suite, return None. return None return utils.load_yaml_file(suite_path)