diff options
Diffstat (limited to 'resources/tools/presentation/generator_files.py')
-rw-r--r-- | resources/tools/presentation/generator_files.py | 74 |
1 files changed, 12 insertions, 62 deletions
diff --git a/resources/tools/presentation/generator_files.py b/resources/tools/presentation/generator_files.py index f8428adf8c..e2bcf7835d 100644 --- a/resources/tools/presentation/generator_files.py +++ b/resources/tools/presentation/generator_files.py @@ -1,4 +1,4 @@ -# Copyright (c) 2017 Cisco and/or its affiliates. +# Copyright (c) 2018 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -67,8 +67,9 @@ def _tests_in_suite(suite_name, tests): def file_test_results(file_spec, input_data): - """Generate the file(s) with algorithm: file_test_results specified in the - specification file. + """Generate the file(s) with algorithms + - file_test_results + specified in the specification file. :param file_spec: File to generate. :param input_data: Data to process. @@ -88,66 +89,16 @@ def file_test_results(file_spec, input_data): format(file_spec["dir-tables"])) return None - job = file_spec["data"].keys()[0] - build = str(file_spec["data"][job][0]) - logging.info(" Writing file '{0}'".format(file_name)) - suites = input_data.suites(job, build)[file_spec["data-start-level"]:] - suites.sort_index(inplace=True) - - with open(file_name, "w") as file_handler: - file_handler.write(rst_header) - for suite_longname, suite in suites.iteritems(): - suite_name = suite["name"] - file_handler.write("\n{0}\n{1}\n".format( - suite_name, get_rst_title_char( - suite["level"] - file_spec["data-start-level"] - 1) * - len(suite_name))) - file_handler.write("\n{0}\n".format( - suite["doc"].replace('|br|', '\n\n -'))) - if _tests_in_suite(suite_name, input_data.tests(job, build)): - for tbl_file in table_lst: - if suite_name in tbl_file: - file_handler.write( - RST_INCLUDE_TABLE.format( - file_latex=tbl_file, - file_html=tbl_file.split("/")[-1])) - - logging.info(" Done.") - - -def file_merged_test_results(file_spec, input_data): - """Generate the file(s) with algorithm: file_merged_test_results specified - in the specification file. - - :param file_spec: File to generate. - :param input_data: Data to process. - :type file_spec: pandas.Series - :type input_data: InputData - """ - - file_name = "{0}{1}".format(file_spec["output-file"], - file_spec["output-file-ext"]) - rst_header = file_spec["file-header"] - - logging.info(" Generating the file {0} ...".format(file_name)) - - table_lst = get_files(file_spec["dir-tables"], ".csv", full_path=True) - if len(table_lst) == 0: - logging.error(" No tables to include in '{0}'. Skipping.". - format(file_spec["dir-tables"])) - return None - - logging.info(" Writing file '{0}'".format(file_name)) - - logging.info(" Creating the data set for the {0} '{1}'.". + logging.info(" Creating the 'tests' data set for the {0} '{1}'.". format(file_spec.get("type", ""), file_spec.get("title", ""))) tests = input_data.filter_data(file_spec) tests = input_data.merge_data(tests) - logging.info(" Creating the data set for the {0} '{1}'.". + logging.info(" Creating the 'suites' data set for the {0} '{1}'.". format(file_spec.get("type", ""), file_spec.get("title", ""))) + file_spec["filter"] = "all" suites = input_data.filter_data(file_spec, data_set="suites") suites = input_data.merge_data(suites) suites.sort_index(inplace=True) @@ -155,23 +106,22 @@ def file_merged_test_results(file_spec, input_data): with open(file_name, "w") as file_handler: file_handler.write(rst_header) for suite_longname, suite in suites.iteritems(): + # TODO: Remove when NDRPDRDISC tests are not used: if "ndrchk" in suite_longname or "pdrchk" in suite_longname: continue if len(suite_longname.split(".")) <= file_spec["data-start-level"]: continue - suite_name = suite["name"] file_handler.write("\n{0}\n{1}\n".format( - suite_name, get_rst_title_char( + suite["name"], get_rst_title_char( suite["level"] - file_spec["data-start-level"] - 1) * - len(suite_name))) + len(suite["name"]))) file_handler.write("\n{0}\n".format( suite["doc"].replace('|br|', '\n\n -'))) - if _tests_in_suite(suite_name, tests): + if _tests_in_suite(suite["name"], tests): for tbl_file in table_lst: - if suite_name in tbl_file: + if suite["name"] in tbl_file: file_handler.write( RST_INCLUDE_TABLE.format( file_latex=tbl_file, file_html=tbl_file.split("/")[-1])) - logging.info(" Done.") |