1 # Copyright (c) 2009 Google Inc. All rights reserved.
2 # Copyright (c) 2009 Apple Inc. All rights reserved.
3 # Copyright (c) 2010 Research In Motion Limited. All rights reserved.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above
12 # copyright notice, this list of conditions and the following disclaimer
13 # in the documentation and/or other materials provided with the
15 # * Neither the name of Google Inc. nor the names of its
16 # contributors may be used to endorse or promote products derived from
17 # this software without specific prior written permission.
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 from .attachment import Attachment
35 # FIXME: This class is kinda a hack for now. It exists so we have one
36 # place to hold bug logic, even if much of the code deals with
39 def __init__(self, bug_dictionary, bugzilla):
40 self.bug_dictionary = bug_dictionary
41 self._bugzilla = bugzilla
44 return self.bug_dictionary["id"]
47 # FIXME: Do we need to HTML unescape the title?
48 return self.bug_dictionary["title"]
50 def reporter_email(self):
51 return self.bug_dictionary["reporter_email"]
53 def assigned_to_email(self):
54 return self.bug_dictionary["assigned_to_email"]
56 # FIXME: This information should be stored in some sort of webkit_config.py instead of here.
57 unassigned_emails = frozenset([
58 "webkit-unassigned@lists.webkit.org",
59 "webkit-qt-unassigned@trolltech.com",
62 def is_unassigned(self):
63 return self.assigned_to_email() in self.unassigned_emails
66 return self.bug_dictionary["bug_status"]
68 # Bugzilla has many status states we don't really use in WebKit:
69 # https://bugs.webkit.org/page.cgi?id=fields.html#status
70 _open_states = ["UNCONFIRMED", "NEW", "ASSIGNED", "REOPENED"]
71 _closed_states = ["RESOLVED", "VERIFIED", "CLOSED"]
74 return self.status() in self._open_states
77 return not self.is_open()
79 def duplicate_of(self):
80 return self.bug_dictionary.get('dup_id', None)
82 # Rarely do we actually want obsolete attachments
83 def attachments(self, include_obsolete=False):
84 attachments = self.bug_dictionary["attachments"]
85 if not include_obsolete:
86 attachments = filter(lambda attachment:
87 not attachment["is_obsolete"], attachments)
88 return [Attachment(attachment, self) for attachment in attachments]
90 def patches(self, include_obsolete=False):
91 return [patch for patch in self.attachments(include_obsolete)
94 def unreviewed_patches(self):
95 return [patch for patch in self.patches() if patch.review() == "?"]
97 def reviewed_patches(self, include_invalid=False):
98 patches = [patch for patch in self.patches() if patch.review() == "+"]
101 # Checking reviewer() ensures that it was both reviewed and has a valid
103 return filter(lambda patch: patch.reviewer(), patches)
105 def commit_queued_patches(self, include_invalid=False):
106 patches = [patch for patch in self.patches()
107 if patch.commit_queue() == "+"]
110 # Checking committer() ensures that it was both commit-queue+'d and has
112 return filter(lambda patch: patch.committer(), patches)