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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/rietveld_approvers_for_issue.py
diff --git a/tools/rietveld_approvers_for_issue.py b/tools/rietveld_approvers_for_issue.py
new file mode 100755
index 0000000000000000000000000000000000000000..4bff91c9157d2d95fbee8b11e60be03690fec447
--- /dev/null
+++ b/tools/rietveld_approvers_for_issue.py
@@ -0,0 +1,46 @@
+#!/usr/bin/env python
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+from __future__ import print_function
+
+
+import argparse
+import json
+import os
+import sys
+import urllib2
+
+
+def main(argv):
+ parser = argparse.ArgumentParser()
+ parser.add_argument('issue', action='store', type=int)
+ args = parser.parse_args(argv)
+
+ try:
+ for approver in rietveld_approvers_for_issue(args.issue):
+ print(approver)
+ return 0
+ except Exception as e:
+ print('Exception raised: %s' % str(e), file=sys.stderr)
+ return 1
+
+
+def rietveld_approvers_for_issue(issue):
+ """Returns a sorted list of the approves for a given Rietveld issue."""
+
+ url = 'https://codereview.chromium.org/api/%d?messages=true' % issue
+ fp = None
+ try:
+ fp = urllib2.urlopen(url)
+ issue_props = json.load(fp)
+ messages = issue_props.get('messages', [])
+ return sorted(set(m['sender'] for m in messages if m.get('approval')))
+ finally:
+ if fp:
+ fp.close()
+
+
+if __name__ == '__main__':
+ sys.exit(main(sys.argv[1:]))
« 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