OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python |
| 2 # Copyright (c) 2011 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 import re |
| 7 |
| 8 |
| 9 class Bug: |
| 10 """A class representing a bug. |
| 11 |
| 12 TODO(imasaki): add more functionalities here if bug-tracker API is available. |
| 13 For example, you can get the name of a bug owner. |
| 14 """ |
| 15 CHROME_BUG_URL = 'http://crbug.com/' |
| 16 WEBKIT_BUG_URL = 'http://webkit.org/b/' |
| 17 # Type enum for the bug. |
| 18 WEBKIT = 0 |
| 19 CHROMIUM = 1 |
| 20 OTHERS = 2 |
| 21 |
| 22 def __init__(self, bug_modifier): |
| 23 """Initialize the object using raw bug text (such as BUGWK2322). |
| 24 |
| 25 The bug modifier used in the test expectation file. |
| 26 |
| 27 Args: |
| 28 bug_modifier: a string representing a bug modifier. According to |
| 29 http://trac.webkit.org/wiki/TestExpectations#Modifiers, |
| 30 currently, BUGWK12345, BUGCR12345, BUGV8_12345, BUGDPRANKE are |
| 31 possible. |
| 32 """ |
| 33 self.bug_txt = bug_modifier |
| 34 pattern_for_webkit_bug = r'BUGWK(\d+)' |
| 35 match = re.search(pattern_for_webkit_bug, bug_modifier) |
| 36 if match: |
| 37 self.type = self.WEBKIT |
| 38 self.url = self.WEBKIT_BUG_URL + match.group(1) |
| 39 return |
| 40 pattern_for_chrome_bug = r'BUGCR(\d+)' |
| 41 match = re.search(pattern_for_chrome_bug, bug_modifier) |
| 42 if match: |
| 43 self.type = self.CHROMIUM |
| 44 self.url = self.CHROME_BUG_URL + match.group(1) |
| 45 return |
| 46 pattern_for_other_bug = r'BUG(\S+)' |
| 47 match = re.search(pattern_for_other_bug, bug_modifier) |
| 48 if match: |
| 49 self.type = self.OTHERS |
| 50 self.url = 'mailto:%s@chromium.org' % match.group(1).lower() |
| 51 return |
| 52 self.url = '' |
| 53 |
| 54 def __str__(self): |
| 55 """Get a string representation of a bug object. |
| 56 |
| 57 Returns: |
| 58 a string for HTML link representation of a bug. |
| 59 """ |
| 60 return '<a href="%s">%s</a>' % (self.url, self.bug_txt) |
OLD | NEW |