Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(13)

Side by Side Diff: tools/rietveld_approvers_for_issue.py

Issue 2660133002: Add a tool to query the Rietveld approvers for an issue. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright 2017 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 from __future__ import print_function
7
8
9 import argparse
10 import json
11 import os
12 import sys
13 import urllib2
14
15
16 def main(argv):
17 parser = argparse.ArgumentParser()
18 parser.add_argument('issue', action='store', type=int)
19 args = parser.parse_args(argv)
20
21 try:
22 for approver in rietveld_approvers_for_issue(args.issue):
23 print(approver)
24 return 0
25 except Exception as e:
26 print('Exception raised: %s' % str(e), file=sys.stderr)
27 return 1
28
29
30 def rietveld_approvers_for_issue(issue):
31 """Returns a sorted list of the approves for a given Rietveld issue."""
32
33 url = 'https://codereview.chromium.org/api/%d?messages=true' % issue
34 fp = None
35 try:
36 fp = urllib2.urlopen(url)
37 issue_props = json.load(fp)
38 messages = issue_props.get('messages', [])
39 return sorted(set(m['sender'] for m in messages if m.get('approval')))
40 finally:
41 if fp:
42 fp.close()
43
44
45 if __name__ == '__main__':
46 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698