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

Side by Side Diff: rietveld.py

Issue 14061008: Have Rietveld.get_description() consistently strip CR and whitespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/rietveld_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 """Defines class Rietveld to easily access a rietveld instance. 5 """Defines class Rietveld to easily access a rietveld instance.
6 6
7 Security implications: 7 Security implications:
8 8
9 The following hypothesis are made: 9 The following hypothesis are made:
10 - Rietveld enforces: 10 - Rietveld enforces:
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 return json.loads( 75 return json.loads(
76 self.get('/search?format=json&commit=2&closed=3&' 76 self.get('/search?format=json&commit=2&closed=3&'
77 'keys_only=True&limit=1000&order=__key__'))['results'] 77 'keys_only=True&limit=1000&order=__key__'))['results']
78 78
79 def close_issue(self, issue): 79 def close_issue(self, issue):
80 """Closes the Rietveld issue for this changelist.""" 80 """Closes the Rietveld issue for this changelist."""
81 logging.info('closing issue %d' % issue) 81 logging.info('closing issue %d' % issue)
82 self.post("/%d/close" % issue, [('xsrf_token', self.xsrf_token())]) 82 self.post("/%d/close" % issue, [('xsrf_token', self.xsrf_token())])
83 83
84 def get_description(self, issue): 84 def get_description(self, issue):
85 """Returns the issue's description.""" 85 """Returns the issue's description.
86 return self.get('/%d/description' % issue) 86
87 Converts any CRLF into LF and strip extraneous whitespace.
88 """
89 return '\n'.join(self.get('/%d/description' % issue).strip().splitlines())
iannucci 2013/04/26 18:21:46 So if it ended with a line ending, it won't have a
M-A Ruel 2013/04/26 18:23:53 Exact, which is fine.
87 90
88 def get_issue_properties(self, issue, messages): 91 def get_issue_properties(self, issue, messages):
89 """Returns all the issue's metadata as a dictionary.""" 92 """Returns all the issue's metadata as a dictionary."""
90 url = '/api/%d' % issue 93 url = '/api/%d' % issue
91 if messages: 94 if messages:
92 url += '?messages=true' 95 url += '?messages=true'
93 return json.loads(self.get(url)) 96 data = json.loads(self.get(url))
97 data['description'] = '\n'.join(data['description'].strip().splitlines())
iannucci 2013/04/26 18:21:46 Can description can be absent/None?
M-A Ruel 2013/04/26 18:23:53 Not in the real API.
98 return data
94 99
95 def get_patchset_properties(self, issue, patchset): 100 def get_patchset_properties(self, issue, patchset):
96 """Returns the patchset properties.""" 101 """Returns the patchset properties."""
97 url = '/api/%d/%d' % (issue, patchset) 102 url = '/api/%d/%d' % (issue, patchset)
98 return json.loads(self.get(url)) 103 return json.loads(self.get(url))
99 104
100 def get_file_content(self, issue, patchset, item): 105 def get_file_content(self, issue, patchset, item):
101 """Returns the content of a new file. 106 """Returns the content of a new file.
102 107
103 Throws HTTP 302 exception if the file doesn't exist or is not a binary file. 108 Throws HTTP 302 exception if the file doesn't exist or is not a binary file.
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 if not messages: 445 if not messages:
441 # Assumes self._lookup uses deepcopy. 446 # Assumes self._lookup uses deepcopy.
442 del data['messages'] 447 del data['messages']
443 return data 448 return data
444 449
445 def get_patchset_properties(self, issue, patchset): 450 def get_patchset_properties(self, issue, patchset):
446 return self._lookup( 451 return self._lookup(
447 'get_patchset_properties', 452 'get_patchset_properties',
448 (issue, patchset), 453 (issue, patchset),
449 super(CachingRietveld, self).get_patchset_properties) 454 super(CachingRietveld, self).get_patchset_properties)
OLDNEW
« no previous file with comments | « no previous file | tests/rietveld_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698