OLD | NEW |
1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2014 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import cgi | 5 import cgi |
6 import ConfigParser | 6 import ConfigParser |
7 import json | 7 import json |
8 import os | 8 import os |
9 import time | 9 import time |
10 | 10 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 path: A string representing a path. | 101 path: A string representing a path. |
102 parsed_deps: A map from component path to its component name, repository, | 102 parsed_deps: A map from component path to its component name, repository, |
103 etc. | 103 etc. |
104 | 104 |
105 Returns: | 105 Returns: |
106 A tuple containing a component this path is in (e.g blink, skia, etc) | 106 A tuple containing a component this path is in (e.g blink, skia, etc) |
107 and a path in that component's repository. Returns None if the component | 107 and a path in that component's repository. Returns None if the component |
108 repository is not supported, i.e from googlecode. | 108 repository is not supported, i.e from googlecode. |
109 """ | 109 """ |
110 # First normalize the path by retreiving the normalized path. | 110 # First normalize the path by retreiving the normalized path. |
111 normalized_path = os.path.normpath(path.replace('\\', '/')) | 111 normalized_path = os.path.normpath(path).replace('\\', '/') |
112 | 112 |
113 # Iterate through all component paths in the parsed DEPS, in the decreasing | 113 # Iterate through all component paths in the parsed DEPS, in the decreasing |
114 # order of the length of the file path. | 114 # order of the length of the file path. |
115 for component_path in sorted(parsed_deps, | 115 for component_path in sorted(parsed_deps, |
116 key=(lambda path: -len(path))): | 116 key=(lambda path: -len(path))): |
117 # new_component_path is the component path with 'src/' removed. | 117 # new_component_path is the component path with 'src/' removed. |
118 new_component_path = component_path | 118 new_component_path = component_path |
119 if new_component_path.startswith('src/') and new_component_path != 'src/': | 119 if new_component_path.startswith('src/') and new_component_path != 'src/': |
120 new_component_path = new_component_path[len('src/'):] | 120 new_component_path = new_component_path[len('src/'):] |
121 | 121 |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 link: A link to add to the string. | 342 link: A link to add to the string. |
343 | 343 |
344 Returns: | 344 Returns: |
345 A string with hyperlink added. | 345 A string with hyperlink added. |
346 """ | 346 """ |
347 sanitized_link = cgi.escape(link, quote=True) | 347 sanitized_link = cgi.escape(link, quote=True) |
348 sanitized_text = cgi.escape(str(text)) | 348 sanitized_text = cgi.escape(str(text)) |
349 return '<a href="%s">%s</a>' % (sanitized_link, sanitized_text) | 349 return '<a href="%s">%s</a>' % (sanitized_link, sanitized_text) |
350 | 350 |
351 | 351 |
352 def PrettifyList(l): | 352 def PrettifyList(items): |
353 """Returns a string representation of a list. | 353 """Returns a string representation of a list. |
354 | 354 |
355 It adds comma in between the elements and removes the brackets. | 355 It adds comma in between the elements and removes the brackets. |
356 Args: | 356 Args: |
357 l: A list to prettify. | 357 items: A list to prettify. |
358 Returns: | 358 Returns: |
359 A string representation of the list. | 359 A string representation of the list. |
360 """ | 360 """ |
361 return str(l)[1:-1] | 361 return ', '.join(map(str, items)) |
| 362 |
| 363 |
| 364 def PrettifyFrameInfo(frame_indices, functions): |
| 365 """Return a string to represent the frames with functions.""" |
| 366 frames = [] |
| 367 for frame_index, function in zip(frame_indices, functions): |
| 368 frames.append('frame #%s, function "%s"' % (frame_index, function)) |
| 369 return '; '.join(frames) |
362 | 370 |
363 | 371 |
364 def PrettifyFiles(file_list): | 372 def PrettifyFiles(file_list): |
365 """Returns a string representation of a list of file names. | 373 """Returns a string representation of a list of file names. |
366 | 374 |
367 Args: | 375 Args: |
368 file_list: A list of tuple, (file_name, file_url). | 376 file_list: A list of tuple, (file_name, file_url). |
369 Returns: | 377 Returns: |
370 A string representation of file names with their urls. | 378 A string representation of file names with their urls. |
371 """ | 379 """ |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 review_url = None | 497 review_url = None |
490 reviewers = None | 498 reviewers = None |
491 line_content = blame.line_content | 499 line_content = blame.line_content |
492 message = blame.message | 500 message = blame.message |
493 | 501 |
494 result = Result(suspected_cl, revision_url, component_name, author, reason, | 502 result = Result(suspected_cl, revision_url, component_name, author, reason, |
495 review_url, reviewers, line_content, message) | 503 review_url, reviewers, line_content, message) |
496 result_list.append(result) | 504 result_list.append(result) |
497 | 505 |
498 return result_list | 506 return result_list |
OLD | NEW |