1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """Bug module that is necessary for the layout analyzer."""
9 from webkitpy
.layout_tests
.models
.test_expectations
import *
13 """A class representing a bug.
15 TODO(imasaki): add more functionalities here if bug-tracker API is available.
16 For example, you can get the name of a bug owner.
18 # Type enum for the bug.
23 def __init__(self
, bug_modifier
):
24 """Initialize the object using raw bug text (such as BUGWK2322).
26 The bug modifier used in the test expectation file.
29 bug_modifier: a string representing a bug modifier. According to
30 http://www.chromium.org/developers/testing/webkit-layout-tests/\
32 Bug identifiers are of the form "webkit.org/b/12345", "crbug.com/12345",
33 "code.google.com/p/v8/issues/detail?id=12345" or "Bug(username)"
35 match
= re
.match('Bug\((\w+)\)$', bug_modifier
)
37 self
.type = self
.OTHERS
38 self
.url
= 'mailto:%s@chromium.org' % match
.group(1).lower()
39 self
.bug_txt
= bug_modifier
42 self
.type = self
.GetBugType(bug_modifier
)
43 self
.url
= bug_modifier
44 self
.bug_txt
= bug_modifier
47 def GetBugType(self
, bug_modifier
):
48 """Returns type of the bug based on URL."""
49 if bug_modifier
.startswith(WEBKIT_BUG_PREFIX
):
51 if bug_modifier
.startswith(CHROMIUM_BUG_PREFIX
):
56 """Get a string representation of a bug object.
59 a string for HTML link representation of a bug.
61 return '<a href="%s">%s</a>' % (self
.url
, self
.bug_txt
)