-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinvFilter.py
More file actions
executable file
·40 lines (31 loc) · 1.21 KB
/
invFilter.py
File metadata and controls
executable file
·40 lines (31 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
# Filter invariants in a csv file
# only output those without any violations (all 0's)
import os
import sys
import argparse
import csv
def nonFaultSensitive(array):
for field in array[1:]:
if field.isdigit() and int(field) != 0:
return False
return True
def faultSensitive(array):
return not nonFaultSensitive(array)
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="Filter inviarants in a csv file, only output those without any violations")
parser.add_argument('csv', help='csv file to Validate', type=argparse.FileType('rb'))
group = parser.add_mutually_exclusive_group()
group.add_argument('--fault', action='store_true', help='only output fault revealing invariants')
group.add_argument('--no-fault', action='store_true', help='only output fault revealing invariants')
args = parser.parse_args()
reader = csv.reader(args.csv)
writer = csv.writer(sys.stdout)
writer.writerow(reader.next())
for row in reader:
if args.fault:
if faultSensitive(row):
writer.writerow(row)
elif args.no_fault:
if nonFaultSensitive(row):
writer.writerow(row)