From db490cb263c00672c5c34edeb16d49b8ae0ae1eb Mon Sep 17 00:00:00 2001 From: ArkaprabhaChakraborty Date: Sun, 12 Mar 2023 02:47:31 +0530 Subject: [PATCH] Preserve all internal comments Signed-off-by: ArkaprabhaChakraborty --- scripts/remove_duplicate_tests.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/remove_duplicate_tests.py b/scripts/remove_duplicate_tests.py index c72998f5..c32e4abb 100644 --- a/scripts/remove_duplicate_tests.py +++ b/scripts/remove_duplicate_tests.py @@ -21,12 +21,12 @@ def parse_apache_2_license(license_file): license_lines = license_lines[190:201] f.close() - # add the ## line to beginning of each line - license_lines = ''.join(['# ' + line.lstrip() for line in license_lines]) + license_lines = ''.join(['#' + line for line in license_lines]) return license_lines def remove_duplicate_test_tags(xml_file, license_file): - tree = ET.parse(xml_file) + tree = ET.parse(xml_file, + parser=ET.XMLParser(target=ET.TreeBuilder(insert_comments=True))) root = tree.getroot() test_case_names = [] for test in root.findall('test'): @@ -50,7 +50,9 @@ def remove_duplicate_test_tags(xml_file, license_file): if __name__ == '__main__': parser = ag.ArgumentParser() - parser.add_argument('--xml-file', type = str, help='Path to playlist.xml', required=True) - parser.add_argument('--license-file', type = str, help='Path to Apache 2.0 LICENSE', required=True) + parser.add_argument('-f','--xml-file', type = str, help='Path to playlist.xml', + required=True) + parser.add_argument('-l','--license-file', type = str, help='Path to Apache 2.0 LICENSE', + required=True, default=None) args = parser.parse_args() remove_duplicate_test_tags(args.xml_file, args.license_file)