Changeset 53729 in webkit


Ignore:
Timestamp:
Jan 22, 2010 3:58:03 PM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-01-22 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

Make bugzilla.py and webkitport.py conform to pep8
https://bugs.webkit.org/show_bug.cgi?id=34015

This patch makes webkitport.py and bugzilla.py mostly conform to PEP8
style as enforced by pep8.py. I wasn't able to get rid of all the
errors because I'm not sure how to wrap some lines properly. Also,
there are a few deprication errors that I couldn't resolve easily.
However, this is a massive improvement in compliance.

  • Scripts/webkitpy/bugzilla.py:
  • Scripts/webkitpy/webkitport.py:
Location:
trunk/WebKitTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r53728 r53729  
     12010-01-22  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Make bugzilla.py and webkitport.py conform to pep8
     6        https://bugs.webkit.org/show_bug.cgi?id=34015
     7
     8        This patch makes webkitport.py and bugzilla.py mostly conform to PEP8
     9        style as enforced by pep8.py.  I wasn't able to get rid of all the
     10        errors because I'm not sure how to wrap some lines properly.  Also,
     11        there are a few deprication errors that I couldn't resolve easily.
     12        However, this is a massive improvement in compliance.
     13
     14        * Scripts/webkitpy/bugzilla.py:
     15        * Scripts/webkitpy/webkitport.py:
     16
    1172010-01-22  Adam Barth  <abarth@webkit.org>
    218
  • trunk/WebKitTools/Scripts/webkitpy/bugzilla.py

    r53542 r53729  
    11# Copyright (c) 2009, Google Inc. All rights reserved.
    22# Copyright (c) 2009 Apple Inc. All rights reserved.
    3 # 
     3#
    44# Redistribution and use in source and binary forms, with or without
    55# modification, are permitted provided that the following conditions are
    66# met:
    7 # 
     7#
    88#     * Redistributions of source code must retain the above copyright
    99# notice, this list of conditions and the following disclaimer.
     
    1515# contributors may be used to endorse or promote products derived from
    1616# this software without specific prior written permission.
    17 # 
     17#
    1818# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1919# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     
    4646from mechanize import Browser
    4747
     48
    4849def parse_bug_id(message):
    4950    match = re.search("http\://webkit\.org/b/(?P<bug_id>\d+)", message)
    5051    if match:
    5152        return int(match.group('bug_id'))
    52     match = re.search(Bugzilla.bug_server_regex + "show_bug\.cgi\?id=(?P<bug_id>\d+)", message)
     53    match = re.search(
     54        Bugzilla.bug_server_regex + "show_bug\.cgi\?id=(?P<bug_id>\d+)",
     55        message)
    5356    if match:
    5457        return int(match.group('bug_id'))
     
    6164
    6265class Attachment(object):
     66
    6367    def __init__(self, attachment_dictionary, bug):
    6468        self._attachment_dictionary = attachment_dictionary
     
    7478
    7579    def attacher_is_committer(self):
    76         return self._bugzilla.committers.committer_by_email(patch.attacher_email())
     80        return self._bugzilla.committers.committer_by_email(
     81            patch.attacher_email())
    7782
    7883    def attacher_email(self):
     
    101106
    102107    def url(self):
    103         # FIXME: This should just return self._bugzilla().attachment_url_for_id(self.id()).  scm_unittest.py depends on the current behavior.
     108        # FIXME: This should just return
     109        # self._bugzilla().attachment_url_for_id(self.id()). scm_unittest.py
     110        # depends on the current behavior.
    104111        return self._attachment_dictionary.get("url")
    105112
     
    108115        if not email:
    109116            return None
    110         committer = getattr(self._bugzilla().committers, "%s_by_email" % flag)(email)
     117        committer = getattr(self._bugzilla().committers,
     118                            "%s_by_email" % flag)(email)
    111119        if committer:
    112120            return committer
    113         log("Warning, attachment %s on bug %s has invalid %s (%s)" % (self._attachment_dictionary['id'], self._attachment_dictionary['bug_id'], flag, email))
     121        log("Warning, attachment %s on bug %s has invalid %s (%s)" % (
     122                 self._attachment_dictionary['id'],
     123                 self._attachment_dictionary['bug_id'], flag, email))
    114124
    115125    def reviewer(self):
     
    124134
    125135
    126 # FIXME: This class is kinda a hack for now.  It exists so we have one place
    127 # to hold bug logic, even if much of the code deals with dictionaries still.
    128136class Bug(object):
     137    # FIXME: This class is kinda a hack for now.  It exists so we have one
     138    # place to hold bug logic, even if much of the code deals with
     139    # dictionaries still.
     140
    129141    def __init__(self, bug_dictionary, bugzilla):
    130142        self.bug_dictionary = bug_dictionary
     
    141153        attachments = self.bug_dictionary["attachments"]
    142154        if not include_obsolete:
    143             attachments = filter(lambda attachment: not attachment["is_obsolete"], attachments)
     155            attachments = filter(lambda attachment:
     156                                 not attachment["is_obsolete"], attachments)
    144157        return [Attachment(attachment, self) for attachment in attachments]
    145158
    146159    def patches(self, include_obsolete=False):
    147         return [patch for patch in self.attachments(include_obsolete) if patch.is_patch()]
     160        return [patch for patch in self.attachments(include_obsolete)
     161                                   if patch.is_patch()]
    148162
    149163    def unreviewed_patches(self):
     
    154168        if include_invalid:
    155169            return patches
    156         # Checking reviewer() ensures that it was both reviewed and has a valid reviewer.
     170        # Checking reviewer() ensures that it was both reviewed and has a valid
     171        # reviewer.
    157172        return filter(lambda patch: patch.reviewer(), patches)
    158173
    159174    def commit_queued_patches(self, include_invalid=False):
    160         patches = [patch for patch in self.patches() if patch.commit_queue() == "+"]
     175        patches = [patch for patch in self.patches()
     176                                      if patch.commit_queue() == "+"]
    161177        if include_invalid:
    162178            return patches
    163         # Checking committer() ensures that it was both commit-queue+'d and has a valid committer.
     179        # Checking committer() ensures that it was both commit-queue+'d and has
     180        # a valid committer.
    164181        return filter(lambda patch: patch.committer(), patches)
    165182
     
    167184# A container for all of the logic for making and parsing buzilla queries.
    168185class BugzillaQueries(object):
     186
    169187    def __init__(self, bugzilla):
    170188        self._bugzilla = bugzilla
    171189
    172     # Note: _load_query and _fetch_bug are the only two methods which access self._bugzilla.
     190    # Note: _load_query and _fetch_bug are the only two methods which access
     191    # self._bugzilla.
     192
    173193    def _load_query(self, query):
    174194        self._bugzilla.authenticate()
     
    180200        return self._bugzilla.fetch_bug(bug_id)
    181201
    182 
    183202    def _fetch_bug_ids_advanced_query(self, query):
    184203        soup = BeautifulSoup(self._load_query(query))
    185         # The contents of the <a> inside the cells in the first column happen to be the bug id.
    186         return [int(bug_link_cell.find("a").string) for bug_link_cell in soup('td', "first-child")]
     204        # The contents of the <a> inside the cells in the first column happen
     205        # to be the bug id.
     206        return [int(bug_link_cell.find("a").string)
     207                for bug_link_cell in soup('td', "first-child")]
    187208
    188209    def _parse_attachment_ids_request_query(self, page):
     
    190211        attachment_href = re.compile("attachment.cgi\?id=\d+&action=review")
    191212        attachment_links = SoupStrainer("a", href=attachment_href)
    192         return [int(digits.search(tag["href"]).group(0)) for tag in BeautifulSoup(page, parseOnlyThese=attachment_links)]
     213        return [int(digits.search(tag["href"]).group(0))
     214                for tag in BeautifulSoup(page, parseOnlyThese=attachment_links)]
    193215
    194216    def _fetch_attachment_ids_request_query(self, query):
     
    201223
    202224    def fetch_patches_from_pending_commit_list(self):
    203         return sum([self._fetch_bug(bug_id).reviewed_patches() for bug_id in self.fetch_bug_ids_from_pending_commit_list()], [])
     225        return sum([self._fetch_bug(bug_id).reviewed_patches()
     226            for bug_id in self.fetch_bug_ids_from_pending_commit_list()], [])
    204227
    205228    def fetch_bug_ids_from_commit_queue(self):
     
    207230        return self._fetch_bug_ids_advanced_query(commit_queue_url)
    208231
    209     # This function will only return patches which have valid committers set.  It won't reject patches with invalid committers/reviewers.
    210232    def fetch_patches_from_commit_queue(self):
    211         return sum([self._fetch_bug(bug_id).commit_queued_patches() for bug_id in self.fetch_bug_ids_from_commit_queue()], [])
     233        # This function will only return patches which have valid committers
     234        # set.  It won't reject patches with invalid committers/reviewers.
     235        return sum([self._fetch_bug(bug_id).commit_queued_patches()
     236                    for bug_id in self.fetch_bug_ids_from_commit_queue()], [])
    212237
    213238    def _fetch_bug_ids_from_review_queue(self):
     
    216241
    217242    def fetch_patches_from_review_queue(self, limit=None):
    218         return sum([self._fetch_bug(bug_id).unreviewed_patches() for bug_id in self._fetch_bug_ids_from_review_queue()[:limit]], []) # [:None] returns the whole array.
    219 
    220     # FIXME: Why do we have both fetch_patches_from_review_queue and fetch_attachment_ids_from_review_queue??
     243        # [:None] returns the whole array.
     244        return sum([self._fetch_bug(bug_id).unreviewed_patches()
     245            for bug_id in self._fetch_bug_ids_from_review_queue()[:limit]], [])
     246
     247    # FIXME: Why do we have both fetch_patches_from_review_queue and
     248    # fetch_attachment_ids_from_review_queue??
    221249    # NOTE: This is also the only client of _fetch_attachment_ids_request_query
     250
    222251    def fetch_attachment_ids_from_review_queue(self):
    223252        review_queue_url = "request.cgi?action=queue&type=review&group=type"
     
    226255
    227256class CommitterValidator(object):
     257
    228258    def __init__(self, bugzilla):
    229259        self._bugzilla = bugzilla
    230260
    231     # _view_source_link belongs in some sort of webkit_config.py module.
    232     def _view_source_link(self, local_path):
     261    # _view_source_url belongs in some sort of webkit_config.py module.
     262    def _view_source_url(self, local_path):
    233263        return "http://trac.webkit.org/browser/trunk/%s" % local_path
    234264
    235265    def _flag_permission_rejection_message(self, setter_email, flag_name):
    236         committer_list = "WebKitTools/Scripts/webkitpy/committers.py" # This could be computed from CommitterList.__file__
    237         contribution_guidlines_url = "http://webkit.org/coding/contributing.html" # Should come from some webkit_config.py
    238         queue_administrator = "eseidel@chromium.org" # This could be queried from the status_server.
    239         queue_name = "commit-queue" # This could be queried from the tool.
    240         rejection_message = "%s does not have %s permissions according to %s." % (setter_email, flag_name, self._view_source_link(committer_list))
    241         rejection_message += "\n\n- If you do not have %s rights please read %s for instructions on how to use bugzilla flags." % (flag_name, contribution_guidlines_url)
    242         rejection_message += "\n\n- If you have %s rights please correct the error in %s by adding yourself to the file (no review needed)." % (flag_name, committer_list)
    243         rejection_message += "  Due to bug 30084 the %s will require a restart after your change." % queue_name
    244         rejection_message += "  Please contact %s to request a %s restart." % (queue_administrator, queue_name)
    245         rejection_message += "  After restart the %s will correctly respect your %s rights." % (queue_name, flag_name)
    246         return rejection_message
     266        # This could be computed from CommitterList.__file__
     267        committer_list = "WebKitTools/Scripts/webkitpy/committers.py"
     268        # Should come from some webkit_config.py
     269        contribution_guidlines = "http://webkit.org/coding/contributing.html"
     270        # This could be queried from the status_server.
     271        queue_administrator = "eseidel@chromium.org"
     272        # This could be queried from the tool.
     273        queue_name = "commit-queue"
     274        message = "%s does not have %s permissions according to %s." % (
     275                        setter_email,
     276                        flag_name,
     277                        self._view_source_url(committer_list))
     278        message += "\n\n- If you do not have %s rights please read %s for instructions on how to use bugzilla flags." % (
     279                        flag_name, contribution_guidlines)
     280        message += "\n\n- If you have %s rights please correct the error in %s by adding yourself to the file (no review needed).  " % (
     281                        flag_name, committer_list)
     282        message += "Due to bug 30084 the %s will require a restart after your change.  " % queue_name
     283        message += "Please contact %s to request a %s restart.  " % (
     284                        queue_administrator, queue_name)
     285        message += "After restart the %s will correctly respect your %s rights." % (
     286                        queue_name, flag_name)
     287        return message
    247288
    248289    def _validate_setter_email(self, patch, result_key, rejection_function):
    249290        committer = getattr(patch, result_key)()
    250         # If the flag is set, and we don't recognize the setter, reject the flag!
     291        # If the flag is set, and we don't recognize the setter, reject the
     292        # flag!
    251293        setter_email = patch._attachment_dictionary.get("%s_email" % result_key)
    252294        if setter_email and not committer:
    253             rejection_function(patch.id(), self._flag_permission_rejection_message(setter_email, result_key))
     295            rejection_function(patch.id(),
     296                self._flag_permission_rejection_message(setter_email,
     297                                                        result_key))
    254298            return False
    255299        return True
     
    258302        validated_patches = []
    259303        for patch in patches:
    260             if self._validate_setter_email(patch, "reviewer", self.reject_patch_from_review_queue) and self._validate_setter_email(patch, "committer", self.reject_patch_from_commit_queue):
     304            if (self._validate_setter_email(
     305                    patch, "reviewer", self.reject_patch_from_review_queue)
     306                and self._validate_setter_email(
     307                    patch, "committer", self.reject_patch_from_commit_queue)):
    261308                validated_patches.append(patch)
    262309        return validated_patches
    263310
    264     def reject_patch_from_commit_queue(self, attachment_id, additional_comment_text=None):
     311    def reject_patch_from_commit_queue(self,
     312                                       attachment_id,
     313                                       additional_comment_text=None):
    265314        comment_text = "Rejecting patch %s from commit-queue." % attachment_id
    266         self._bugzilla.set_flag_on_attachment(attachment_id, 'commit-queue', '-', comment_text, additional_comment_text)
    267 
    268     def reject_patch_from_review_queue(self, attachment_id, additional_comment_text=None):
     315        self._bugzilla.set_flag_on_attachment(attachment_id,
     316                                              "commit-queue",
     317                                              "-",
     318                                              comment_text,
     319                                              additional_comment_text)
     320
     321    def reject_patch_from_review_queue(self,
     322                                       attachment_id,
     323                                       additional_comment_text=None):
    269324        comment_text = "Rejecting patch %s from review queue." % attachment_id
    270         self._bugzilla.set_flag_on_attachment(attachment_id, 'review', '-', comment_text, additional_comment_text)
     325        self._bugzilla.set_flag_on_attachment(attachment_id,
     326                                              'review',
     327                                              '-',
     328                                              comment_text,
     329                                              additional_comment_text)
    271330
    272331
    273332class Bugzilla(object):
     333
    274334    def __init__(self, dryrun=False, committers=CommitterList()):
    275335        self.dryrun = dryrun
     
    278338        self.committers = committers
    279339
    280         # FIXME: We should use some sort of Browser mock object when in dryrun mode (to prevent any mistakes).
     340        # FIXME: We should use some sort of Browser mock object when in dryrun
     341        # mode (to prevent any mistakes).
    281342        self.browser = Browser()
    282         # Ignore bugs.webkit.org/robots.txt until we fix it to allow this script
     343        # Ignore bugs.webkit.org/robots.txt until we fix it to allow this
     344        # script.
    283345        self.browser.set_handle_robots(False)
    284346
     
    291353    def bug_url_for_bug_id(self, bug_id, xml=False):
    292354        content_type = "&ctype=xml" if xml else ""
    293         return "%sshow_bug.cgi?id=%s%s" % (self.bug_server_url, bug_id, content_type)
     355        return "%sshow_bug.cgi?id=%s%s" % (self.bug_server_url,
     356                                           bug_id,
     357                                           content_type)
    294358
    295359    def short_bug_url_for_bug_id(self, bug_id):
     
    300364        if action and action != "view":
    301365            action_param = "&action=%s" % action
    302         return "%sattachment.cgi?id=%s%s" % (self.bug_server_url, attachment_id, action_param)
    303 
    304     def _parse_attachment_flag(self, element, flag_name, attachment, result_key):
    305         flag = element.find('flag', attrs={'name' : flag_name})
     366        return "%sattachment.cgi?id=%s%s" % (self.bug_server_url,
     367                                             attachment_id,
     368                                             action_param)
     369
     370    def _parse_attachment_flag(self,
     371                               element,
     372                               flag_name,
     373                               attachment,
     374                               result_key):
     375        flag = element.find('flag', attrs={'name': flag_name})
    306376        if flag:
    307377            attachment[flag_name] = flag['status']
     
    320390        attachment['attacher_email'] = str(element.find('attacher').string)
    321391        attachment['type'] = str(element.find('type').string)
    322         self._parse_attachment_flag(element, 'review', attachment, 'reviewer_email')
    323         self._parse_attachment_flag(element, 'commit-queue', attachment, 'committer_email')
     392        self._parse_attachment_flag(
     393                element, 'review', attachment, 'reviewer_email')
     394        self._parse_attachment_flag(
     395                element, 'commit-queue', attachment, 'committer_email')
    324396        return attachment
    325397
     
    331403        bug["reporter_email"] = str(soup.find("reporter").string)
    332404        bug["assigned_to_email"] = str(soup.find("assigned_to").string)
    333         bug["cc_emails"] = [str(element.string) for element in soup.findAll('cc')]
     405        bug["cc_emails"] = [str(element.string)
     406                            for element in soup.findAll('cc')]
    334407        bug["attachments"] = [self._parse_attachment_element(element, bug["id"]) for element in soup.findAll('attachment')]
    335408        return bug
    336409
    337     # Makes testing fetch_*_from_bug() possible until we have a better BugzillaNetwork abstration.
     410    # Makes testing fetch_*_from_bug() possible until we have a better
     411    # BugzillaNetwork abstration.
     412
    338413    def _fetch_bug_page(self, bug_id):
    339414        bug_url = self.bug_url_for_bug_id(bug_id, xml=True)
     
    345420
    346421    # FIXME: A BugzillaCache object should provide all these fetch_ methods.
     422
    347423    def fetch_bug(self, bug_id):
    348424        return Bug(self.fetch_bug_dictionary(bug_id), self)
    349425
    350426    def _parse_bug_id_from_attachment_page(self, page):
    351         up_link = BeautifulSoup(page).find('link', rel='Up') # The "Up" relation happens to point to the bug.
     427        # The "Up" relation happens to point to the bug.
     428        up_link = BeautifulSoup(page).find('link', rel='Up')
    352429        if not up_link:
    353             return None # This attachment does not exist (or you don't have permissions to view it).
     430            # This attachment does not exist (or you don't have permissions to
     431            # view it).
     432            return None
    354433        match = re.search("show_bug.cgi\?id=(?P<bug_id>\d+)", up_link['href'])
    355434        return int(match.group('bug_id'))
     
    363442        return self._parse_bug_id_from_attachment_page(page)
    364443
    365     # FIXME: This should just return Attachment(id), which should be able to lazily fetch needed data.
     444    # FIXME: This should just return Attachment(id), which should be able to
     445    # lazily fetch needed data.
     446
    366447    def fetch_attachment(self, attachment_id):
    367         # We could grab all the attachment details off of the attachment edit page
    368         # but we already have working code to do so off of the bugs page, so re-use that.
     448        # We could grab all the attachment details off of the attachment edit
     449        # page but we already have working code to do so off of the bugs page,
     450        # so re-use that.
    369451        bug_id = self.bug_id_for_attachment_id(attachment_id)
    370452        if not bug_id:
    371453            return None
    372         for attachment in self.fetch_bug(bug_id).attachments(include_obsolete=True):
     454        attachments = self.fetch_bug(bug_id).attachments(include_obsolete=True)
     455        for attachment in attachments:
    373456            if attachment.id() == int(attachment_id):
    374457                return attachment
     
    384467            return
    385468
    386         (username, password) = Credentials(self.bug_server_host, git_prefix="bugzilla").read_credentials()
     469        (username, password) = Credentials(
     470                self.bug_server_host, git_prefix="bugzilla").read_credentials()
    387471
    388472        log("Logging in as %s..." % username)
     
    394478
    395479        match = re.search("<title>(.+?)</title>", response.read())
    396         # If the resulting page has a title, and it contains the word "invalid" assume it's the login failure page.
     480        # If the resulting page has a title, and it contains the word "invalid"
     481        # assume it's the login failure page.
    397482        if match and re.search("Invalid", match.group(1), re.IGNORECASE):
    398483            # FIXME: We could add the ability to try again on failure.
     
    401486        self.authenticated = True
    402487
    403     def _fill_attachment_form(self, description, patch_file_object, comment_text=None, mark_for_review=False, mark_for_commit_queue=False, mark_for_landing=False, bug_id=None):
     488    def _fill_attachment_form(self,
     489                              description,
     490                              patch_file_object,
     491                              comment_text=None,
     492                              mark_for_review=False,
     493                              mark_for_commit_queue=False,
     494                              mark_for_landing=False, bug_id=None):
    404495        self.browser['description'] = description
    405496        self.browser['ispatch'] = ("1",)
     
    417508        else:
    418509            patch_name ="%s.patch" % timestamp()
    419         self.browser.add_file(patch_file_object, "text/plain", patch_name, 'data')
    420 
    421     def add_patch_to_bug(self, bug_id, patch_file_object, description, comment_text=None, mark_for_review=False, mark_for_commit_queue=False, mark_for_landing=False):
    422         self.authenticate()
    423 
    424         log('Adding patch "%s" to %sshow_bug.cgi?id=%s' % (description, self.bug_server_url, bug_id))
    425 
    426         if self.dryrun:
    427             log(comment_text)
    428             return
    429 
    430         self.browser.open("%sattachment.cgi?action=enter&bugid=%s" % (self.bug_server_url, bug_id))
     510        self.browser.add_file(patch_file_object,
     511                              "text/plain",
     512                              patch_name,
     513                              'data')
     514
     515    def add_patch_to_bug(self,
     516                         bug_id,
     517                         patch_file_object,
     518                         description,
     519                         comment_text=None,
     520                         mark_for_review=False,
     521                         mark_for_commit_queue=False,
     522                         mark_for_landing=False):
     523        self.authenticate()
     524
     525        log('Adding patch "%s" to %sshow_bug.cgi?id=%s' % (description,
     526                                                           self.bug_server_url,
     527                                                           bug_id))
     528
     529        if self.dryrun:
     530            log(comment_text)
     531            return
     532
     533        self.browser.open("%sattachment.cgi?action=enter&bugid=%s" % (
     534                          self.bug_server_url, bug_id))
    431535        self.browser.select_form(name="entryform")
    432         self._fill_attachment_form(description, patch_file_object, mark_for_review=mark_for_review, mark_for_commit_queue=mark_for_commit_queue, mark_for_landing=mark_for_landing, bug_id=bug_id)
     536        self._fill_attachment_form(description,
     537                                   patch_file_object,
     538                                   mark_for_review=mark_for_review,
     539                                   mark_for_commit_queue=mark_for_commit_queue,
     540                                   mark_for_landing=mark_for_landing,
     541                                   bug_id=bug_id)
    433542        if comment_text:
    434543            log(comment_text)
     
    446555
    447556    def _check_create_bug_response(self, response_html):
    448         match = re.search("<title>Bug (?P<bug_id>\d+) Submitted</title>", response_html)
     557        match = re.search("<title>Bug (?P<bug_id>\d+) Submitted</title>",
     558                          response_html)
    449559        if match:
    450560            return match.group('bug_id')
    451561
    452         match = re.search('<div id="bugzilla-body">(?P<error_message>.+)<div id="footer">', response_html, re.DOTALL)
     562        match = re.search(
     563            '<div id="bugzilla-body">(?P<error_message>.+)<div id="footer">',
     564            response_html,
     565            re.DOTALL)
    453566        error_message = "FAIL"
    454567        if match:
    455             text_lines = BeautifulSoup(match.group('error_message')).findAll(text=True)
    456             error_message = "\n" + '\n'.join(["  " + line.strip() for line in text_lines if line.strip()])
     568            text_lines = BeautifulSoup(
     569                    match.group('error_message')).findAll(text=True)
     570            error_message = "\n" + '\n'.join(
     571                    ["  " + line.strip()
     572                     for line in text_lines if line.strip()])
    457573        raise Exception("Bug not created: %s" % error_message)
    458574
    459     def create_bug(self, bug_title, bug_description, component=None, patch_file_object=None, patch_description=None, cc=None, mark_for_review=False, mark_for_commit_queue=False):
     575    def create_bug(self,
     576                   bug_title,
     577                   bug_description,
     578                   component=None,
     579                   patch_file_object=None,
     580                   patch_description=None,
     581                   cc=None,
     582                   mark_for_review=False,
     583                   mark_for_commit_queue=False):
    460584        self.authenticate()
    461585
     
    480604
    481605        if patch_file_object:
    482             self._fill_attachment_form(patch_description, patch_file_object, mark_for_review=mark_for_review, mark_for_commit_queue=mark_for_commit_queue)
     606            self._fill_attachment_form(
     607                    patch_description,
     608                    patch_file_object,
     609                    mark_for_review=mark_for_review,
     610                    mark_for_commit_queue=mark_for_commit_queue)
    483611
    484612        response = self.browser.submit()
     
    497625        raise Exception("Don't know how to find flag named \"%s\"" % flag_name)
    498626
    499     def clear_attachment_flags(self, attachment_id, additional_comment_text=None):
     627    def clear_attachment_flags(self,
     628                               attachment_id,
     629                               additional_comment_text=None):
    500630        self.authenticate()
    501631
     
    515645        self.browser.submit()
    516646
    517     # FIXME: We need a way to test this on a live bugzilla instance.
    518     def set_flag_on_attachment(self, attachment_id, flag_name, flag_value, comment_text, additional_comment_text):
     647    def set_flag_on_attachment(self,
     648                               attachment_id,
     649                               flag_name,
     650                               flag_value,
     651                               comment_text,
     652                               additional_comment_text):
     653        # FIXME: We need a way to test this function on a live bugzilla
     654        # instance.
     655
    519656        self.authenticate()
    520657
     
    532669        self.browser.submit()
    533670
    534     # FIXME: All of these bug editing methods have a ridiculous amount of copy/paste code.
    535     def obsolete_attachment(self, attachment_id, comment_text = None):
     671    # FIXME: All of these bug editing methods have a ridiculous amount of
     672    # copy/paste code.
     673
     674    def obsolete_attachment(self, attachment_id, comment_text=None):
    536675        self.authenticate()
    537676
     
    549688        if comment_text:
    550689            log(comment_text)
    551             # Bugzilla has two textareas named 'comment', one is somehow hidden.  We want the first.
     690            # Bugzilla has two textareas named 'comment', one is somehow
     691            # hidden.  We want the first.
    552692            self.browser.set_value(comment_text, name='comment', nr=0)
    553693        self.browser.submit()
     
    556696        self.authenticate()
    557697
    558         log("Adding %s to the CC list for bug %s" % (email_address_list, bug_id))
     698        log("Adding %s to the CC list for bug %s" % (email_address_list,
     699                                                     bug_id))
    559700        if self.dryrun:
    560701            return
     
    617758
    618759        log("Re-opening bug %s" % bug_id)
    619         log(comment_text) # Bugzilla requires a comment when re-opening a bug, so we know it will never be None.
     760        # Bugzilla requires a comment when re-opening a bug, so we know it will
     761        # never be None.
     762        log(comment_text)
    620763        if self.dryrun:
    621764            return
     
    624767        self.browser.select_form(name="changeform")
    625768        bug_status = self.browser.find_control("bug_status", type="select")
    626         # This is a hack around the fact that ClientForm.ListControl seems to have no simpler way to ask
    627         # if a control has an item named "REOPENED" without using exceptions for control flow.
     769        # This is a hack around the fact that ClientForm.ListControl seems to
     770        # have no simpler way to ask if a control has an item named "REOPENED"
     771        # without using exceptions for control flow.
    628772        possible_bug_statuses = map(lambda item: item.name, bug_status.items)
    629773        if "REOPENED" in possible_bug_statuses:
    630774            bug_status.value = ["REOPENED"]
    631775        else:
    632             log("Did not reopen bug %s.  It appears to already be open with status %s." % (bug_id, bug_status.value))
     776            log("Did not reopen bug %s.  " +
     777                "It appears to already be open with status %s." % (
     778                        bug_id, bug_status.value))
    633779        self.browser['comment'] = comment_text
    634780        self.browser.submit()
  • trunk/WebKitTools/Scripts/webkitpy/webkitport.py

    r53011 r53729  
    11# Copyright (C) 2009, Google Inc. All rights reserved.
    2 # 
     2#
    33# Redistribution and use in source and binary forms, with or without
    44# modification, are permitted provided that the following conditions are
    55# met:
    6 # 
     6#
    77#     * Redistributions of source code must retain the above copyright
    88# notice, this list of conditions and the following disclaimer.
     
    1414# contributors may be used to endorse or promote products derived from
    1515# this software without specific prior written permission.
    16 # 
     16#
    1717# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    1818# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     
    3636
    3737class WebKitPort(object):
     38
    3839    # We might need to pass scm into this function for scm.checkout_root
    3940    @classmethod
     
    5455    @classmethod
    5556    def name(cls):
    56         raise NotImplementedError, "subclasses must implement"
     57        raise NotImplementedError("subclasses must implement")
    5758
    5859    @classmethod
    5960    def flag(cls):
    60         raise NotImplementedError, "subclasses must implement"
     61        raise NotImplementedError("subclasses must implement")
    6162
    6263    @classmethod
     
    9192
    9293class MacPort(WebKitPort):
     94
    9395    @classmethod
    9496    def name(cls):
     
    101103
    102104class GtkPort(WebKitPort):
     105
    103106    @classmethod
    104107    def name(cls):
     
    124127
    125128class QtPort(WebKitPort):
     129
    126130    @classmethod
    127131    def name(cls):
     
    141145
    142146class ChromiumPort(WebKitPort):
     147
    143148    @classmethod
    144149    def name(cls):
Note: See TracChangeset for help on using the changeset viewer.