summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@kernel.org>2024-03-13 08:56:04 +0100
committerMauro Carvalho Chehab <mchehab@kernel.org>2024-03-14 06:04:42 +0100
commit36c9cb435d4957a7cbb255aece22f6f1c3125d43 (patch)
treedd8a5f932d2bf4b16c04bed9ad6052cccfa6a7bc /scripts
parent2fd782900bd85e91dff370a5b44c6d63e8f5efe9 (diff)
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: Mauro Carvalho Chehab <mchehab@kernel.org> Reviewed-by: Katarzyna Piecielska <katarzyna.piecielska@intel.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/xls_to_doc.py61
1 files changed, 32 insertions, 29 deletions
diff --git a/scripts/xls_to_doc.py b/scripts/xls_to_doc.py
index 510ab5427..fdf98105c 100755
--- a/scripts/xls_to_doc.py
+++ b/scripts/xls_to_doc.py
@@ -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()