-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExtractParamChanges.py
33 lines (27 loc) · 1.13 KB
/
ExtractParamChanges.py
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
import re
import csv
# git diff last_version..new_version > buffer
with open('patch.diff') as diffFile:
diff = diffFile.readlines()
params = []
for line in diff:
lineMatch = re.search('^(\+|\-)\ +initConfig\w+\(\ *"([\w_]+)"\ *,*\ *&([\w_]+).+$', line)
if lineMatch:
params.append([lineMatch.group(1), lineMatch.group(2), lineMatch.group(3)])
paramCounts = {}
for param in params:
thisParamCount = params.count(param)
otherParam = list(param)
otherParam[0] = '+' if otherParam[0] == '-' else '-'
otherParamCount = params.count(otherParam)
# if thisParamCount == 1 and otherParamCount == 1:
# continue # Trivial case: go past
paramCounts[(param[1], param[2])] = [thisParamCount, otherParamCount]
print('{0},{1},{2}'.format(param[0], param[1], param[2]))
# with open('patch.csv', 'wb') as csvfile:
# writer = csv.writer(csvfile)
# for key in paramCounts.keys():
# writer.writerow([key[0], key[1], paramCounts[key][0], paramCounts[key][1]])
#
# go through the whole structure and look for exact pairs of + or - (and throw a notice if it's not a pair)
# write what's left to a CSV file'