def auto_select_xccdf_id(datastream, bench_number): xccdf_ids = xml_operations.get_all_xccdf_ids_in_datastream(datastream) n_xccdf_ids = len(xccdf_ids) if n_xccdf_ids == 0: msg = ("The provided DataStream doesn't contain any Benchmark") raise RuntimeError(msg) if bench_number < 0 or bench_number >= n_xccdf_ids: _print_available_benchmarks(xccdf_ids, n_xccdf_ids) logging.info("Selected Benchmark is {0}".format(bench_number)) msg = ("Please select a valid Benchmark number") raise RuntimeError(msg) if n_xccdf_ids > 1: _print_available_benchmarks(xccdf_ids, n_xccdf_ids) logging.info("Selected Benchmark is {0}".format(bench_number)) logging.info("To select a different Benchmark, " "use --xccdf-id-number option.") return xccdf_ids[bench_number]
def auto_select_xccdf_id(datastream, bench_number): xccdf_ids = xml_operations.get_all_xccdf_ids_in_datastream(datastream) n_xccdf_ids = len(xccdf_ids) if n_xccdf_ids == 0: msg = ("The provided DataStream doesn't contain any Benchmark") raise RuntimeError(msg) if bench_number < 0 or bench_number >= n_xccdf_ids: _print_available_benchmarks(xccdf_ids, n_xccdf_ids) logging.info("Selected Benchmark is {0}".format(bench_number)) msg = ("Please select a valid Benchmark number") raise RuntimeError(msg) if n_xccdf_ids > 1: _print_available_benchmarks(xccdf_ids, n_xccdf_ids) logging.info("Selected Benchmark is {0}".format(bench_number)) logging.info("To select a different Benchmark, " "use --xccdf-id-number option.") return xccdf_ids[bench_number]