Chromium Code Reviews| 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 bug owner. | |
|
dennis_jeffrey
2011/08/24 17:40:47
'name bug' --> 'name of a bug'
imasaki1
2011/08/25 23:57:03
Done.
| |
| 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_txt): | |
| 23 """Initialize the object using raw bug text (such as BUGWK2322). | |
| 24 | |
| 25 The raw bug text is used in the test expectation file. According to | |
| 26 http://trac.webkit.org/wiki/TestExpectations#Modifiers, currently, | |
| 27 BUGWK12345, BUGCR12345, BUGV8_12345, BUGDPRANKE are possible. | |
|
dennis_jeffrey
2011/08/24 17:40:47
It looks like the "raw bug text" and the "modifier
imasaki1
2011/08/25 23:57:03
Done.
| |
| 28 """ | |
| 29 self.bug_txt = bug_txt | |
| 30 pattern_for_webkit_bug = r'BUGWK(\d+)' | |
| 31 match = re.search(pattern_for_webkit_bug, bug_txt) | |
| 32 if match: | |
| 33 self.type = self.WEBKIT | |
| 34 self.url = self.WEBKIT_BUG_URL + match.group(1) | |
| 35 return | |
| 36 pattern_for_chrome_bug = r'BUGCR(\d+)' | |
| 37 match = re.search(pattern_for_chrome_bug, bug_txt) | |
| 38 if match: | |
| 39 self.type = self.CHROMIUM | |
| 40 self.url = self.CHROME_BUG_URL + match.group(1) | |
| 41 return | |
| 42 pattern_for_other_bug = r'BUG(\S+)' | |
| 43 match = re.search(pattern_for_other_bug, bug_txt) | |
| 44 if match: | |
| 45 self.type = self.OTHERS | |
| 46 self.url = 'mailto:%s@chromium.org' % match.group(1).lower() | |
| 47 return | |
| 48 self.url = '' | |
| 49 | |
| 50 def ToString(self): | |
|
dennis_jeffrey
2011/08/24 17:40:47
Instead of calling this function ToString, how abo
imasaki1
2011/08/25 23:57:03
Done.
| |
| 51 """Get a HTML link representation of a bug. | |
| 52 | |
| 53 Returns: | |
| 54 a string for HTML link representation of a bug. | |
| 55 """ | |
| 56 return '<a href="%s">%s</a>' % (self.url, self.bug_txt) | |
| OLD | NEW |