32 """Script to update a failure list file to add/remove failures.
34 This is sort of like comm(1), except it recognizes comments and ignores them.
39 parser = argparse.ArgumentParser(
40 description=
'Adds/removes failures from the failure list.')
41 parser.add_argument(
'filename', type=str, help=
'failure list file to update')
42 parser.add_argument(
'--add', dest=
'add_list', action=
'append')
43 parser.add_argument(
'--remove', dest=
'remove_list', action=
'append')
45 args = parser.parse_args()
50 for add_file
in (args.add_list
or []):
51 with open(add_file)
as f:
55 for remove_file
in (args.remove_list
or []):
56 with open(remove_file)
as f:
59 raise Exception(
"Asked to both add and remove test: " + line)
60 remove_set.add(line.strip())
62 add_list = sorted(add_set, reverse=
True)
64 with open(args.filename)
as in_file:
65 existing_list = in_file.read()
67 with open(args.filename,
"w")
as f:
68 for line
in existing_list.splitlines(
True):
69 test = line.split(
"#")[0].strip()
70 while len(add_list) > 0
and test > add_list[-1]:
71 f.write(add_list.pop())
72 if test
not in remove_set: