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

Unified Diff: rietveld.py

Issue 7977030: Add my_reviews.py script for perf time. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: another comment Created 9 years, 3 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 | « my_reviews.py ('k') | tests/rietveld_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: rietveld.py
diff --git a/rietveld.py b/rietveld.py
index 0b88eb0eb746ba898d97991f43b5e1b00460ee1a..d13173b3218cf31cdb21fe096f4b7702161814e2 100644
--- a/rietveld.py
+++ b/rietveld.py
@@ -242,6 +242,64 @@ class Rietveld(object):
('xsrf_token', self.xsrf_token()),
(flag, value)])
+ def search(
+ self,
+ owner=None, reviewer=None,
+ base=None,
+ closed=None, private=None, commit=None,
+ created_before=None, created_after=None,
+ modified_before=None, modified_after=None,
+ per_request=None, keys_only=False,
+ with_messages=False):
+ """Yields search results."""
+ # These are expected to be strings.
+ string_keys = {
+ 'owner': owner,
+ 'reviewer': reviewer,
+ 'base': base,
+ 'created_before': created_before,
+ 'created_after': created_after,
+ 'modified_before': modified_before,
+ 'modified_after': modified_after,
+ }
+ # These are either None, False or True.
+ three_state_keys = {
+ 'closed': closed,
+ 'private': private,
+ 'commit': commit,
+ }
+
+ url = '/search?format=json'
+ # Sort the keys mainly to ease testing.
+ for key in sorted(string_keys):
+ value = string_keys[key]
+ if value:
+ url += '&%s=%s' % (key, urllib2.quote(value))
+ for key in sorted(three_state_keys):
+ value = three_state_keys[key]
+ if value is not None:
+ url += '&%s=%d' % (key, int(value) + 1)
+
+ if keys_only:
+ url += '&keys_only=True'
+ if with_messages:
+ url += '&with_messages=True'
+ if per_request:
+ url += '&limit=%d' % per_request
+
+ cursor = ''
+ while True:
+ output = self.get(url + cursor)
+ if output.startswith('<'):
+ # It's an error message. Return as no result.
+ break
+ data = json.loads(output) or {}
+ if not data.get('results'):
+ break
+ for i in data['results']:
+ yield i
+ cursor = '&cursor=%s' % data['cursor']
+
def get(self, request_path, **kwargs):
kwargs.setdefault('payload', None)
return self._send(request_path, **kwargs)
« no previous file with comments | « my_reviews.py ('k') | tests/rietveld_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698