Verbose review summaries.

This commit is contained in:
Michael Still 2014-05-26 05:09:36 +00:00
parent 622d8ba996
commit 785dfcb552
1 changed files with 23 additions and 10 deletions

View File

@ -1,5 +1,6 @@
#!/usr/bin/python #!/usr/bin/python
import copy
import datetime import datetime
import json import json
import os import os
@ -85,17 +86,21 @@ while day < datetime.datetime.now():
day += one_day day += one_day
#for dirpath, subdirs, files in os.walk('merged'): # Reprocess the world?
# for filename in files: if False:
# if filename.endswith('.json'): for dirpath, subdirs, files in os.walk('merged'):
# continue for filename in files:
# changed_merge_files[os.path.join(dirpath, filename)] = True if filename.endswith('.json'):
continue
changed_merge_files[os.path.join(dirpath, filename)] = True
print 'Processing changed merge files' print 'Processing changed merge files'
for filename in changed_merge_files: for filename in changed_merge_files:
print '... %s' % filename print '... %s' % filename
with open(filename, 'r') as f: with open(filename, 'r') as f:
reviews = {} reviews = {}
reviews_verbose = {}
for line in f.readlines(): for line in f.readlines():
line = line.rstrip() line = line.rstrip()
@ -120,12 +125,18 @@ for filename in changed_merge_files:
project = j['change']['project'] project = j['change']['project']
for approval in j.get('approvals', []): for approval in j.get('approvals', []):
data = {'number': number,
'patchset': patchset,
'project': project,
'type': approval['type'],
'value': approval['value'],
'id': j['change']['id']}
reviews.setdefault(author, []) reviews.setdefault(author, [])
reviews[author].append({'number': number, reviews[author].append(copy.copy(data))
'patchset': patchset,
'project': project, data['comment'] = j['comment']
'type': approval['type'], reviews_verbose.setdefault(author, [])
'value': approval['value']}) reviews_verbose[author].append(copy.copy(data))
except Exception, e: except Exception, e:
print 'Error: %s\n' % e print 'Error: %s\n' % e
@ -134,5 +145,7 @@ for filename in changed_merge_files:
with open('%s_reviews.json' % filename, 'w') as f: with open('%s_reviews.json' % filename, 'w') as f:
f.write(json.dumps(reviews, indent=4)) f.write(json.dumps(reviews, indent=4))
with open('%s_reviews_verbose.json' % filename, 'w') as f:
f.write(json.dumps(reviews_verbose, indent=4))
print 'Done' print 'Done'