• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2009, Google Inc. All rights reserved.
2#
3# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions are
5# met:
6#
7#     * Redistributions of source code must retain the above copyright
8# notice, this list of conditions and the following disclaimer.
9#     * Redistributions in binary form must reproduce the above
10# copyright notice, this list of conditions and the following disclaimer
11# in the documentation and/or other materials provided with the
12# distribution.
13#     * Neither the name of Google Inc. nor the names of its
14# contributors may be used to endorse or promote products derived from
15# this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28#
29# WebKit's Python module for committer and reviewer validation
30
31class Committer:
32    def __init__(self, name, email):
33        self.full_name = name
34        self.bugzilla_email = email
35        self.can_review = False
36
37    def __str__(self):
38        return '"%s" <%s>' % (self.full_name, self.bugzilla_email)
39
40class Reviewer(Committer):
41    def __init__(self, name, email):
42        Committer.__init__(self, name, email)
43        self.can_review = True
44
45# All reviewers are committers, so this list is only of committers
46# who are not reviewers.
47committers_unable_to_review = [
48    Committer("Albert J. Wong", "ajwong@chromium.org"),
49    Committer("Ben Murdoch", "benm@google.com"),
50    Committer("Jeremy Orlow", "jorlow@chromium.org"),
51    Committer("Peter Kasting", "pkasting@google.com"),
52    Committer("Pierre d'Herbemont", "pdherbemont@free.fr"),
53    Committer("Shinichiro Hamaji", "hamaji@google.com"),
54    Committer("Zoltan Horvath", "hzoltan@inf.u-szeged.hu"),
55]
56
57reviewers_list = [
58    Reviewer("Adam Barth", "abarth@webkit.org"),
59    Reviewer("Adam Roben", "aroben@apple.com"),
60    Reviewer("Adam Treat", "treat@kde.org"),
61    Reviewer("Adele Peterson", "adele@apple.com"),
62    Reviewer("Alexey Proskuryakov", "ap@webkit.org"),
63    Reviewer("Anders Carlsson", "andersca@apple.com"),
64    Reviewer("Antti Koivisto", "koivisto@iki.fi"),
65    Reviewer("Ariya Hidayat", "ariya.hidayat@trolltech.com"),
66    Reviewer("Brady Eidson", "beidson@apple.com"),
67    Reviewer("Dan Bernstein", "mitz@webkit.org"),
68    Reviewer("Darin Adler", "darin@apple.com"),
69    Reviewer("Darin Fisher", "fishd@chromium.org"),
70    Reviewer("David Hyatt", "hyatt@apple.com"),
71    Reviewer("David Kilzer", "ddkilzer@webkit.org"),
72    Reviewer("David Levin", "levin@chromium.org"),
73    Reviewer("Dimitri Glazkov", "dglazkov@chromium.org"),
74    Reviewer("Eric Seidel", "eric@webkit.org"),
75    Reviewer("Gavin Barraclough", "barraclough@apple.com"),
76    Reviewer("George Staikos", "staikos@kde.org"),
77    Reviewer("Gustavo Noronha", "gns@gnome.org"),
78    Reviewer("Holger Freyther", "zecke@selfish.org"),
79    Reviewer("Jan Alonzo", "jmalonzo@gmail.com"),
80    Reviewer("Justin Garcia", "justin.garcia@apple.com"),
81    Reviewer("Kevin McCullough", "kmccullough@apple.com"),
82    Reviewer("Kevin Ollivier", "kevino@theolliviers.com"),
83    Reviewer("Maciej Stachowiak", "mjs@apple.com"),
84    Reviewer("Mark Rowe", "mrowe@apple.com"),
85    Reviewer("Nikolas Zimmermann", "zimmermann@kde.org"),
86    Reviewer("Oliver Hunt", "oliver@apple.com"),
87    Reviewer("Sam Weinig", "sam@webkit.org"),
88    Reviewer("Simon Fraser", "simon.fraser@apple.com"),
89    Reviewer("Simon Hausmann", "hausmann@webkit.org"),
90    Reviewer("Steve Falkenburg", "sfalken@apple.com"),
91    Reviewer("Timothy Hatcher", "timothy@hatcher.name"),
92    Reviewer(u'Tor Arne Vestb\xf8', "vestbo@webkit.org"),
93    Reviewer("Xan Lopez", "xan.lopez@gmail.com"),
94]
95
96
97class CommitterList:
98    # Committers and reviewers are passed in to allow easy testing
99    def __init__(self, committers=committers_unable_to_review, reviewers=reviewers_list):
100        self._committers = committers + reviewers
101        self._reviewers = reviewers
102        self._committers_by_email = {}
103
104    def committers(self):
105        return self._committers
106
107    def _email_to_committer_map(self):
108        if not len(self._committers_by_email):
109            for committer in self._committers:
110                self._committers_by_email[committer.bugzilla_email] = committer
111        return self._committers_by_email
112
113    def committer_by_bugzilla_email(self, bugzilla_email):
114        committer = self._email_to_committer_map().get(bugzilla_email)
115        if not committer:
116            raise Exception("Unknown committer: %s" % bugzilla_email)
117        return committer
118
119    def reviewer_by_bugzilla_email(self, bugzilla_email):
120        committer = self.committer_by_bugzilla_email(bugzilla_email)
121        if not committer.can_review:
122            raise Exception("Committer %s does not have review rights." % committer)
123        return committer
124