import glob import sys import re if len(sys.argv) != 3: print('usage: triage.py project resultsfile.txt') sys.exit(1) project = sys.argv[1] resultfile = sys.argv[2] f = open(project + '/true-positives.txt', 'rt') truepositives = f.read() f.close(); f = open(project + '/false-positives.txt', 'rt') falsepositives = f.read() f.close(); fin = open(resultfile,'rt') results = fin.read() fin.close() out = {} out['untriaged'] = '' out['fn'] = '' out['fp'] = '' out['tp'] = '' numberOfFalsePositives = 0 numberOfTruePositives = 0 numberOfFalseNegatives = 0 for result in results.split('\n'): result = result.strip() res = re.match('\\[('+project+'.+):([0-9]+)\\]:\s+[(][a-z]+[)] (.+)', result) if res == None: continue filename = res.group(1) linenr = res.group(2) message = res.group(3) css = 'untriaged' classification = 'Untriaged' if result in truepositives: css = 'tp' classification = 'True Positive' numberOfTruePositives += 1 elif result in falsepositives: css = 'fp' classification = 'False Positive' numberOfFalsePositives += 1 href = None html = '
Number of false negatives: ' + str(numberOfFalseNegatives) + '
\n') fout.write('Number of true positives: ' + str(numberOfTruePositives) + '
\n') fout.write('Number of false positives: ' + str(numberOfFalsePositives) + '
\n') fout.write('Filename | Line | Message | Classification |
---|