Skip to content
Snippets Groups Projects
Commit 36c9cb43 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab
Browse files

scripts/xls_to_doc.py: use a main() function


Move the main code to a function, called only when the script
is executed directly from command line.

That allows the method to be re-used by other scripts if needed.

No functional changes.

Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
Reviewed-by: default avatarKatarzyna Piecielska <katarzyna.piecielska@intel.com>
parent 2fd78290
No related branches found
No related tags found
No related merge requests found
......@@ -293,32 +293,35 @@ class FillTests(TestList):
# Main
######
parser = argparse.ArgumentParser(description=__doc__,
formatter_class = argparse.ArgumentDefaultsHelpFormatter,
argument_default = argparse.SUPPRESS,
epilog = EPILOG)
parser.add_argument("--config", required = True,
help="JSON file describing the test plan template")
parser.add_argument("--xls", required = True,
help="Input XLS file.")
parser.add_argument("--sheets", nargs = "*",
help="Input only some specific sheets from the XLS file.")
parser.add_argument('--ignore-lists',action='store_false', default=True, help='Ignore fields that are updated via test lists')
parse_args = parser.parse_args()
fill_test = FillTests(parse_args.config)
if "sheets" not in parse_args:
parse_args.sheets = None
fill_test.parse_spreadsheet(parse_args.xls, parse_args.sheets)
## DEBUG: remove it later on
with open("fill_test.json", "w", encoding='utf8') as write_file:
json.dump(fill_test.tests, write_file, indent = 4)
with open("doc.json", "w", encoding='utf8') as write_file:
json.dump(fill_test.doc, write_file, indent = 4)
fill_test.update_test_files(parse_args)
def main():
parser = argparse.ArgumentParser(description=__doc__,
formatter_class = argparse.ArgumentDefaultsHelpFormatter,
argument_default = argparse.SUPPRESS,
epilog = EPILOG)
parser.add_argument("--config", required = True,
help="JSON file describing the test plan template")
parser.add_argument("--xls", required = True,
help="Input XLS file.")
parser.add_argument("--sheets", nargs = "*",
help="Input only some specific sheets from the XLS file.")
parser.add_argument('--ignore-lists',action='store_false', default=True, help='Ignore fields that are updated via test lists')
parse_args = parser.parse_args()
fill_test = FillTests(parse_args.config)
if "sheets" not in parse_args:
parse_args.sheets = None
fill_test.parse_spreadsheet(parse_args.xls, parse_args.sheets)
## DEBUG: remove it later on
with open("fill_test.json", "w", encoding='utf8') as write_file:
json.dump(fill_test.tests, write_file, indent = 4)
with open("doc.json", "w", encoding='utf8') as write_file:
json.dump(fill_test.doc, write_file, indent = 4)
fill_test.update_test_files(parse_args)
if __name__ == '__main__':
main()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment