[SCM] WebKit Debian packaging branch, webkit-1.1, updated. upstream/1.1.19-706-ge5415e9

abarth at webkit.org abarth at webkit.org
Thu Feb 4 21:25:26 UTC 2010


The following commit has been merged in the webkit-1.1 branch:
commit da9058ab90c08f94abcb57233a139245269cea69
Author: abarth at webkit.org <abarth at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jan 22 23:58:03 2010 +0000

    2010-01-22  Adam Barth  <abarth at 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:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@53729 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 09dee59..17f1ff9 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,5 +1,21 @@
 2010-01-22  Adam Barth  <abarth at 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:
+
+2010-01-22  Adam Barth  <abarth at webkit.org>
+
         Reviewed by Darin Adler.
 
         Limit length of EWS results to 5MB
diff --git a/WebKitTools/Scripts/webkitpy/bugzilla.py b/WebKitTools/Scripts/webkitpy/bugzilla.py
index 35ecc25..280773f 100644
--- a/WebKitTools/Scripts/webkitpy/bugzilla.py
+++ b/WebKitTools/Scripts/webkitpy/bugzilla.py
@@ -1,10 +1,10 @@
 # Copyright (c) 2009, Google Inc. All rights reserved.
 # Copyright (c) 2009 Apple Inc. All rights reserved.
-# 
+#
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
 # met:
-# 
+#
 #     * Redistributions of source code must retain the above copyright
 # notice, this list of conditions and the following disclaimer.
 #     * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
 #     * Neither the name of Google Inc. nor the names of its
 # contributors may be used to endorse or promote products derived from
 # this software without specific prior written permission.
-# 
+#
 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -45,11 +45,14 @@ from .BeautifulSoup import BeautifulSoup, SoupStrainer
 
 from mechanize import Browser
 
+
 def parse_bug_id(message):
     match = re.search("http\://webkit\.org/b/(?P<bug_id>\d+)", message)
     if match:
         return int(match.group('bug_id'))
-    match = re.search(Bugzilla.bug_server_regex + "show_bug\.cgi\?id=(?P<bug_id>\d+)", message)
+    match = re.search(
+        Bugzilla.bug_server_regex + "show_bug\.cgi\?id=(?P<bug_id>\d+)",
+        message)
     if match:
         return int(match.group('bug_id'))
     return None
@@ -60,6 +63,7 @@ def timestamp():
 
 
 class Attachment(object):
+
     def __init__(self, attachment_dictionary, bug):
         self._attachment_dictionary = attachment_dictionary
         self._bug = bug
@@ -73,7 +77,8 @@ class Attachment(object):
         return int(self._attachment_dictionary.get("id"))
 
     def attacher_is_committer(self):
-        return self._bugzilla.committers.committer_by_email(patch.attacher_email())
+        return self._bugzilla.committers.committer_by_email(
+            patch.attacher_email())
 
     def attacher_email(self):
         return self._attachment_dictionary.get("attacher_email")
@@ -100,17 +105,22 @@ class Attachment(object):
         return self._attachment_dictionary.get("commit-queue")
 
     def url(self):
-        # FIXME: This should just return self._bugzilla().attachment_url_for_id(self.id()).  scm_unittest.py depends on the current behavior.
+        # FIXME: This should just return
+        # self._bugzilla().attachment_url_for_id(self.id()). scm_unittest.py
+        # depends on the current behavior.
         return self._attachment_dictionary.get("url")
 
     def _validate_flag_value(self, flag):
         email = self._attachment_dictionary.get("%s_email" % flag)
         if not email:
             return None
-        committer = getattr(self._bugzilla().committers, "%s_by_email" % flag)(email)
+        committer = getattr(self._bugzilla().committers,
+                            "%s_by_email" % flag)(email)
         if committer:
             return committer
-        log("Warning, attachment %s on bug %s has invalid %s (%s)" % (self._attachment_dictionary['id'], self._attachment_dictionary['bug_id'], flag, email))
+        log("Warning, attachment %s on bug %s has invalid %s (%s)" % (
+                 self._attachment_dictionary['id'],
+                 self._attachment_dictionary['bug_id'], flag, email))
 
     def reviewer(self):
         if not self._reviewer:
@@ -123,9 +133,11 @@ class Attachment(object):
         return self._committer
 
 
-# FIXME: This class is kinda a hack for now.  It exists so we have one place
-# to hold bug logic, even if much of the code deals with dictionaries still.
 class Bug(object):
+    # FIXME: This class is kinda a hack for now.  It exists so we have one
+    # place to hold bug logic, even if much of the code deals with
+    # dictionaries still.
+
     def __init__(self, bug_dictionary, bugzilla):
         self.bug_dictionary = bug_dictionary
         self._bugzilla = bugzilla
@@ -140,11 +152,13 @@ class Bug(object):
     def attachments(self, include_obsolete=False):
         attachments = self.bug_dictionary["attachments"]
         if not include_obsolete:
-            attachments = filter(lambda attachment: not attachment["is_obsolete"], attachments)
+            attachments = filter(lambda attachment:
+                                 not attachment["is_obsolete"], attachments)
         return [Attachment(attachment, self) for attachment in attachments]
 
     def patches(self, include_obsolete=False):
-        return [patch for patch in self.attachments(include_obsolete) if patch.is_patch()]
+        return [patch for patch in self.attachments(include_obsolete)
+                                   if patch.is_patch()]
 
     def unreviewed_patches(self):
         return [patch for patch in self.patches() if patch.review() == "?"]
@@ -153,23 +167,29 @@ class Bug(object):
         patches = [patch for patch in self.patches() if patch.review() == "+"]
         if include_invalid:
             return patches
-        # Checking reviewer() ensures that it was both reviewed and has a valid reviewer.
+        # Checking reviewer() ensures that it was both reviewed and has a valid
+        # reviewer.
         return filter(lambda patch: patch.reviewer(), patches)
 
     def commit_queued_patches(self, include_invalid=False):
-        patches = [patch for patch in self.patches() if patch.commit_queue() == "+"]
+        patches = [patch for patch in self.patches()
+                                      if patch.commit_queue() == "+"]
         if include_invalid:
             return patches
-        # Checking committer() ensures that it was both commit-queue+'d and has a valid committer.
+        # Checking committer() ensures that it was both commit-queue+'d and has
+        # a valid committer.
         return filter(lambda patch: patch.committer(), patches)
 
 
 # A container for all of the logic for making and parsing buzilla queries.
 class BugzillaQueries(object):
+
     def __init__(self, bugzilla):
         self._bugzilla = bugzilla
 
-    # Note: _load_query and _fetch_bug are the only two methods which access self._bugzilla.
+    # Note: _load_query and _fetch_bug are the only two methods which access
+    # self._bugzilla.
+
     def _load_query(self, query):
         self._bugzilla.authenticate()
 
@@ -179,17 +199,19 @@ class BugzillaQueries(object):
     def _fetch_bug(self, bug_id):
         return self._bugzilla.fetch_bug(bug_id)
 
-
     def _fetch_bug_ids_advanced_query(self, query):
         soup = BeautifulSoup(self._load_query(query))
-        # The contents of the <a> inside the cells in the first column happen to be the bug id.
-        return [int(bug_link_cell.find("a").string) for bug_link_cell in soup('td', "first-child")]
+        # The contents of the <a> inside the cells in the first column happen
+        # to be the bug id.
+        return [int(bug_link_cell.find("a").string)
+                for bug_link_cell in soup('td', "first-child")]
 
     def _parse_attachment_ids_request_query(self, page):
         digits = re.compile("\d+")
         attachment_href = re.compile("attachment.cgi\?id=\d+&action=review")
         attachment_links = SoupStrainer("a", href=attachment_href)
-        return [int(digits.search(tag["href"]).group(0)) for tag in BeautifulSoup(page, parseOnlyThese=attachment_links)]
+        return [int(digits.search(tag["href"]).group(0))
+                for tag in BeautifulSoup(page, parseOnlyThese=attachment_links)]
 
     def _fetch_attachment_ids_request_query(self, query):
         return self._parse_attachment_ids_request_query(self._load_query(query))
@@ -200,86 +222,126 @@ class BugzillaQueries(object):
         return self._fetch_bug_ids_advanced_query(needs_commit_query_url)
 
     def fetch_patches_from_pending_commit_list(self):
-        return sum([self._fetch_bug(bug_id).reviewed_patches() for bug_id in self.fetch_bug_ids_from_pending_commit_list()], [])
+        return sum([self._fetch_bug(bug_id).reviewed_patches()
+            for bug_id in self.fetch_bug_ids_from_pending_commit_list()], [])
 
     def fetch_bug_ids_from_commit_queue(self):
         commit_queue_url = "buglist.cgi?query_format=advanced&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&field0-0-0=flagtypes.name&type0-0-0=equals&value0-0-0=commit-queue%2B&order=Last+Changed"
         return self._fetch_bug_ids_advanced_query(commit_queue_url)
 
-    # This function will only return patches which have valid committers set.  It won't reject patches with invalid committers/reviewers.
     def fetch_patches_from_commit_queue(self):
-        return sum([self._fetch_bug(bug_id).commit_queued_patches() for bug_id in self.fetch_bug_ids_from_commit_queue()], [])
+        # This function will only return patches which have valid committers
+        # set.  It won't reject patches with invalid committers/reviewers.
+        return sum([self._fetch_bug(bug_id).commit_queued_patches()
+                    for bug_id in self.fetch_bug_ids_from_commit_queue()], [])
 
     def _fetch_bug_ids_from_review_queue(self):
         review_queue_url = "buglist.cgi?query_format=advanced&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&field0-0-0=flagtypes.name&type0-0-0=equals&value0-0-0=review?"
         return self._fetch_bug_ids_advanced_query(review_queue_url)
 
     def fetch_patches_from_review_queue(self, limit=None):
-        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.
+        # [:None] returns the whole array.
+        return sum([self._fetch_bug(bug_id).unreviewed_patches()
+            for bug_id in self._fetch_bug_ids_from_review_queue()[:limit]], [])
 
-    # FIXME: Why do we have both fetch_patches_from_review_queue and fetch_attachment_ids_from_review_queue??
+    # FIXME: Why do we have both fetch_patches_from_review_queue and
+    # fetch_attachment_ids_from_review_queue??
     # NOTE: This is also the only client of _fetch_attachment_ids_request_query
+
     def fetch_attachment_ids_from_review_queue(self):
         review_queue_url = "request.cgi?action=queue&type=review&group=type"
         return self._fetch_attachment_ids_request_query(review_queue_url)
 
 
 class CommitterValidator(object):
+
     def __init__(self, bugzilla):
         self._bugzilla = bugzilla
 
-    # _view_source_link belongs in some sort of webkit_config.py module.
-    def _view_source_link(self, local_path):
+    # _view_source_url belongs in some sort of webkit_config.py module.
+    def _view_source_url(self, local_path):
         return "http://trac.webkit.org/browser/trunk/%s" % local_path
 
     def _flag_permission_rejection_message(self, setter_email, flag_name):
-        committer_list = "WebKitTools/Scripts/webkitpy/committers.py" # This could be computed from CommitterList.__file__
-        contribution_guidlines_url = "http://webkit.org/coding/contributing.html" # Should come from some webkit_config.py
-        queue_administrator = "eseidel at chromium.org" # This could be queried from the status_server.
-        queue_name = "commit-queue" # This could be queried from the tool.
-        rejection_message = "%s does not have %s permissions according to %s." % (setter_email, flag_name, self._view_source_link(committer_list))
-        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)
-        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)
-        rejection_message += "  Due to bug 30084 the %s will require a restart after your change." % queue_name
-        rejection_message += "  Please contact %s to request a %s restart." % (queue_administrator, queue_name)
-        rejection_message += "  After restart the %s will correctly respect your %s rights." % (queue_name, flag_name)
-        return rejection_message
+        # This could be computed from CommitterList.__file__
+        committer_list = "WebKitTools/Scripts/webkitpy/committers.py"
+        # Should come from some webkit_config.py
+        contribution_guidlines = "http://webkit.org/coding/contributing.html"
+        # This could be queried from the status_server.
+        queue_administrator = "eseidel at chromium.org"
+        # This could be queried from the tool.
+        queue_name = "commit-queue"
+        message = "%s does not have %s permissions according to %s." % (
+                        setter_email,
+                        flag_name,
+                        self._view_source_url(committer_list))
+        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)
+        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)
+        message += "Due to bug 30084 the %s will require a restart after your change.  " % queue_name
+        message += "Please contact %s to request a %s restart.  " % (
+                        queue_administrator, queue_name)
+        message += "After restart the %s will correctly respect your %s rights." % (
+                        queue_name, flag_name)
+        return message
 
     def _validate_setter_email(self, patch, result_key, rejection_function):
         committer = getattr(patch, result_key)()
-        # If the flag is set, and we don't recognize the setter, reject the flag!
+        # If the flag is set, and we don't recognize the setter, reject the
+        # flag!
         setter_email = patch._attachment_dictionary.get("%s_email" % result_key)
         if setter_email and not committer:
-            rejection_function(patch.id(), self._flag_permission_rejection_message(setter_email, result_key))
+            rejection_function(patch.id(),
+                self._flag_permission_rejection_message(setter_email,
+                                                        result_key))
             return False
         return True
 
     def patches_after_rejecting_invalid_commiters_and_reviewers(self, patches):
         validated_patches = []
         for patch in patches:
-            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):
+            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)):
                 validated_patches.append(patch)
         return validated_patches
 
-    def reject_patch_from_commit_queue(self, attachment_id, additional_comment_text=None):
+    def reject_patch_from_commit_queue(self,
+                                       attachment_id,
+                                       additional_comment_text=None):
         comment_text = "Rejecting patch %s from commit-queue." % attachment_id
-        self._bugzilla.set_flag_on_attachment(attachment_id, 'commit-queue', '-', comment_text, additional_comment_text)
-
-    def reject_patch_from_review_queue(self, attachment_id, additional_comment_text=None):
+        self._bugzilla.set_flag_on_attachment(attachment_id,
+                                              "commit-queue",
+                                              "-",
+                                              comment_text,
+                                              additional_comment_text)
+
+    def reject_patch_from_review_queue(self,
+                                       attachment_id,
+                                       additional_comment_text=None):
         comment_text = "Rejecting patch %s from review queue." % attachment_id
-        self._bugzilla.set_flag_on_attachment(attachment_id, 'review', '-', comment_text, additional_comment_text)
+        self._bugzilla.set_flag_on_attachment(attachment_id,
+                                              'review',
+                                              '-',
+                                              comment_text,
+                                              additional_comment_text)
 
 
 class Bugzilla(object):
+
     def __init__(self, dryrun=False, committers=CommitterList()):
         self.dryrun = dryrun
         self.authenticated = False
         self.queries = BugzillaQueries(self)
         self.committers = committers
 
-        # FIXME: We should use some sort of Browser mock object when in dryrun mode (to prevent any mistakes).
+        # FIXME: We should use some sort of Browser mock object when in dryrun
+        # mode (to prevent any mistakes).
         self.browser = Browser()
-        # Ignore bugs.webkit.org/robots.txt until we fix it to allow this script
+        # Ignore bugs.webkit.org/robots.txt until we fix it to allow this
+        # script.
         self.browser.set_handle_robots(False)
 
     # FIXME: Much of this should go into some sort of config module:
@@ -290,7 +352,9 @@ class Bugzilla(object):
 
     def bug_url_for_bug_id(self, bug_id, xml=False):
         content_type = "&ctype=xml" if xml else ""
-        return "%sshow_bug.cgi?id=%s%s" % (self.bug_server_url, bug_id, content_type)
+        return "%sshow_bug.cgi?id=%s%s" % (self.bug_server_url,
+                                           bug_id,
+                                           content_type)
 
     def short_bug_url_for_bug_id(self, bug_id):
         return "http://webkit.org/b/%s" % bug_id
@@ -299,10 +363,16 @@ class Bugzilla(object):
         action_param = ""
         if action and action != "view":
             action_param = "&action=%s" % action
-        return "%sattachment.cgi?id=%s%s" % (self.bug_server_url, attachment_id, action_param)
-
-    def _parse_attachment_flag(self, element, flag_name, attachment, result_key):
-        flag = element.find('flag', attrs={'name' : flag_name})
+        return "%sattachment.cgi?id=%s%s" % (self.bug_server_url,
+                                             attachment_id,
+                                             action_param)
+
+    def _parse_attachment_flag(self,
+                               element,
+                               flag_name,
+                               attachment,
+                               result_key):
+        flag = element.find('flag', attrs={'name': flag_name})
         if flag:
             attachment[flag_name] = flag['status']
             if flag['status'] == '+':
@@ -319,8 +389,10 @@ class Bugzilla(object):
         attachment['name'] = unicode(element.find('desc').string)
         attachment['attacher_email'] = str(element.find('attacher').string)
         attachment['type'] = str(element.find('type').string)
-        self._parse_attachment_flag(element, 'review', attachment, 'reviewer_email')
-        self._parse_attachment_flag(element, 'commit-queue', attachment, 'committer_email')
+        self._parse_attachment_flag(
+                element, 'review', attachment, 'reviewer_email')
+        self._parse_attachment_flag(
+                element, 'commit-queue', attachment, 'committer_email')
         return attachment
 
     def _parse_bug_page(self, page):
@@ -330,11 +402,14 @@ class Bugzilla(object):
         bug["title"] = unicode(soup.find("short_desc").string)
         bug["reporter_email"] = str(soup.find("reporter").string)
         bug["assigned_to_email"] = str(soup.find("assigned_to").string)
-        bug["cc_emails"] = [str(element.string) for element in soup.findAll('cc')]
+        bug["cc_emails"] = [str(element.string)
+                            for element in soup.findAll('cc')]
         bug["attachments"] = [self._parse_attachment_element(element, bug["id"]) for element in soup.findAll('attachment')]
         return bug
 
-    # Makes testing fetch_*_from_bug() possible until we have a better BugzillaNetwork abstration.
+    # Makes testing fetch_*_from_bug() possible until we have a better
+    # BugzillaNetwork abstration.
+
     def _fetch_bug_page(self, bug_id):
         bug_url = self.bug_url_for_bug_id(bug_id, xml=True)
         log("Fetching: %s" % bug_url)
@@ -344,13 +419,17 @@ class Bugzilla(object):
         return self._parse_bug_page(self._fetch_bug_page(bug_id))
 
     # FIXME: A BugzillaCache object should provide all these fetch_ methods.
+
     def fetch_bug(self, bug_id):
         return Bug(self.fetch_bug_dictionary(bug_id), self)
 
     def _parse_bug_id_from_attachment_page(self, page):
-        up_link = BeautifulSoup(page).find('link', rel='Up') # The "Up" relation happens to point to the bug.
+        # The "Up" relation happens to point to the bug.
+        up_link = BeautifulSoup(page).find('link', rel='Up')
         if not up_link:
-            return None # This attachment does not exist (or you don't have permissions to view it).
+            # This attachment does not exist (or you don't have permissions to
+            # view it).
+            return None
         match = re.search("show_bug.cgi\?id=(?P<bug_id>\d+)", up_link['href'])
         return int(match.group('bug_id'))
 
@@ -362,14 +441,18 @@ class Bugzilla(object):
         page = self.browser.open(attachment_url)
         return self._parse_bug_id_from_attachment_page(page)
 
-    # FIXME: This should just return Attachment(id), which should be able to lazily fetch needed data.
+    # FIXME: This should just return Attachment(id), which should be able to
+    # lazily fetch needed data.
+
     def fetch_attachment(self, attachment_id):
-        # We could grab all the attachment details off of the attachment edit page
-        # but we already have working code to do so off of the bugs page, so re-use that.
+        # We could grab all the attachment details off of the attachment edit
+        # page but we already have working code to do so off of the bugs page,
+        # so re-use that.
         bug_id = self.bug_id_for_attachment_id(attachment_id)
         if not bug_id:
             return None
-        for attachment in self.fetch_bug(bug_id).attachments(include_obsolete=True):
+        attachments = self.fetch_bug(bug_id).attachments(include_obsolete=True)
+        for attachment in attachments:
             if attachment.id() == int(attachment_id):
                 return attachment
         return None # This should never be hit.
@@ -383,7 +466,8 @@ class Bugzilla(object):
             self.authenticated = True
             return
 
-        (username, password) = Credentials(self.bug_server_host, git_prefix="bugzilla").read_credentials()
+        (username, password) = Credentials(
+                self.bug_server_host, git_prefix="bugzilla").read_credentials()
 
         log("Logging in as %s..." % username)
         self.browser.open(self.bug_server_url + "index.cgi?GoAheadAndLogIn=1")
@@ -393,14 +477,21 @@ class Bugzilla(object):
         response = self.browser.submit()
 
         match = re.search("<title>(.+?)</title>", response.read())
-        # If the resulting page has a title, and it contains the word "invalid" assume it's the login failure page.
+        # If the resulting page has a title, and it contains the word "invalid"
+        # assume it's the login failure page.
         if match and re.search("Invalid", match.group(1), re.IGNORECASE):
             # FIXME: We could add the ability to try again on failure.
             raise Exception("Bugzilla login failed: %s" % match.group(1))
 
         self.authenticated = True
 
-    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):
+    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):
         self.browser['description'] = description
         self.browser['ispatch'] = ("1",)
         self.browser['flag_type-1'] = ('?',) if mark_for_review else ('X',)
@@ -416,20 +507,38 @@ class Bugzilla(object):
             patch_name = "bug-%s-%s.patch" % (bug_id, timestamp())
         else:
             patch_name ="%s.patch" % timestamp()
-        self.browser.add_file(patch_file_object, "text/plain", patch_name, 'data')
-
-    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):
+        self.browser.add_file(patch_file_object,
+                              "text/plain",
+                              patch_name,
+                              'data')
+
+    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):
         self.authenticate()
 
-        log('Adding patch "%s" to %sshow_bug.cgi?id=%s' % (description, self.bug_server_url, bug_id))
+        log('Adding patch "%s" to %sshow_bug.cgi?id=%s' % (description,
+                                                           self.bug_server_url,
+                                                           bug_id))
 
         if self.dryrun:
             log(comment_text)
             return
 
-        self.browser.open("%sattachment.cgi?action=enter&bugid=%s" % (self.bug_server_url, bug_id))
+        self.browser.open("%sattachment.cgi?action=enter&bugid=%s" % (
+                          self.bug_server_url, bug_id))
         self.browser.select_form(name="entryform")
-        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)
+        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)
         if comment_text:
             log(comment_text)
             self.browser['comment'] = comment_text
@@ -445,18 +554,33 @@ class Bugzilla(object):
         return components[result]
 
     def _check_create_bug_response(self, response_html):
-        match = re.search("<title>Bug (?P<bug_id>\d+) Submitted</title>", response_html)
+        match = re.search("<title>Bug (?P<bug_id>\d+) Submitted</title>",
+                          response_html)
         if match:
             return match.group('bug_id')
 
-        match = re.search('<div id="bugzilla-body">(?P<error_message>.+)<div id="footer">', response_html, re.DOTALL)
+        match = re.search(
+            '<div id="bugzilla-body">(?P<error_message>.+)<div id="footer">',
+            response_html,
+            re.DOTALL)
         error_message = "FAIL"
         if match:
-            text_lines = BeautifulSoup(match.group('error_message')).findAll(text=True)
-            error_message = "\n" + '\n'.join(["  " + line.strip() for line in text_lines if line.strip()])
+            text_lines = BeautifulSoup(
+                    match.group('error_message')).findAll(text=True)
+            error_message = "\n" + '\n'.join(
+                    ["  " + line.strip()
+                     for line in text_lines if line.strip()])
         raise Exception("Bug not created: %s" % error_message)
 
-    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):
+    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):
         self.authenticate()
 
         log('Creating bug with title "%s"' % bug_title)
@@ -479,7 +603,11 @@ class Bugzilla(object):
         self.browser['comment'] = bug_description
 
         if patch_file_object:
-            self._fill_attachment_form(patch_description, patch_file_object, mark_for_review=mark_for_review, mark_for_commit_queue=mark_for_commit_queue)
+            self._fill_attachment_form(
+                    patch_description,
+                    patch_file_object,
+                    mark_for_review=mark_for_review,
+                    mark_for_commit_queue=mark_for_commit_queue)
 
         response = self.browser.submit()
 
@@ -496,7 +624,9 @@ class Bugzilla(object):
             return self.browser.find_control(type='select', nr=1)
         raise Exception("Don't know how to find flag named \"%s\"" % flag_name)
 
-    def clear_attachment_flags(self, attachment_id, additional_comment_text=None):
+    def clear_attachment_flags(self,
+                               attachment_id,
+                               additional_comment_text=None):
         self.authenticate()
 
         comment_text = "Clearing flags on attachment: %s" % attachment_id
@@ -514,8 +644,15 @@ class Bugzilla(object):
         self._find_select_element_for_flag('commit-queue').value = ("X",)
         self.browser.submit()
 
-    # FIXME: We need a way to test this on a live bugzilla instance.
-    def set_flag_on_attachment(self, attachment_id, flag_name, flag_value, comment_text, additional_comment_text):
+    def set_flag_on_attachment(self,
+                               attachment_id,
+                               flag_name,
+                               flag_value,
+                               comment_text,
+                               additional_comment_text):
+        # FIXME: We need a way to test this function on a live bugzilla
+        # instance.
+
         self.authenticate()
 
         if additional_comment_text:
@@ -531,8 +668,10 @@ class Bugzilla(object):
         self._find_select_element_for_flag(flag_name).value = (flag_value,)
         self.browser.submit()
 
-    # FIXME: All of these bug editing methods have a ridiculous amount of copy/paste code.
-    def obsolete_attachment(self, attachment_id, comment_text = None):
+    # FIXME: All of these bug editing methods have a ridiculous amount of
+    # copy/paste code.
+
+    def obsolete_attachment(self, attachment_id, comment_text=None):
         self.authenticate()
 
         log("Obsoleting attachment: %s" % attachment_id)
@@ -548,14 +687,16 @@ class Bugzilla(object):
         self._find_select_element_for_flag('commit-queue').value = ("X",)
         if comment_text:
             log(comment_text)
-            # Bugzilla has two textareas named 'comment', one is somehow hidden.  We want the first.
+            # Bugzilla has two textareas named 'comment', one is somehow
+            # hidden.  We want the first.
             self.browser.set_value(comment_text, name='comment', nr=0)
         self.browser.submit()
 
     def add_cc_to_bug(self, bug_id, email_address_list):
         self.authenticate()
 
-        log("Adding %s to the CC list for bug %s" % (email_address_list, bug_id))
+        log("Adding %s to the CC list for bug %s" % (email_address_list,
+                                                     bug_id))
         if self.dryrun:
             return
 
@@ -616,19 +757,24 @@ class Bugzilla(object):
         self.authenticate()
 
         log("Re-opening bug %s" % bug_id)
-        log(comment_text) # Bugzilla requires a comment when re-opening a bug, so we know it will never be None.
+        # Bugzilla requires a comment when re-opening a bug, so we know it will
+        # never be None.
+        log(comment_text)
         if self.dryrun:
             return
 
         self.browser.open(self.bug_url_for_bug_id(bug_id))
         self.browser.select_form(name="changeform")
         bug_status = self.browser.find_control("bug_status", type="select")
-        # This is a hack around the fact that ClientForm.ListControl seems to have no simpler way to ask
-        # if a control has an item named "REOPENED" without using exceptions for control flow.
+        # This is a hack around the fact that ClientForm.ListControl seems to
+        # have no simpler way to ask if a control has an item named "REOPENED"
+        # without using exceptions for control flow.
         possible_bug_statuses = map(lambda item: item.name, bug_status.items)
         if "REOPENED" in possible_bug_statuses:
             bug_status.value = ["REOPENED"]
         else:
-            log("Did not reopen bug %s.  It appears to already be open with status %s." % (bug_id, bug_status.value))
+            log("Did not reopen bug %s.  " +
+                "It appears to already be open with status %s." % (
+                        bug_id, bug_status.value))
         self.browser['comment'] = comment_text
         self.browser.submit()
diff --git a/WebKitTools/Scripts/webkitpy/webkitport.py b/WebKitTools/Scripts/webkitpy/webkitport.py
index fcde460..cd60a54 100644
--- a/WebKitTools/Scripts/webkitpy/webkitport.py
+++ b/WebKitTools/Scripts/webkitpy/webkitport.py
@@ -1,9 +1,9 @@
 # Copyright (C) 2009, Google Inc. All rights reserved.
-# 
+#
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions are
 # met:
-# 
+#
 #     * Redistributions of source code must retain the above copyright
 # notice, this list of conditions and the following disclaimer.
 #     * Redistributions in binary form must reproduce the above
@@ -13,7 +13,7 @@
 #     * Neither the name of Google Inc. nor the names of its
 # contributors may be used to endorse or promote products derived from
 # this software without specific prior written permission.
-# 
+#
 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -35,6 +35,7 @@ from webkitpy.executive import Executive
 
 
 class WebKitPort(object):
+
     # We might need to pass scm into this function for scm.checkout_root
     @classmethod
     def script_path(cls, script_name):
@@ -53,11 +54,11 @@ class WebKitPort(object):
 
     @classmethod
     def name(cls):
-        raise NotImplementedError, "subclasses must implement"
+        raise NotImplementedError("subclasses must implement")
 
     @classmethod
     def flag(cls):
-        raise NotImplementedError, "subclasses must implement"
+        raise NotImplementedError("subclasses must implement")
 
     @classmethod
     def update_webkit_command(cls):
@@ -90,6 +91,7 @@ class WebKitPort(object):
 
 
 class MacPort(WebKitPort):
+
     @classmethod
     def name(cls):
         return "Mac"
@@ -100,6 +102,7 @@ class MacPort(WebKitPort):
 
 
 class GtkPort(WebKitPort):
+
     @classmethod
     def name(cls):
         return "Gtk"
@@ -123,6 +126,7 @@ class GtkPort(WebKitPort):
 
 
 class QtPort(WebKitPort):
+
     @classmethod
     def name(cls):
         return "Qt"
@@ -140,6 +144,7 @@ class QtPort(WebKitPort):
 
 
 class ChromiumPort(WebKitPort):
+
     @classmethod
     def name(cls):
         return "Chromium"

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list