[Reportbug-commits] [reportbug] 03/03: PEP8-fied the source code (except for "line too long", which we ignore)

Sandro Tosi morph at moszumanska.debian.org
Thu Sep 3 19:49:25 UTC 2015


This is an automated email from the git hooks/post-receive script.

morph pushed a commit to branch master
in repository reportbug.

commit b86543ed9cc74ccaca9ebdd87b870f4e3cc7af06
Author: Sandro Tosi <morph at debian.org>
Date:   Mon Aug 31 16:23:32 2015 +0100

    PEP8-fied the source code (except for "line too long", which we ignore)
---
 Makefile                   |    2 +-
 bin/querybts               |   73 +-
 bin/reportbug              |  458 +++++------
 debian/changelog           |    3 +-
 reportbug/__init__.py      |    4 +-
 reportbug/bugreport.py     |   37 +-
 reportbug/checkbuildd.py   |   36 +-
 reportbug/checkversions.py |   56 +-
 reportbug/debbugs.py       |  619 ++++++++-------
 reportbug/exceptions.py    |   39 +-
 reportbug/hiermatch.py     |   10 +-
 reportbug/submit.py        |   76 +-
 reportbug/tempfiles.py     |   31 +-
 reportbug/ui/__init__.py   |   33 +-
 reportbug/ui/gtk2_ui.py    | 1847 ++++++++++++++++++++++----------------------
 reportbug/ui/text_ui.py    |  425 +++++-----
 reportbug/ui/urwid_ui.py   |  206 ++---
 reportbug/urlutils.py      |   78 +-
 reportbug/utils.py         |  228 ++++--
 setup.py                   |    2 +-
 test/test_bugreport.py     |    6 +-
 test/test_checkbuildd.py   |    4 +-
 test/test_checkversions.py |   19 +-
 test/test_debbugs.py       |  157 ++--
 test/test_exception.py     |    1 +
 test/test_hiermatch.py     |    1 +
 test/test_tempfiles.py     |    5 +-
 test/test_ui.py            |    1 +
 test/test_ui_gtk2.py       |    6 +-
 test/test_urlutils.py      |    3 +-
 test/test_utils.py         |   88 +--
 31 files changed, 2384 insertions(+), 2170 deletions(-)

diff --git a/Makefile b/Makefile
index e8a4656..2501e79 100644
--- a/Makefile
+++ b/Makefile
@@ -23,7 +23,7 @@ coverhtml: coverage
 codechecks: pep8 pyflakes pylint
 
 pep8:
-	pep8 --verbose --repeat --show-source --filename=*.py,reportbug,querybts . --statistics
+	pep8 --verbose --repeat --show-source --filename=*.py,reportbug,querybts . --statistics --ignore=E501
 
 pyflakes:
 	pyflakes . bin/*
diff --git a/bin/querybts b/bin/querybts
index 5dbcb7a..8804354 100755
--- a/bin/querybts
+++ b/bin/querybts
@@ -7,19 +7,19 @@
 #
 # This program is freely distributable per the following license:
 #
-##  Permission to use, copy, modify, and distribute this software and its
-##  documentation for any purpose and without fee is hereby granted,
-##  provided that the above copyright notice appears in all copies and that
-##  both that copyright notice and this permission notice appear in
-##  supporting documentation.
-##
-##  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-##  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
-##  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
-##  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-##  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-##  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-##  SOFTWARE.
+#  Permission to use, copy, modify, and distribute this software and its
+#  documentation for any purpose and without fee is hereby granted,
+#  provided that the above copyright notice appears in all copies and that
+#  both that copyright notice and this permission notice appear in
+#  supporting documentation.
+#
+#  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
+#  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+#  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+#  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+#  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+#  SOFTWARE.
 
 import sys
 import os
@@ -30,27 +30,28 @@ from reportbug import utils
 from reportbug.exceptions import (
     UINotImportable,
     NoPackage, NoBugs, NoReport, NoNetwork,
-    )
+)
 from reportbug import debbugs
 from reportbug import urlutils
 
 from reportbug.ui import AVAILABLE_UIS
 
 import reportbug.ui.text_ui as ui
+
 ui_mode = 'text'
 
 from reportbug import VERSION_NUMBER
 
 VERSION = "querybts %s" % VERSION_NUMBER
 
-def main():
 
+def main():
     # default values for cli options
-    defaults = dict(system = 'debian', archived = False,
-                    http_proxy = '', interface = 'text',
-                    use_browser = False, source = False,
-                    mirrors = None, mbox = False,  buglist = False,
-                    mbox_reader_cmd = None)
+    defaults = dict(system='debian', archived=False,
+                    http_proxy='', interface='text',
+                    use_browser=False, source=False,
+                    mirrors=None, mbox=False, buglist=False,
+                    mbox_reader_cmd=None)
 
     # parse config file to update default options
     args = utils.parse_config_files()
@@ -75,7 +76,7 @@ def main():
                       help='Display a bugs list for the given package.')
     parser.add_option('-B', '--bts', dest='system',
                       help='Specify an alternate debbugs BTS; available values:  %s ' %
-                      ', '.join([k for k in debbugs.SYSTEMS if debbugs.SYSTEMS[k].get('btsroot')]))
+                           ', '.join([k for k in debbugs.SYSTEMS if debbugs.SYSTEMS[k].get('btsroot')]))
     parser.add_option('-m', '--mbox', action='store_true', dest='mbox',
                       help='generate mbox')
     parser.add_option('--proxy', '--http_proxy', dest='http_proxy',
@@ -93,7 +94,6 @@ def main():
     parser.add_option('--latest-first', action='store_true', dest='latest_first', default=False,
                       help='Order bugs to show the latest first')
 
-
     # parse cli options
     (options, args) = parser.parse_args()
 
@@ -118,12 +118,13 @@ def main():
             print
 
     # initialize the selected UI
-    ui.initialize ()
+    ui.initialize()
 
     # system must be one of those supported
     if options.system not in [k for k in debbugs.SYSTEMS if debbugs.SYSTEMS[k].get('btsroot')]:
         parser.error('Allowed arguments to --bts: \n' +
-                     '\n'.join(['  %s  (%s)' % (k, debbugs.SYSTEMS[k]['name']) for k in debbugs.SYSTEMS if debbugs.SYSTEMS[k].get('btsroot')]))
+                     '\n'.join(['  %s  (%s)' % (k, debbugs.SYSTEMS[k]['name'])
+                                for k in debbugs.SYSTEMS if debbugs.SYSTEMS[k].get('btsroot')]))
     else:
         # set the system info to those of the one selected
         sysinfo = debbugs.SYSTEMS[options.system]
@@ -159,10 +160,10 @@ def main():
             package = bugnum
             m = re.match('^#?(\d+)$', bugnum)
             if not m:
-                mboxbuglist = []
-                mboxbuglist = ui.handle_bts_query(package, options.system, options.timeout, options.mirrors, options.http_proxy,
-                                    queryonly=True, title=VERSION, archived=options.archived,
-                                    source=options.source, mbox=options.mbox, latest_first=options.latest_first)
+                mboxbuglist = ui.handle_bts_query(package, options.system, options.timeout, options.mirrors,
+                                                  options.http_proxy, queryonly=True, title=VERSION,
+                                                  archived=options.archived, source=options.source, mbox=options.mbox,
+                                                  latest_first=options.latest_first)
                 for num in mboxbuglist:
                     url = debbugs.get_report_url(options.system, num, options.archived, mbox=True)
                     try:
@@ -181,7 +182,6 @@ def main():
                     sys.exit(1)
         return
 
-
     reportre = re.compile(r'^#?(\d+)$')
     try:
         if len(args) > 1:
@@ -198,13 +198,13 @@ def main():
             match = reportre.match(package)
             if match:
                 report = int(match.group(1))
-                while 1 :
+                while 1:
                     retvalue = ui.show_report(report, options.system, options.mirrors,
-                                          options.http_proxy, options.timeout,
-                                          queryonly=True,
-                                          title=VERSION,
-                                          archived=options.archived,
-                                          mbox_reader_cmd=options.mbox_reader_cmd)
+                                              options.http_proxy, options.timeout,
+                                              queryonly=True,
+                                              title=VERSION,
+                                              archived=options.archived,
+                                              mbox_reader_cmd=options.mbox_reader_cmd)
                     ui.long_message('This option is not available while using querybts alone.\n')
                     x = ui.select_options('What do you want to do now?', 'Qb',
                                           {'q': 'Exit querybts.',
@@ -235,13 +235,14 @@ def main():
     except NoNetwork:
         ui.long_message('Cannot connect to network.\n')
 
+
 if __name__ == '__main__':
     try:
         main()
     except KeyboardInterrupt:
         print "querybts: exiting due to user interrupt."
     except debbugs.Error, x:
-        print 'error accessing BTS: '+str(x)
+        print 'error accessing BTS: ' + str(x)
     except SystemExit:
         pass
     except:
diff --git a/bin/reportbug b/bin/reportbug
index b787f98..4f81e81 100755
--- a/bin/reportbug
+++ b/bin/reportbug
@@ -7,19 +7,19 @@
 #
 # This program is freely distributable per the following license:
 #
-##  Permission to use, copy, modify, and distribute this software and its
-##  documentation for any purpose and without fee is hereby granted,
-##  provided that the above copyright notice appears in all copies and that
-##  both that copyright notice and this permission notice appear in
-##  supporting documentation.
-##
-##  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-##  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
-##  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
-##  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-##  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-##  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-##  SOFTWARE.
+#  Permission to use, copy, modify, and distribute this software and its
+#  documentation for any purpose and without fee is hereby granted,
+#  provided that the above copyright notice appears in all copies and that
+#  both that copyright notice and this permission notice appear in
+#  supporting documentation.
+#
+#  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
+#  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+#  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+#  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+#  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+#  SOFTWARE.
 
 DEFAULT_BTS = 'debian'
 
@@ -45,19 +45,19 @@ from reportbug import (
     VERSION_NUMBER,
     COPYRIGHT,
     LICENSE
-    )
+)
 from reportbug.utils import (
     MODE_EXPERT, MODE_ADVANCED, MODE_NOVICE, MODE_STANDARD,
-    )
+)
 from reportbug.tempfiles import (
     TempFile,
     tempfile_prefix,
     cleanup_temp_file,
-    )
+)
 from reportbug.exceptions import (
     UINotImportable, UINotImplemented,
     NoNetwork, NoPackage, NoBugs, NoReport, QuertBTSError,
-    )
+)
 from reportbug import submit
 from reportbug import checkversions
 from reportbug import debbugs
@@ -66,9 +66,9 @@ import reportbug.ui.text_ui as ui
 
 from reportbug.ui import (
     UIS, AVAILABLE_UIS, getUI
-    )
+)
 
-#ui = getUI('text')
+# ui = getUI('text')
 
 try:
     gettext.install('reportbug')
@@ -80,15 +80,18 @@ except IOError:
 MIN_USER_ID = 250
 quietly = False
 
+
 # Cheat for now.
 # ewrite() may put stuff on the status bar or in message boxes depending on UI
 def ewrite(*args):
     return quietly or ui.log_message(*args)
 
+
 def efail(*args):
     ui.display_failure(*args)
     sys.exit(1)
 
+
 # Lame message when we store a report as a temp file.
 def stopmsg(filename):
     ui.final_message(
@@ -102,12 +105,14 @@ def stopmsg(filename):
         'submit at bugs.debian.org, editing the subject and bug text as needed '
         '(but not altering the other information).\n', filename)
 
+
 def check_attachment_size(attachfile, maxsize):
     """Check if the attachment size is bigger than max allowed"""
     statinfo = os.stat(attachfile)
     attachsize = statinfo[6]
     return attachsize >= maxsize
 
+
 def include_file_in_report(message, message_filename,
                            attachment_filenames, package_name,
                            include_filename, charset, inline=False, draftpath=None):
@@ -138,8 +143,8 @@ def include_file_in_report(message, message_filename,
         try:
             fp = open(include_filename)
             message += '\n*** %s\n%s' % (
-                       include_filename.decode(charset, 'replace'),
-                       fp.read().decode(charset, 'replace'))
+                include_filename.decode(charset, 'replace'),
+                fp.read().decode(charset, 'replace'))
             fp.close()
             fp, temp_filename = TempFile(
                 prefix=tempfile_prefix(package_name), dir=draftpath)
@@ -155,8 +160,11 @@ def include_file_in_report(message, message_filename,
 
     return (message, message_filename, attachment_filenames)
 
+
 # Useful to retrieve CCs given in handle_editing
 CCS = []
+
+
 def handle_editing(filename, dmessage, options, sendto, attachments, package,
                    severity, mode, editor=None, charset='utf-8', tags=''):
     if not editor:
@@ -227,7 +235,7 @@ def handle_editing(filename, dmessage, options, sendto, attachments, package,
         x = ui.select_options(prompt, menuopts,
                               {'y': yesmessage,
                                'n': "Don't submit the bug report; instead, "
-                               "save it in a temporary file (exits reportbug).",
+                                    "save it in a temporary file (exits reportbug).",
                                'q': "Save it in a temporary file and quit.",
                                'a': "Attach a file.",
                                'd': "Detach an attachment file.",
@@ -282,7 +290,7 @@ def handle_editing(filename, dmessage, options, sendto, attachments, package,
                 myattachments = []
                 myattachments = [(x, '') for x in attachments]
                 filetodetach = ui.menu(detachprompt, myattachments,
-                    'Select the file:', default='', empty_ok=True)
+                                       'Select the file:', default='', empty_ok=True)
                 # only if selection is not empty and the file is in the attachment list
                 if filetodetach != '' and filetodetach in attachments:
                     attachments.remove(filetodetach)
@@ -308,10 +316,10 @@ def handle_editing(filename, dmessage, options, sendto, attachments, package,
                     if attachments:
                         # notify that they will be lost
                         if ui.yes_no(
-                            'Editing the report will lose all attachments: are you sure you want to continue?',
-                            'Yes, please',
-                            'No, thanks',
-                            True):
+                                'Editing the report will lose all attachments: are you sure you want to continue?',
+                                'Yes, please',
+                                'No, thanks',
+                                True):
                             # if ok, go into the MUA
                             options.mua = mailer
                             break
@@ -368,7 +376,7 @@ def handle_editing(filename, dmessage, options, sendto, attachments, package,
                 x = ui.select_options(
                     'Report is unchanged.  Edit this report or quit', 'Eqs',
                     {'q': "Don't submit the bug report; instead, save it "
-                     "in a temporary file and quit.",
+                          "in a temporary file and quit.",
                      'e': 'Re-edit the bug report.',
                      's': 'Send report anyway.'})
                 if x == 'q':
@@ -383,6 +391,7 @@ def handle_editing(filename, dmessage, options, sendto, attachments, package,
 
     return open(filename).read(), patch, justsave
 
+
 def find_package_for(filename, notatty=False, pathonly=False):
     ewrite("Finding package for '%s'...\n", filename)
     (newfilename, packages) = utils.find_package_for(filename, pathonly)
@@ -399,17 +408,17 @@ def find_package_for(filename, notatty=False, pathonly=False):
         if notatty:
             print "Please re-run reportbug selecting one of these packages:"
             for pkg, files in packlist:
-                print "  "+pkg
+                print "  " + pkg
             sys.exit(1)
 
         packs = []
         for pkg, files in packlist:
             if len(files) > 3:
                 files[3:] = ['...']
-            packs.append( (pkg, ', '.join(files) ) )
+            packs.append((pkg, ', '.join(files)))
 
         package = ui.menu("Multiple packages match: ", packs, 'Select one '
-                          'of these packages: ', any_ok=True)
+                                                              'of these packages: ', any_ok=True)
         # for urwid, when pressing 'Cancel' in the menu
         if package == -1:
             package = None
@@ -419,12 +428,14 @@ def find_package_for(filename, notatty=False, pathonly=False):
         ewrite("Using package '%s'.\n", package)
         return (filename, package)
 
+
 def validate_package_name(package):
     if not re.match(r'^[a-z0-9][a-z0-9\-\+\.]+$', package):
         ui.long_message("%s is not a valid package name.", package)
         package = None
     return package
 
+
 def get_other_package_name(others):
     """Displays the list of pseudo-packages and returns the one selected."""
 
@@ -437,15 +448,16 @@ def get_other_package_name(others):
     else:
         return None
 
+
 def get_package_name(bts='debian', mode=MODE_EXPERT):
     others = debbugs.SYSTEMS[bts].get('otherpkgs')
-    prompt = "Please enter the name of the package in which you have found "\
+    prompt = "Please enter the name of the package in which you have found " \
              "a problem"
     if others:
         prompt += ", or type 'other' to report a more general problem."
     else:
         prompt += '.'
-    prompt += " If you don't know what package the bug is in, "\
+    prompt += " If you don't know what package the bug is in, " \
               "please contact debian-user at lists.debian.org for assistance."
 
     options = []
@@ -485,40 +497,40 @@ def get_package_name(bts='debian', mode=MODE_EXPERT):
         if package in ('bugs.debian.org', 'debbugs'):
             if ui.yes_no('Are you reporting a problem with this program '
                          '(reportbug)', 'Yes, this is actually a bug in '
-                         'reportbug.', 'No, this is really a problem in the '
-                         'bug tracking system itself.'):
+                                        'reportbug.', 'No, this is really a problem in the '
+                                                      'bug tracking system itself.'):
                 package = 'reportbug'
 
         if package in ('general', 'project', 'debian-general'):
             ui.long_message(
                 "If you have a general problem, please do consider using "
-		'the available Debian support channels to narrow the problem '
-		'down. This will help us together to resolve the problem '
-		'quicker. See https://www.debian.org/support')
+                'the available Debian support channels to narrow the problem '
+                'down. This will help us together to resolve the problem '
+                'quicker. See https://www.debian.org/support')
             if not ui.yes_no(
-                "Are you sure this bug doesn't apply to a specific package?",
-                'Yes, this bug is truly general.',
-                'No, this is not really a general bug.', False):
+                    "Are you sure this bug doesn't apply to a specific package?",
+                    'Yes, this bug is truly general.',
+                    'No, this is not really a general bug.', False):
                 return get_package_name(bts, mode)
 
         if package == 'wnpp':
             if not ui.yes_no(
-                'Are you sure you want to file a WNPP report?',
-                'Yes, I am a developer or know what I\'m doing.',
-                'No, I am not a developer and I don\'t know what wnpp means.',
-                False):
+                    'Are you sure you want to file a WNPP report?',
+                    'Yes, I am a developer or know what I\'m doing.',
+                    'No, I am not a developer and I don\'t know what wnpp means.',
+                    False):
                 return get_package_name(bts, mode)
 
         if package in ('ftp.debian.org', 'release.debian.org'):
-            if not ui.yes_no(
-                'Are you sure you want to file a bug on %s?' % (package),
-                'Yes, I am a developer or know what I\'m doing.',
-                'No, I am not a developer and I don\'t know what %s is.' % (package),
-                False):
+            if not ui.yes_no('Are you sure you want to file a bug on %s?' % (package),
+                             'Yes, I am a developer or know what I\'m doing.',
+                             'No, I am not a developer and I don\'t know what %s is.' % (package),
+                             False):
                 return get_package_name(bts, mode)
 
     return package
 
+
 def special_prompts(package, bts, ui, fromaddr, timeout, online, http_proxy):
     prompts = debbugs.SYSTEMS[bts].get('specials')
     if prompts:
@@ -527,6 +539,7 @@ def special_prompts(package, bts, ui, fromaddr, timeout, online, http_proxy):
             return pkgprompts(package, bts, ui, fromaddr, timeout, online, http_proxy)
     return
 
+
 def offer_configuration(options):
     charset = locale.nl_langinfo(locale.CODESET)
     # It would be nice if there were some canonical character set conversion
@@ -588,7 +601,7 @@ def offer_configuration(options):
         realname = realname.replace('"', '\\"')
 
     is_addr_ok = False
-    while is_addr_ok != True:
+    while not is_addr_ok:
         from_addr = ui.get_string(
             'Which of your email addresses should be used when sending bug '
             'reports? (Note that this address will be visible in the bug tracking '
@@ -639,28 +652,28 @@ def offer_configuration(options):
             default=False)
 
     http_proxy = ui.get_string(
-       'Please enter the name of your proxy server.  It should only '
-       'use this parameter if you are behind a firewall. '
-       'The PROXY argument should be  formatted as a valid HTTP URL,'
-       ' including (if necessary) a port number;'
-       ' for example, http://192.168.1.1:3128/. '
-       'Just press ENTER if you don\'t have one or don\'t know.',
-       empty_ok=True, force_prompt=True)
-    
+        'Please enter the name of your proxy server.  It should only '
+        'use this parameter if you are behind a firewall. '
+        'The PROXY argument should be  formatted as a valid HTTP URL,'
+        ' including (if necessary) a port number;'
+        ' for example, http://192.168.1.1:3128/. '
+        'Just press ENTER if you don\'t have one or don\'t know.',
+        empty_ok=True, force_prompt=True)
+
     if os.path.exists(utils.USERFILE):
         try:
-            os.rename(utils.USERFILE, utils.USERFILE+'~')
+            os.rename(utils.USERFILE, utils.USERFILE + '~')
         except OSError:
             ui.display_failure('Unable to rename %s as %s~\n', utils.USERFILE,
                                utils.USERFILE)
 
     try:
-        fd = os.open(utils.USERFILE, os.O_WRONLY|os.O_TRUNC|os.O_CREAT,
+        fd = os.open(utils.USERFILE, os.O_WRONLY | os.O_TRUNC | os.O_CREAT,
                      0600)
     except OSError, x:
         efail('Unable to save %s; most likely, you do not have a '
-                        'home directory.  Please fix this before using '
-                        'reportbug again.\n', utils.USERFILE)
+              'home directory.  Please fix this before using '
+              'reportbug again.\n', utils.USERFILE)
 
     fp = os.fdopen(fd, 'w')
     print >> fp, '# reportbug preferences file'
@@ -686,12 +699,12 @@ def offer_configuration(options):
     if email_name != def_realname:
         print >> fp, rn % email_name.encode(charset, 'replace')
     else:
-        print >> fp, '# '+(rn % email_name.encode(charset, 'replace'))
+        print >> fp, '# ' + (rn % email_name.encode(charset, 'replace'))
 
     if email_addy != def_email:
         print >> fp, em % email_addy
     else:
-        print >> fp, '# '+(em % email_addy)
+        print >> fp, '# ' + (em % email_addy)
 
     uid = os.getuid()
     if uid < MIN_USER_ID:
@@ -737,6 +750,7 @@ def offer_configuration(options):
     ui.final_message('Default preferences file written.  To reconfigure, '
                      're-run reportbug with the "--configure" option.\n')
 
+
 def verify_option(option, opt, value, parser, *args):
     heading, valid = args
     if value == 'help':
@@ -747,13 +761,14 @@ def verify_option(option, opt, value, parser, *args):
     else:
         ewrite('Ignored bogus setting for %s: %s\n' % (opt, value))
 
+
 def verify_append_option(option, opt, value, parser, *args):
     heading, valid = args
     # special case --tag: in valid we pass a function reference
     # as get_tags is dependant on the user mode, so we also have to convert
     # the mode to the integer value expected... FIXME
     if opt == '--tag' or opt == '-T':
-        valid = sorted(valid(mode=utils.MODELIST.index(parser.values.mode)).keys())+['none']
+        valid = sorted(valid(mode=utils.MODELIST.index(parser.values.mode)).keys()) + ['none']
     if value == 'help':
         ewrite('%s:\n %s\n' % (heading, '\n '.join(valid)))
         sys.exit(1)
@@ -765,6 +780,7 @@ def verify_append_option(option, opt, value, parser, *args):
     else:
         ewrite('Ignored bogus setting for %s: %s\n' % (opt, value))
 
+
 def main():
     global quietly, ui
 
@@ -850,18 +866,18 @@ def main():
                       help='send the report using mh/nmh',
                       const=utils.MUA['mh'])
     parser.add_option('-N', '--bugnumber', action='store_true',
-                      dest='bugnumber',help='specify a bug number to look for')
+                      dest='bugnumber', help='specify a bug number to look for')
     parser.add_option('--mua', dest='mua',
                       help='send the report using the specified mail user agent')
     parser.add_option('--mta', dest='mta', help='send the report using the '
-                      'specified mail transport agent')
+                                                'specified mail transport agent')
     parser.add_option('--list-cc', action='append', dest='listcc',
                       help='send a copy to the specified address')
     parser.add_option('-p', '--print', action='store_true', dest='printonly',
                       help='output the report to standard output only')
     parser.add_option('--report-quiet', action='store_const', dest='sendto',
                       const='quiet', help='file report without any mail to '
-                      'the maintainer or tracking lists')
+                                          'the maintainer or tracking lists')
     parser.add_option('-q', '--quiet', action='store_true', dest='quietly',
                       help='reduce the verbosity of the output', default=False)
     parser.add_option('-s', '--subject', help='the subject for your report')
@@ -869,9 +885,9 @@ def main():
                       help='do not send a copy of the report to yourself')
     parser.add_option('-z', '--no-compress', dest='nocompress',
                       action='store_true', help='do not strip blank lines '
-                      'and comments from config files')
+                                                'and comments from config files')
     parser.add_option('-o', '--output', dest='outfile', help='output the report'
-                      ' to the specified file (both mail headers and body)')
+                                                             ' to the specified file (both mail headers and body)')
     parser.add_option('-O', '--offline', help='disable all external queries',
                       action='store_true')
     parser.add_option('-i', '--include', action='append',
@@ -879,16 +895,16 @@ def main():
     parser.add_option('-A', '--attach', action='append', dest='attachments',
                       help='attach the specified file to the report')
     parser.add_option('-b', '--no-query-bts', action='store_true',
-                      dest='dontquery',help='do not query the BTS for reports')
+                      dest='dontquery', help='do not query the BTS for reports')
     parser.add_option('--query-bts', action='store_false', dest='dontquery',
                       help='query the BTS for reports')
     parser.add_option('-T', '--tag', action='callback', dest='tags',
-                      callback=verify_append_option,  type='string',
+                      callback=verify_append_option, type='string',
                       callback_args=('Permitted tags',
                                      debbugs.get_tags),
                       help='add the specified tag to the report')
     parser.add_option('--http_proxy', '--proxy', help='use this proxy for '
-                      'HTTP accesses')
+                                                      'HTTP accesses')
     parser.add_option('--email', help='specify originating email address')
     parser.add_option('--realname', help='specify real name for your report')
     parser.add_option('--smtphost', help='specify SMTP server for mailing')
@@ -900,7 +916,7 @@ def main():
     parser.add_option('--smtpuser', help='username to use for SMTP')
     parser.add_option('--smtppasswd', help='password to use for SMTP')
     parser.add_option('--replyto', '--reply-to', help='specify Reply-To '
-                      'address for your report')
+                                                      'address for your report')
     parser.add_option('--query-source', action='store_true', dest='query_src',
                       help='query on source packages, not binary packages')
     parser.add_option('--no-query-source', action='store_false',
@@ -914,7 +930,7 @@ def main():
     parser.add_option('--no-debconf', action='store_false', dest='debconf',
                       help='exclude debconf settings from your report')
     parser.add_option('-j', '--justification', help='include justification '
-                      'for the severity of your report')
+                                                    'for the severity of your report')
     parser.add_option('-V', '--package-version', dest='pkgversion',
                       help='specify the version number for the package')
     parser.add_option('-u', '--interface', '--ui', action='callback',
@@ -946,19 +962,19 @@ def main():
                       help='check for new releases on various sites')
     parser.add_option('--no-check-available', action='store_false',
                       dest='check_available', help='do not check for new '
-                      'releases')
+                                                   'releases')
     parser.add_option('--mode', action='callback', help='choose the operating '
-                      'mode for reportbug', callback=verify_option,
+                                                        'mode for reportbug', callback=verify_option,
                       type='string', dest='mode',
                       callback_args=('Permitted operating modes',
                                      utils.MODES.keys()))
     parser.add_option('-v', '--verify', action='store_true', help='verify '
-                      'integrity of installed package using debsums')
+                                                                  'integrity of installed package using debsums')
     parser.add_option('--no-verify', action='store_false', dest='verify',
                       help='do not verify package installation')
     parser.add_option('-k', '--kudos', action='store_true', default=False,
                       help='send appreciative email to the maintainer, rather '
-                      'than filing a bug report')
+                           'than filing a bug report')
     parser.add_option('--body', dest="body", type="string",
                       help="specify the body for the report as a string")
     parser.add_option('--body-file', '--bodyfile', dest="bodyfile",
@@ -969,14 +985,14 @@ def main():
                       help='don\'t check whether the package is installed')
     parser.add_option('--check-installed', action='store_true',
                       dest='querydpkg', help='check whether the specified '
-                      'package is installed when filing a report (default)')
+                                             'package is installed when filing a report (default)')
     parser.add_option('--exit-prompt', action='store_true', dest='exitprompt',
                       help='prompt before exiting')
     parser.add_option('--paranoid', action='store_true', dest='paranoid',
                       help='show contents of message before sending')
     parser.add_option('--no-paranoid', action='store_false', dest='paranoid',
                       help='don\'t show contents of message before sending '
-                      '(default)')
+                           '(default)')
     parser.add_option('--no-bug-script', dest="bugscript", default=True,
                       action='store_false',
                       help='don\'t execute the bug script (if present)')
@@ -992,13 +1008,13 @@ def main():
                       help='don\'t show tags menu')
     parser.add_option('--mbox-reader-cmd', dest='mbox_reader_cmd',
                       help="Specify the program to open the reports mbox.")
-    parser.add_option('--max-attachment-size', type="int", dest='max_attachment_size', help="Specify the maximum size in byte for an attachment [default: 10485760].")
+    parser.add_option('--max-attachment-size', type="int", dest='max_attachment_size',
+                      help="Specify the maximum size in byte for an attachment [default: 10485760].")
     parser.add_option('--latest-first', action='store_true', dest='latest_first', default=False,
                       help='Order bugs to show the latest first')
     parser.add_option('--envelope-from', dest='envelopefrom',
                       help='Specify the Envelope From (Return-path) address used to send the bug report')
 
-
     (options, args) = parser.parse_args()
 
     # Load the interface, *before* the configuration step.
@@ -1030,7 +1046,7 @@ def main():
                 any_missing = True
             elif check_attachment_size(attachment, options.max_attachment_size):
                 print 'The attachment file %s size is bigger than the maximum of %d bytes: reduce ' \
-                'its size else the report cannot be sent' % (attachment, options.max_attachment_size)
+                      'its size else the report cannot be sent' % (attachment, options.max_attachment_size)
                 any_missing = True
         if any_missing:
             print "The above files can't be attached; exiting"
@@ -1073,7 +1089,7 @@ def main():
                             interface, msg)
             ewrite('\n')
 
-        if newui.initialize ():
+        if newui.initialize():
             ui = newui
             submit.ui = ui
         else:
@@ -1087,8 +1103,8 @@ def main():
         os.environ['INTERFACE'] = interface
 
     if not ui.can_input():
-        defaults.update({ 'dontquery' : True, 'notatty' : True,
-                          'printonly' : True })
+        defaults.update({'dontquery': True, 'notatty': True,
+                         'printonly': True})
 
     # force to report the bug against the source package if --from-buildd
     if options.buildd_format:
@@ -1099,6 +1115,7 @@ def main():
         return iface.user_interface()
     return ui.run_interface(iface.user_interface)
 
+
 class UI(object):
     def __init__(self, options, args):
         self.options = options
@@ -1158,7 +1175,8 @@ class UI(object):
             try:
                 if check_attachment_size(self.options.bodyfile, self.options.max_attachment_size):
                     print 'Body file %s size bigger than the maximum of %d bytes: ' \
-                    'reduce its size else the report cannot be sent'% (self.options.bodyfile, self.options.max_attachment_size)
+                          'reduce its size else the report cannot be sent' % (
+                              self.options.bodyfile, self.options.max_attachment_size)
                     raise Exception
                 body = open(self.options.bodyfile).read()
             except:
@@ -1203,7 +1221,9 @@ class UI(object):
             mua = smtphost = None
 
         if smtphost and smtphost.lower() in ('master.debian.org', 'bugs.debian.org'):
-            ui.long_message('*** Warning: %s is no longer an appropriate smtphost setting for reportbug: it has been superseded by reportbug.debian.org and this one is forced as smtphost; please update your .reportbugrc file.\n', smtphost.lower())
+            ui.long_message(
+                '*** Warning: %s is no longer an appropriate smtphost setting for reportbug: it has been superseded by reportbug.debian.org and this one is forced as smtphost; please update your .reportbugrc file.\n',
+                smtphost.lower())
             smtphost = 'reportbug.debian.org'
 
         if attachments and mua:
@@ -1240,7 +1260,7 @@ class UI(object):
                 if not uid:
                     message = "Running 'reportbug' as root is probably insecure!"
                 else:
-                    message = "Running 'reportbug' as an administrative user "\
+                    message = "Running 'reportbug' as an administrative user " \
                               "is probably not a good idea!"
                 message += '  Continue'
 
@@ -1324,8 +1344,7 @@ class UI(object):
         if baseedname == 'sensible-editor':
             edname = utils.realpath('/usr/bin/editor')
 
-        if not notatty and 'vi' in baseedname and mode < MODE_STANDARD and \
-               'EDITOR' not in os.environ:
+        if not notatty and 'vi' in baseedname and mode < MODE_STANDARD and 'EDITOR' not in os.environ:
             if not ui.yes_no('You appear to be using the "vi" editor, which is '
                              'not suited for new users.  You probably want to '
                              'change this setting by using "update-alternatives '
@@ -1344,8 +1363,8 @@ class UI(object):
                 if os.path.exists(f):
                     fp = open(f)
                     incfiles = u'%s\n*** %s\n%s' % (
-                               incfiles, f.decode('utf-8', 'replace'),
-                               fp.read().decode('utf-8', 'replace'))
+                        incfiles, f.decode('utf-8', 'replace'),
+                        fp.read().decode('utf-8', 'replace'))
                     fp.close()
                 else:
                     ewrite("Can't find %s to include!\n", f)
@@ -1375,10 +1394,10 @@ class UI(object):
                 if match:
                     report = int(match.group(1))
                     exinfo = ui.show_report(report, 'debian', self.options.mirrors,
-                                          self.options.http_proxy, self.options.timeout, queryonly=True,
-                                          title=VERSION,
-                                          archived=False,
-                                          mbox_reader_cmd=self.options.mbox_reader_cmd)
+                                            self.options.http_proxy, self.options.timeout, queryonly=True,
+                                            title=VERSION,
+                                            archived=False,
+                                            mbox_reader_cmd=self.options.mbox_reader_cmd)
                     # When asking to re-display the bugs list, None is returned
                     # given we're in the part of code that's executed when the
                     # user pass a bug number on the cli, so we'll exit
@@ -1394,8 +1413,8 @@ class UI(object):
             efail('Exiting.\n')
 
         if not pkgversion and self.options.querydpkg and \
-               sysinfo.get('query-dpkg', True) and \
-               package not in debbugs.SYSTEMS[bts].get('otherpkgs').keys():
+                sysinfo.get('query-dpkg', True) and \
+                package not in debbugs.SYSTEMS[bts].get('otherpkgs').keys():
             ewrite("Getting status for %s...\n", package)
             status = utils.get_package_status(package)
 
@@ -1413,7 +1432,7 @@ class UI(object):
                         if len(depends) == 1:
                             if mode < MODE_ADVANCED:
                                 ewrite('Dependency package "%s" corresponds to '
-                                   'actual package "%s".\n', package, depends[0])
+                                       'actual package "%s".\n', package, depends[0])
                                 package = depends[0]
                         else:
                             opts = [(x,
@@ -1421,7 +1440,7 @@ class UI(object):
                                       'not installed')) for x in depends]
                             if mode >= MODE_ADVANCED:
                                 opts += [(package,
-                                          status[11]+' (dependency package)')]
+                                          status[11] + ' (dependency package)')]
 
                             package = ui.menu('%s is a dependency package.  '
                                               'Which of the following '
@@ -1451,7 +1470,7 @@ class UI(object):
                     if len(packages) and not notatty:
                         packages.sort()
                         if src not in [x[0] for x in packages]:
-                            packages.append( (src, 'Source package') )
+                            packages.append((src, 'Source package'))
 
                         if len(packages) > 1:
                             package = ui.menu(
@@ -1477,12 +1496,11 @@ class UI(object):
                 packages = utils.packages_providing(package)
                 tmp = pack = None
                 if not packages:
-                    if ui.yes_no(
-                        'A package named "%s" does not appear to be installed; do '
-                        'you want to search for a similar-looking filename in '
-                        'an installed package' % package,
-                        'Look for a file with a similar filename.',
-                        'Continue filing with this package name.', True):
+                    if ui.yes_no('A package named "%s" does not appear to be installed; do '
+                                 'you want to search for a similar-looking filename in '
+                                 'an installed package' % package,
+                                 'Look for a file with a similar filename.',
+                                 'Continue filing with this package name.', True):
                         pkgavail = False
                     else:
                         pack = package
@@ -1496,13 +1514,12 @@ class UI(object):
                     (tmp, pack) = find_package_for(package, notatty)
                     if pack:
                         status = None
-                        if not ui.yes_no(
-                            "A package named '%s' does not appear to be installed "
-                            "on your system; however, '%s' contains a file named "
-                            "'%s'.  Do you want to file your report on the "
-                            "package reportbug found" % (package, pack, tmp),
-                            'Yes, use the package specified.',
-                            'No, give up the search.'):
+                        if not ui.yes_no("A package named '%s' does not appear to be installed "
+                                         "on your system; however, '%s' contains a file named "
+                                         "'%s'.  Do you want to file your report on the "
+                                         "package reportbug found" % (package, pack, tmp),
+                                         'Yes, use the package specified.',
+                                         'No, give up the search.'):
                             efail("Package not installed; stopping.\n")
 
                 if not status and pack:
@@ -1511,9 +1528,9 @@ class UI(object):
                     status = utils.get_package_status(package)
                 elif not packages:
                     if not ui.yes_no(
-                        'This package does not appear to be installed; continue '
-                        'with this report', 'Ignore this problem and continue.',
-                        'Exit without filing a report.', False):
+                            'This package does not appear to be installed; continue '
+                            'with this report', 'Ignore this problem and continue.',
+                            'Exit without filing a report.', False):
                         efail("Package not installed; stopping.\n")
                 elif (len(packages) > 1) or (packages[0][0] != package):
                     this_package = [(package, 'Uninstalled/non-existent package')]
@@ -1529,9 +1546,9 @@ class UI(object):
                         status = utils.get_package_status(package)
             elif not pkgavail and not notatty and not isvirtual and not issource:
                 if not ui.yes_no(
-                    'This package does not appear to exist; continue',
-                    'Ignore this problem and continue.',
-                    'Exit without filing a report.', False):
+                        'This package does not appear to exist; continue',
+                        'Ignore this problem and continue.',
+                        'Exit without filing a report.', False):
                     efail("Package does not exist; stopping.\n")
                     sys.exit(1)
 
@@ -1548,30 +1565,30 @@ class UI(object):
         if os.path.isfile(buginfo) and os.access(buginfo, os.X_OK):
             bugexec = buginfo
         elif os.path.isdir(buginfo):
-            if os.path.isfile(buginfo+'/script') and os.access(buginfo+'/script', os.X_OK):
-                bugexec = buginfo+'/script'
+            if os.path.isfile(buginfo + '/script') and os.access(buginfo + '/script', os.X_OK):
+                bugexec = buginfo + '/script'
 
-            if os.path.isfile(buginfo+'/presubj'):
-                presubj = buginfo+'/presubj'
+            if os.path.isfile(buginfo + '/presubj'):
+                presubj = buginfo + '/presubj'
 
-            if os.path.isfile(buginfo+'/control'):
+            if os.path.isfile(buginfo + '/control'):
                 submitas, submitto, reportwith, supplemental = \
-                          utils.parse_bug_control_file(buginfo+'/control')
-        elif os.path.isfile('/usr/share/bug/default/'+package) \
-             and os.access('/usr/share/bug/default/'+package, os.X_OK):
-            bugexec = '/usr/share/bug/default/'+package
-        elif os.path.isdir('/usr/share/bug/default/'+package):
-            buginfo = '/usr/share/bug/default/'+package
-            if os.path.isfile(buginfo+'/script') and os.access(buginfo+'/script',
-                                                               os.X_OK):
-                bugexec = buginfo+'/script'
-
-            if os.path.isfile(buginfo+'/presubj'):
-                presubj = buginfo+'/presubj'
-
-            if os.path.isfile(buginfo+'/control'):
+                    utils.parse_bug_control_file(buginfo + '/control')
+        elif os.path.isfile('/usr/share/bug/default/' + package) \
+                and os.access('/usr/share/bug/default/' + package, os.X_OK):
+            bugexec = '/usr/share/bug/default/' + package
+        elif os.path.isdir('/usr/share/bug/default/' + package):
+            buginfo = '/usr/share/bug/default/' + package
+            if os.path.isfile(buginfo + '/script') and os.access(buginfo + '/script',
+                                                                 os.X_OK):
+                bugexec = buginfo + '/script'
+
+            if os.path.isfile(buginfo + '/presubj'):
+                presubj = buginfo + '/presubj'
+
+            if os.path.isfile(buginfo + '/control'):
                 submitas, submitto, reportwith, supplemental = \
-                          utils.parse_bug_control_file(buginfo+'/control')
+                    utils.parse_bug_control_file(buginfo + '/control')
 
         if submitas and (submitas not in reportwith):
             reportwith += [submitas]
@@ -1581,21 +1598,20 @@ class UI(object):
             reportwith = [x for x in reportwith if x != package]
 
         if (pkgavail and self.options.verify and os.path.exists('/usr/bin/debsums')
-            and not self.options.kudos and state == 'installed'):
+                and not self.options.kudos and state == 'installed'):
             ewrite('Verifying package integrity...\n')
-            rc, output = commands.getstatusoutput('/usr/bin/debsums --ignore-permissions -s'+
+            rc, output = commands.getstatusoutput('/usr/bin/debsums --ignore-permissions -s' +
                                                   commands.mkarg(package))
             debsumsoutput = output
 
             if rc and not notatty:
-                if not ui.yes_no(
-                    'There may be a problem with your installation of '+package+
-                    ';\nthe following problems were detected by debsums:\n'+
-                    output+'\nDo you still want to file a report',
-                    'Ignore this problem and continue.  This may be '
-                    'appropriate if you have fixed the package manually already.  '
-                    'This problem may also result from the use of localepurge.',
-                    'Exit without filing a report.', False, nowrap=True):
+                if not ui.yes_no('There may be a problem with your installation of ' + package +
+                                 ';\nthe following problems were detected by debsums:\n' +
+                                 output + '\nDo you still want to file a report',
+                                 'Ignore this problem and continue.  This may be '
+                                 'appropriate if you have fixed the package manually already.  '
+                                 'This problem may also result from the use of localepurge.',
+                                 'Exit without filing a report.', False, nowrap=True):
                     efail("Package integrity check failed; stopping.\n")
 
         if not pkgversion or usedavail or (not pkgavail and
@@ -1610,8 +1626,8 @@ class UI(object):
             arch = utils.get_arch()
             check_more = (mode > MODE_STANDARD)
             if check_more:
-                ewrite('Checking for newer versions at madison,'+
-                  ' incoming.debian.org and http://ftp-master.debian.org/new.html\n')
+                ewrite('Checking for newer versions at madison,' +
+                       ' incoming.debian.org and http://ftp-master.debian.org/new.html\n')
             else:
                 ewrite('Checking for newer versions at madison...\n')
             (avail, toonew) = checkversions.check_available(
@@ -1619,14 +1635,13 @@ class UI(object):
                 check_incoming=check_more, check_newqueue=check_more,
                 http_proxy=self.options.http_proxy, arch=arch)
             if toonew:
-                if not ui.yes_no(
-                    '\nYour version of %s (%s) is newer than that in Debian!\n'
-                    'Do you still want to file a report' % (package, pkgversion),
-                    'Ignore this problem and continue.  This may be '
-                    'appropriate if you know this bug is present in older '
-                    'releases of the package, or you\'re running a mixed '
-                    'stable/testing installation.',
-                    'Exit without filing a report.', False):
+                if not ui.yes_no('\nYour version of %s (%s) is newer than that in Debian!\n'
+                                 'Do you still want to file a report' % (package, pkgversion),
+                                 'Ignore this problem and continue.  This may be '
+                                 'appropriate if you know this bug is present in older '
+                                 'releases of the package, or you\'re running a mixed '
+                                 'stable/testing installation.',
+                                 'Exit without filing a report.', False):
                     efail("Newer released version; stopping.\n")
 
             if avail:
@@ -1636,15 +1651,14 @@ class UI(object):
                 for rel in availlist:
                     availtext += '  %s: %s\n' % (rel, avail[rel])
 
-                if not ui.yes_no(
-                    ('\nYour version (%s) of %s appears to be out of date.\nThe '
-                    'following newer release(s) are available in the Debian '
-                    'archive:\n' % (pkgversion, package))+availtext+
-                    'Do you still want to file a report',
-                    'Ignore this problem and continue.  This may be '
-                    'appropriate if you know this bug is still present in more '
-                    'recent releases of the package.',
-                    'Exit without filing a report.', False, nowrap=True):
+                if not ui.yes_no(('\nYour version (%s) of %s appears to be out of date.\nThe '
+                                  'following newer release(s) are available in the Debian '
+                                  'archive:\n' % (pkgversion, package)) + availtext +
+                                 'Do you still want to file a report',
+                                 'Ignore this problem and continue.  This may be '
+                                 'appropriate if you know this bug is still present in more '
+                                 'recent releases of the package.',
+                                 'Exit without filing a report.', False, nowrap=True):
                     efail("Newer released version; stopping.\n")
 
         bts = DEFAULT_BTS
@@ -1691,7 +1705,7 @@ class UI(object):
             res = special_prompts(package, bts, ui, fromaddr,
                                   self.options.timeout,
                                   not self.options.offline and
-                                      (check_available or not dontquery),
+                                  (check_available or not dontquery),
                                   self.options.http_proxy)
             if res:
                 (subject, severity, h, ph, body, query) = res
@@ -1701,8 +1715,6 @@ class UI(object):
                     dontquery = True
                 special = True
 
-
-
         if not (dontquery or notatty or self.options.kudos):
             pkg, src = package, issource
             if self.options.query_src:
@@ -1716,8 +1728,7 @@ class UI(object):
                                              source=src,
                                              queryonly=self.options.queryonly,
                                              version=pkgversion,
-                                             mbox_reader_cmd=
-                                                 self.options.mbox_reader_cmd,
+                                             mbox_reader_cmd=self.options.mbox_reader_cmd,
                                              latest_first=self.options.latest_first)
             except UINotImplemented:
                 exinfo = None
@@ -1725,10 +1736,10 @@ class UI(object):
                 sys.exit(1)
             except NoPackage:
                 if not self.options.queryonly and maintainer and ui.yes_no(
-                    'There is no record of this package in the bug tracking '
-                    'system.\nSend report directly to maintainer',
-                    'Send the report to the maintainer (%s).' % maintainer,
-                    'Send the report to the BTS anyway.'):
+                        'There is no record of this package in the bug tracking '
+                        'system.\nSend report directly to maintainer',
+                        'Send the report to the maintainer (%s).' % maintainer,
+                        'Send the report to the BTS anyway.'):
                     rtype = 'debbugs'
                     sendto = maintainer
             except NoBugs:
@@ -1816,18 +1827,18 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
                 while 1:
                     x = ui.select_options(
                         "*** WARNING: The following configuration files have been "
-                        "modified:\n"+ "\n".join(changed)+
+                        "modified:\n" + "\n".join(changed) +
                         "\nSend modified configuration files", 'Ynd',
-                        {'y':'Send your modified configuration files.',
-                         'n':"Don't send modified configuration files.",
-                         'd':'Display modified configuration files.'})
+                        {'y': 'Send your modified configuration files.',
+                         'n': "Don't send modified configuration files.",
+                         'd': 'Display modified configuration files.'})
                     if x == 'n':
                         for f in changed:
                             confinfo[f] = 'changed [not included]'
                         break
                     elif x == 'd':
                         PAGER = os.environ.get('PAGER', '/usr/bin/sensible-pager')
-                        ui.system(PAGER+' '+' '.join(changed))
+                        ui.system(PAGER + ' ' + ' '.join(changed))
                     else:
                         break
 
@@ -1840,23 +1851,22 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
                 conftext = conftext + u'%s %s\n' % (f, confinfo[f])
 
         if (self.options.debconf and os.path.exists('/usr/bin/debconf-show') and
-            not self.options.kudos and installed):
+                not self.options.kudos and installed):
             showpkgs = package
             if reportwith:
                 showpkgs += ' ' + ' '.join(reportwith)
             (status, output) = commands.getstatusoutput(
                 'DEBCONF_SYSTEMRC=1 DEBCONF_NOWARNINGS=yes '
-                '/usr/bin/debconf-show %s' % showpkgs )
+                '/usr/bin/debconf-show %s' % showpkgs)
             if status:
                 conftext += '\n-- debconf-show failed\n'
             elif output:
                 output = output.decode('utf-8', 'replace')
                 outstr = output.encode(charset, 'replace')
-                if (notatty or ui.yes_no(
-                    "*** The following debconf settings were detected:\n"
-                    +outstr+"\nInclude these settings in your report",
-                    'Send your debconf settings.',
-                    "Don't send your debconf settings.", nowrap=True)):
+                if (notatty or ui.yes_no("*** The following debconf settings were detected:\n" +
+                                         outstr + "\nInclude these settings in your report",
+                                         'Send your debconf settings.',
+                                         "Don't send your debconf settings.", nowrap=True)):
                     conftext += u'\n-- debconf information:\n%s\n' % output
                 else:
                     conftext += u'\n-- debconf information excluded\n'
@@ -1866,7 +1876,7 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
         ewrite('\n')
         prompted = False
         if interactive and not (self.options.kudos or exinfo) and presubj:
-            ui.display_report(open(presubj).read()+'\n', presubj=True)
+            ui.display_report(open(presubj).read() + '\n', presubj=True)
 
         if self.options.kudos:
             subject = subject or ('Thanks for packaging %s!' % package)
@@ -1917,8 +1927,7 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
             if foundfile:
                 subject = foundfile + ": " + subject
                 ewrite("Rewriting subject to '%s'\n", subject)
-            elif (not re.match(r"\S+:\s", subject) and
-                  not subject.startswith(package)):
+            elif not re.match(r"\S+:\s", subject) and not subject.startswith(package):
                 subject = package + ": " + subject
                 ewrite("Rewriting subject to '%s'\n", subject)
 
@@ -1927,7 +1936,8 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
             listcc = []
 
         if not listcc and mode > MODE_STANDARD and rtype == 'debbugs' and not self.options.testmode and not self.options.template and self.options.ccmenu:
-            listcc += ui.get_multiline('Enter any additional addresses this report should be sent to; press ENTER after each address.')
+            listcc += ui.get_multiline(
+                'Enter any additional addresses this report should be sent to; press ENTER after each address.')
 
         if severity and rtype:
             severity = debbugs.convert_severity(severity, rtype)
@@ -1966,8 +1976,8 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
         if rtype == 'debbugs' and package != 'wnpp' and mode < MODE_EXPERT:
             if severity in ('critical', 'grave'):
                 justification = ui.menu(
-                    'You are reporting a ' +severity+' bug; which of the '
-                    'following criteria does it meet?',
+                    'You are reporting a ' + severity + ' bug; which of the '
+                                                        'following criteria does it meet?',
                     debbugs.JUSTIFICATIONS[severity],
                     'Please select the impact of the bug: ', default='unknown')
             elif severity == 'serious':
@@ -2008,19 +2018,19 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
                 if not notatty:
                     # special-case only if it was built in the past
                     if ui.yes_no(
-                        'Has this package successfully been built for this '
-                        'architecture in the past (you can look this up at '
-                        'buildd.debian.org)',
-                        'Yes, this is a recently-introduced problem.',
-                        'No, it has always been this way.'):
+                            'Has this package successfully been built for this '
+                            'architecture in the past (you can look this up at '
+                            'buildd.debian.org)',
+                            'Yes, this is a recently-introduced problem.',
+                            'No, it has always been this way.'):
                         justification += ' (but built successfully in the past)'
 
         HOMEDIR = os.environ.get('HOME', '/')
 
         if (rtype == 'debbugs' and not self.options.tags and
-            not (notatty or self.options.kudos or exinfo) and
-            package not in ('wnpp', 'ftp.debian.org', 'release.debian.org') and
-            mode > MODE_NOVICE and self.options.tagsmenu):
+                not (notatty or self.options.kudos or exinfo) and
+                package not in ('wnpp', 'ftp.debian.org', 'release.debian.org') and
+                mode > MODE_NOVICE and self.options.tagsmenu):
             tags = debbugs.get_tags(severity, mode)
 
             taglist = ui.select_multiple(
@@ -2033,7 +2043,7 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
         patch = ('patch' in taglist)
 
         if justification and 'security' not in taglist and 'security' in \
-               justification:
+                justification:
             ewrite('Adding security tag to this report.\n')
             taglist += ['security']
 
@@ -2044,9 +2054,9 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
 
         if 'security' in taglist:
             if self.options.secteam or (self.options.secteam is None and ui.yes_no(
-                'Are you reporting an undisclosed vulnerability? If so, in order to responsibly disclose the issue, it should not be sent to the public BTS right now, but instead to the private Security Team mailing list.',
-                'Yes, it is an undisclosed vulnerability, send this report to the private Security Team mailing list and not to the BTS.',
-                'No, it is already a publicly disclosed vulnerability, send this report to the BTS.', False)):
+                    'Are you reporting an undisclosed vulnerability? If so, in order to responsibly disclose the issue, it should not be sent to the public BTS right now, but instead to the private Security Team mailing list.',
+                    'Yes, it is an undisclosed vulnerability, send this report to the private Security Team mailing list and not to the BTS.',
+                    'No, it is already a publicly disclosed vulnerability, send this report to the BTS.', False)):
                 sendto = 'team at security.debian.org'
 
         # Execute bug script
@@ -2058,14 +2068,13 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
             # we get the return code of the script, headers and pseudo- set
             # by the script, and last the text output of the script
             (rc, bugscript_hdrs, bugscript_pseudo, text, bugscript_attachments) = \
-                 utils.exec_and_parse_bugscript(handler, bugexec)
+                utils.exec_and_parse_bugscript(handler, bugexec)
 
             if rc and not notatty:
-                if not ui.yes_no(
-                    'The package bug script %s exited with an error status (return '
-                    'code = %s). Do you still want to file a report?' % (bugexec,rc),
-                    'Ignore this problem and continue.',
-                    'Exit without filing a report.', False, nowrap=True):
+                if not ui.yes_no('The package bug script %s exited with an error status (return '
+                                 'code = %s). Do you still want to file a report?' % (bugexec, rc),
+                                 'Ignore this problem and continue.',
+                                 'Exit without filing a report.', False, nowrap=True):
                     efail("Package bug script failed; stopping.\n")
 
             # add bugscript headers only if present
@@ -2079,7 +2088,7 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
                 attachments += bugscript_attachments
             addinfo = None
             if not self.options.noconf:
-                addinfo = u"\n-- Package-specific info:\n"+text
+                addinfo = u"\n-- Package-specific info:\n" + text
 
             if addinfo and incfiles:
                 incfiles = addinfo + u"\n" + incfiles
@@ -2097,7 +2106,7 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
             if not mua:
                 SIGFILE = os.path.join(HOMEDIR, '.signature')
                 try:
-                    message = u"\n\n-- \n"+open(SIGFILE).read().decode('utf-8', 'replace')
+                    message = u"\n\n-- \n" + open(SIGFILE).read().decode('utf-8', 'replace')
                 except IOError:
                     pass
         else:
@@ -2123,7 +2132,7 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
                     else:
                         sendto = str(exinfo.bug_num)
 
-                sendto = sendto+'@'+submitto
+                sendto = sendto + '@' + submitto
         elif '@' not in sendto:
             if exinfo:
                 if sendto != 'submit':
@@ -2136,7 +2145,7 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
             except TypeError:
                 sendto = sysinfo['email']
 
-            sendto = rfc822.dump_address_pair((sysinfo['name']+
+            sendto = rfc822.dump_address_pair((sysinfo['name'] +
                                                ' Bug Tracking System', sendto))
 
         mailing = not (mua or self.options.printonly or self.options.template)
@@ -2185,7 +2194,7 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
         if CCS:
             listcc += CCS
         if listcc:
-            headers.append('X-Debbugs-CC: '+', '.join(listcc))
+            headers.append('X-Debbugs-CC: ' + ', '.join(listcc))
 
         # Pass both headers and pseudo-headers (passed on command-line, f.e.)
         body, headers, pseudoheaders = utils.cleanup_msg(message, headers, pseudos, rtype)
@@ -2199,11 +2208,11 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
                 body = oldbody
 
         if pseudoheaders:
-            body = '\n'.join(pseudoheaders)+'\n\n'+body
+            body = '\n'.join(pseudoheaders) + '\n\n' + body
 
         # Strip the body of useless whitespace at the end, then put a final
         # newline in the message.  See #234963.
-        body = body.rstrip('\n')+'\n'
+        body = body.rstrip('\n') + '\n'
 
         if justsave:
             fh, outputfile = TempFile(prefix=tfprefix,
@@ -2232,6 +2241,7 @@ For more details, please see: http://www.debian.org/devel/wnpp/''')
             ui.get_string('Please press ENTER to exit reportbug: ')
         return
 
+
 if __name__ == '__main__':
     try:
         main()
diff --git a/debian/changelog b/debian/changelog
index b85f935..4d9968d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -16,8 +16,9 @@ reportbug (6.6.5) UNRELEASED; urgency=medium
   * reportbug/utils.py
     - correctly identify conffiles marked as obsolete; thanks to Jakub Wilk for
       the report; Closes: #791577
+  * PEP8-fied the source code (except for "line too long", which we ignore)
 
- -- Sandro Tosi <morph at debian.org>  Sun, 30 Aug 2015 02:39:06 +0100
+ -- Sandro Tosi <morph at debian.org>  Mon, 31 Aug 2015 16:22:42 +0100
 
 reportbug (6.6.4) unstable; urgency=medium
 
diff --git a/reportbug/__init__.py b/reportbug/__init__.py
index 071c64d..b861532 100644
--- a/reportbug/__init__.py
+++ b/reportbug/__init__.py
@@ -7,7 +7,7 @@
 #
 # This program is freely distributable per the following license:
 #
-LICENSE="""\
+LICENSE = """\
 Permission to use, copy, modify, and distribute this software and its
 documentation for any purpose and without fee is hereby granted,
 provided that the above copyright notice appears in all copies and that
@@ -27,6 +27,6 @@ __all__ = ['bugreport', 'utils', 'urlutils', 'checkbuildd', 'checkversions',
 
 VERSION_NUMBER = "6.6.4"
 
-VERSION = "reportbug "+VERSION_NUMBER
+VERSION = "reportbug " + VERSION_NUMBER
 COPYRIGHT = VERSION + '\nCopyright (C) 1999-2008 Chris Lawrence <lawrencc at debian.org>' + \
                       '\nCopyright (C) 2008-2015 Sandro Tosi <morph at debian.org>'
diff --git a/reportbug/bugreport.py b/reportbug/bugreport.py
index 46e9dd2..556b3f8 100644
--- a/reportbug/bugreport.py
+++ b/reportbug/bugreport.py
@@ -6,19 +6,19 @@
 #
 # This program is freely distributable per the following license:
 #
-##  Permission to use, copy, modify, and distribute this software and its
-##  documentation for any purpose and without fee is hereby granted,
-##  provided that the above copyright notice appears in all copies and that
-##  both that copyright notice and this permission notice appear in
-##  supporting documentation.
-##
-##  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-##  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
-##  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
-##  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-##  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-##  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-##  SOFTWARE.
+#  Permission to use, copy, modify, and distribute this software and its
+#  documentation for any purpose and without fee is hereby granted,
+#  provided that the above copyright notice appears in all copies and that
+#  both that copyright notice and this permission notice appear in
+#  supporting documentation.
+#
+#  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
+#  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+#  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+#  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+#  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+#  SOFTWARE.
 
 import os
 
@@ -31,12 +31,13 @@ from exceptions import *
 # to print errors
 import ui.text_ui as ui
 
+
 class bugreport(object):
     "Encapsulates a bug report into a convenient object we can pass around."
 
     # Default character set for str(x)
     charset = 'utf-8'
-    
+
     def __init__(self, package, subject='', body='', system='debian',
                  incfiles='', sysinfo=True,
                  followup=False, type='debbugs', mode=utils.MODE_STANDARD,
@@ -101,7 +102,7 @@ class bugreport(object):
 
         ph = getattr(self, 'pseudoheaders', None)
         if ph:
-            headers = u'\n'.join(ph)+u'\n'
+            headers = u'\n'.join(ph) + u'\n'
         else:
             headers = u''
 
@@ -117,7 +118,7 @@ class bugreport(object):
         # thinking about those systems that don't have 'specials' dict
         if self.mode < utils.MODE_ADVANCED and self.package not in \
                 debbugs.SYSTEMS[self.system].get('specials', {}).keys():
-            body = utils.NEWBIELINE+u'\n\n'+body
+            body = utils.NEWBIELINE + u'\n\n' + body
         elif not body:
             body = u'\n'
 
@@ -134,7 +135,7 @@ class bugreport(object):
                 a = getattr(self, attr, None)
                 if a:
                     headers += u'%s: %s\n' % (name, a)
-            
+
             report = u"%s: %s\n%s\n" % (reportto, self.package, headers)
         else:
             report = "Followup-For: Bug #%d\n%s: %s\n%s\n" % (
@@ -197,7 +198,7 @@ class bugreport(object):
 
     def __str__(self):
         return unicode(self).encode(charset, 'replace')
-        
+
     def __repr__(self):
         params = ['%s=%s' % (k, self.k) for k in dir(self)]
         return 'bugreport(%s)' % ', '.join(params)
diff --git a/reportbug/checkbuildd.py b/reportbug/checkbuildd.py
index c0be95d..19c944d 100644
--- a/reportbug/checkbuildd.py
+++ b/reportbug/checkbuildd.py
@@ -7,19 +7,19 @@
 #
 # This program is freely distributable per the following license:
 #
-##  Permission to use, copy, modify, and distribute this software and its
-##  documentation for any purpose and without fee is hereby granted,
-##  provided that the above copyright notice appears in all copies and that
-##  both that copyright notice and this permission notice appear in
-##  supporting documentation.
-##
-##  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-##  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
-##  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
-##  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-##  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-##  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-##  SOFTWARE.
+#  Permission to use, copy, modify, and distribute this software and its
+#  documentation for any purpose and without fee is hereby granted,
+#  provided that the above copyright notice appears in all copies and that
+#  both that copyright notice and this permission notice appear in
+#  supporting documentation.
+#
+#  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
+#  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+#  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+#  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+#  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+#  SOFTWARE.
 
 import sgmllib
 import commands
@@ -28,12 +28,12 @@ import utils
 from urlutils import open_url
 from reportbug.exceptions import (
     NoNetwork,
-    )
+)
 
 BUILDD_URL = 'https://buildd.debian.org/build.php?arch=%s&pkg=%s'
 
-# Check for successful in a 'td' block
 
+# Check for successful in a 'td' block
 class BuilddParser(sgmllib.SGMLParser):
     def __init__(self):
         sgmllib.SGMLParser.__init__(self)
@@ -55,7 +55,8 @@ class BuilddParser(sgmllib.SGMLParser):
     def save_end(self, mode=0):
         data = self.savedata
         self.savedata = None
-        if not mode and data is not None: data = ' '.join(data.split())
+        if not mode and data is not None:
+            data = ' '.join(data.split())
         return data
 
     def start_td(self, attrs):
@@ -64,7 +65,8 @@ class BuilddParser(sgmllib.SGMLParser):
     def end_td(self):
         data = self.save_end()
         if data and 'successful' in data.lower():
-            self.found_succeeded=True
+            self.found_succeeded = True
+
 
 def check_built(src_package, timeout, arch=None, http_proxy=None):
     """Return True if built in the past, False otherwise (even error)"""
diff --git a/reportbug/checkversions.py b/reportbug/checkversions.py
index 72b1619..bb7a3fd 100644
--- a/reportbug/checkversions.py
+++ b/reportbug/checkversions.py
@@ -7,19 +7,19 @@
 #
 # This program is freely distributable per the following license:
 #
-##  Permission to use, copy, modify, and distribute this software and its
-##  documentation for any purpose and without fee is hereby granted,
-##  provided that the above copyright notice appears in all copies and that
-##  both that copyright notice and this permission notice appear in
-##  supporting documentation.
-##
-##  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-##  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
-##  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
-##  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-##  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-##  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-##  SOFTWARE.
+#  Permission to use, copy, modify, and distribute this software and its
+#  documentation for any purpose and without fee is hereby granted,
+#  provided that the above copyright notice appears in all copies and that
+#  both that copyright notice and this permission notice appear in
+#  supporting documentation.
+#
+#  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
+#  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+#  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+#  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+#  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+#  SOFTWARE.
 
 import sys
 import os
@@ -33,7 +33,7 @@ import utils
 from urlutils import open_url
 from reportbug.exceptions import (
     NoNetwork,
-    )
+)
 
 # needed to parse new.822
 from debian.deb822 import Deb822
@@ -43,6 +43,7 @@ RMADISON_URL = 'http://qa.debian.org/madison.php?package=%s&text=on'
 INCOMING_URL = 'http://incoming.debian.org/'
 NEWQUEUE_URL = 'http://ftp-master.debian.org/new.822'
 
+
 # The format is an unordered list
 
 class BaseParser(sgmllib.SGMLParser):
@@ -64,16 +65,18 @@ class BaseParser(sgmllib.SGMLParser):
     def save_end(self, mode=0):
         data = self.savedata
         self.savedata = None
-        if not mode and data is not None: data = ' '.join(data.split())
+        if not mode and data is not None:
+            data = ' '.join(data.split())
         return data
 
+
 class IncomingParser(sgmllib.SGMLParser):
     def __init__(self, package, arch='i386'):
         sgmllib.SGMLParser.__init__(self)
         self.found = []
         self.savedata = None
-        arch = r'(?:all|'+re.escape(arch)+')'
-        self.package = re.compile(re.escape(package)+r'_([^_]+)_'+arch+'.deb')
+        arch = r'(?:all|' + re.escape(arch) + ')'
+        self.package = re.compile(re.escape(package) + r'_([^_]+)_' + arch + '.deb')
 
     def start_a(self, attrs):
         for attrib, value in attrs:
@@ -84,17 +87,21 @@ class IncomingParser(sgmllib.SGMLParser):
             if mob:
                 self.found.append(mob.group(1))
 
+
 def compare_versions(current, upstream):
     """Return 1 if upstream is newer than current, -1 if current is
     newer than upstream, and 0 if the same."""
-    if not current or not upstream: return 0
+    if not current or not upstream:
+        return 0
     return debian_support.version_compare(upstream, current)
 
+
 def later_version(a, b):
     if compare_versions(a, b) > 0:
         return b
     return a
 
+
 def get_versions_available(package, timeout, dists=None, http_proxy=None, arch='i386'):
     if not dists:
         dists = ('oldstable', 'stable', 'testing', 'unstable', 'experimental')
@@ -132,9 +139,10 @@ def get_versions_available(package, timeout, dists=None, http_proxy=None, arch='
 
     return versions
 
+
 def get_newqueue_available(package, timeout, dists=None, http_proxy=None, arch='i386'):
     if dists is None:
-        dists = ('unstable (new queue)', )
+        dists = ('unstable (new queue)',)
     try:
         page = open_url(NEWQUEUE_URL, http_proxy, timeout)
     except NoNetwork:
@@ -150,12 +158,13 @@ def get_newqueue_available(package, timeout, dists=None, http_proxy=None, arch='
     # iter over the entries, one paragraph at a time
     for para in Deb822.iter_paragraphs(page):
         if para['Source'] == package:
-            k = para['Distribution'] + ' (' + para['Queue']  + ')'
+            k = para['Distribution'] + ' (' + para['Queue'] + ')'
             # in case of multiple versions, choose the bigger
             versions[k] = max(para['Version'].split())
 
     return versions
 
+
 def get_incoming_version(package, timeout, http_proxy=None, arch='i386'):
     try:
         page = open_url(INCOMING_URL, http_proxy, timeout)
@@ -186,6 +195,7 @@ def get_incoming_version(package, timeout, http_proxy=None, arch='i386'):
     del parser
     return None
 
+
 def check_available(package, version, timeout, dists=None,
                     check_incoming=True, check_newqueue=True,
                     http_proxy=None, arch='i386'):
@@ -199,11 +209,11 @@ def check_available(package, version, timeout, dists=None,
     avail.update(stuff)
     if check_newqueue:
         srcpackage = utils.get_source_name(package)
-	if srcpackage is None:
-	    srcpackage = package
+        if srcpackage is None:
+            srcpackage = package
         stuff = get_newqueue_available(srcpackage, timeout, dists, http_proxy, arch)
         avail.update(stuff)
-        #print gc.garbage, stuff
+        # print gc.garbage, stuff
 
     new = {}
     newer = 0
diff --git a/reportbug/debbugs.py b/reportbug/debbugs.py
index 3efab9e..ebde5c4 100644
--- a/reportbug/debbugs.py
+++ b/reportbug/debbugs.py
@@ -7,19 +7,19 @@
 #
 # This program is freely distributable per the following license:
 #
-##  Permission to use, copy, modify, and distribute this software and its
-##  documentation for any purpose and without fee is hereby granted,
-##  provided that the above copyright notice appears in all copies and that
-##  both that copyright notice and this permission notice appear in
-##  supporting documentation.
-##
-##  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-##  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
-##  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
-##  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-##  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-##  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-##  SOFTWARE.
+#  Permission to use, copy, modify, and distribute this software and its
+#  documentation for any purpose and without fee is hereby granted,
+#  provided that the above copyright notice appears in all copies and that
+#  both that copyright notice and this permission notice appear in
+#  supporting documentation.
+#
+#  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
+#  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+#  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+#  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+#  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+#  SOFTWARE.
 
 import utils
 import sys
@@ -44,9 +44,10 @@ import checkversions
 from exceptions import (
     NoNetwork,
     QuertBTSError,
-    )
+)
 from urlutils import open_url
 
+
 def msgfactory(fp):
     try:
         return email.message_from_file(fp)
@@ -55,18 +56,20 @@ def msgfactory(fp):
         # stop the mailbox iterator
         return ''
 
+
 class Error(Exception):
     pass
 
+
 # Severity levels
 SEVERITIES = {
-    'critical' : """makes unrelated software on the system (or the
+    'critical': """makes unrelated software on the system (or the
     whole system) break, or causes serious data loss, or introduces a
     security hole on systems where you install the package.""",
-    'grave' : """makes the package in question unusable by most or all users,
+    'grave': """makes the package in question unusable by most or all users,
     or causes data loss, or introduces a security hole allowing access
     to the accounts of users who use the package.""",
-    'serious' : """is a severe violation of Debian policy (that is,
+    'serious': """is a severe violation of Debian policy (that is,
     the problem is a violation of a 'must' or 'required' directive);
     may or may not affect the usability of the package.  Note that non-severe
     policy violations may be 'normal,' 'minor,' or 'wishlist' bugs.
@@ -74,127 +77,130 @@ SEVERITIES = {
     release-critical; however, end users should not do so.). For the canonical
     list of issues worthing a serious severity you can refer to this webpage:
     http://release.debian.org/testing/rc_policy.txt .""",
-    'important' : """a bug which has a major effect on the usability
+    'important': """a bug which has a major effect on the usability
     of a package, without rendering it completely unusable to
     everyone.""",
-    'does-not-build' : """a bug that stops the package from being built
+    'does-not-build': """a bug that stops the package from being built
     from source.  (This is a 'virtual severity'.)""",
-    'normal' : """a bug that does not undermine the usability of the
+    'normal': """a bug that does not undermine the usability of the
     whole package; for example, a problem with a particular option or
     menu item.""",
-    'minor' : """things like spelling mistakes and other minor
+    'minor': """things like spelling mistakes and other minor
     cosmetic errors that do not affect the core functionality of the
     package.""",
-    'wishlist' : "suggestions and requests for new features.",
-    }
+    'wishlist': "suggestions and requests for new features.",
+}
 
 # justifications for critical bugs
 JUSTIFICATIONS = {
-    'critical' : (
-    ('breaks unrelated software', """breaks unrelated software on the system
+    'critical': (
+        ('breaks unrelated software', """breaks unrelated software on the system
     (packages that have a dependency relationship are not unrelated)"""),
-    ('breaks the whole system', """renders the entire system unusable (e.g.,
+        ('breaks the whole system', """renders the entire system unusable (e.g.,
     unbootable, unable to reach a multiuser runlevel, etc.)"""),
-    ('causes serious data loss', """causes loss of important, irreplaceable
+        ('causes serious data loss', """causes loss of important, irreplaceable
     data"""),
-    ('root security hole', """introduces a security hole allowing access to
+        ('root security hole', """introduces a security hole allowing access to
     root (or another privileged system account), or data normally
     accessible only by such accounts"""),
-    ('unknown', """not sure, or none of the above"""),
+        ('unknown', """not sure, or none of the above"""),
     ),
-    'grave' : (
-    ('renders package unusable', """renders the package unusable, or mostly
+    'grave': (
+        ('renders package unusable', """renders the package unusable, or mostly
     so, on all or nearly all possible systems on which it could be installed
     (i.e., not a hardware-specific bug); or renders package uninstallable
     or unremovable without special effort"""),
-    ('causes non-serious data loss', """causes the loss of data on the system
+        ('causes non-serious data loss', """causes the loss of data on the system
     that is unimportant, or restorable without resorting to backup media"""),
-    ('user security hole', """introduces a security hole allowing access to
+        ('user security hole', """introduces a security hole allowing access to
     user accounts or data not normally accessible"""),
-    ('unknown', """not sure, or none of the above"""),
+        ('unknown', """not sure, or none of the above"""),
     )
-    }
+}
 
 
 # Ordering for justifications
 JUSTORDER = {
-    'critical' :  ['breaks unrelated software',
-                   'breaks the whole system',
-                   'causes serious data loss',
-                   'root security hole',
-                   'unknown'],
-    'grave' : ['renders package unusable',
-               'causes non-serious data loss',
-               'user security hole',
-               'unknown']
-    }
+    'critical': ['breaks unrelated software',
+                 'breaks the whole system',
+                 'causes serious data loss',
+                 'root security hole',
+                 'unknown'],
+    'grave': ['renders package unusable',
+              'causes non-serious data loss',
+              'user security hole',
+              'unknown']
+}
 
 SEVERITIES_gnats = {
-    'critical' : 'The product, component or concept is completely'
-    'non-operational or some essential functionality is missing.  No'
-    'workaround is known.',
-    'serious' : 'The product, component or concept is not working'
-    'properly or significant functionality is missing.  Problems that'
-    'would otherwise be considered ''critical'' are rated ''serious'' when'
-    'a workaround is known.',
-    'non-critical' : 'The product, component or concept is working'
-    'in general, but lacks features, has irritating behavior, does'
-    'something wrong, or doesn''t match its documentation.',
-    }
+    'critical': 'The product, component or concept is completely'
+                'non-operational or some essential functionality is missing.  No'
+                'workaround is known.',
+    'serious': 'The product, component or concept is not working'
+               'properly or significant functionality is missing.  Problems that'
+               'would otherwise be considered ''critical'' are rated ''serious'' when'
+               'a workaround is known.',
+    'non-critical': 'The product, component or concept is working'
+                    'in general, but lacks features, has irritating behavior, does'
+                    'something wrong, or doesn''t match its documentation.',
+}
 
 # Rank order of severities, for sorting
 SEVLIST = ['critical', 'grave', 'serious', 'important', 'does-not-build',
            'normal', 'non-critical', 'minor', 'wishlist', 'fixed']
 
+
 def convert_severity(severity, type='debbugs'):
     "Convert severity names if needed."
     if type == 'debbugs':
-        return {'non-critical' : 'normal'}.get(severity, severity)
+        return {'non-critical': 'normal'}.get(severity, severity)
     elif type == 'gnats':
-        return {'grave' : 'critical',
-                'important' : 'serious',
-                'normal' : 'non-critical',
-                'minor' : 'non-critical',
-                'wishlist' : 'non-critical'}.get(severity, severity)
+        return {'grave': 'critical',
+                'important': 'serious',
+                'normal': 'non-critical',
+                'minor': 'non-critical',
+                'wishlist': 'non-critical'}.get(severity, severity)
     else:
         return severity
 
+
 # These packages are virtual in Debian; we don't look them up...
 debother = {
-    'bugs.debian.org' : 'The bug tracking system, @bugs.debian.org',
-    'buildd.debian.org' :  'Problems and requests related to the Debian Buildds',
-    'buildd.emdebian.org' :  'Problems related to building packages for Emdebian',
-    'cdimage.debian.org' : 'CD Image issues',
-    'cdrom' : 'Problems with installation from CD-ROMs',
-    'debian-maintainers' :  'Problems and requests related to Debian Maintainers',
-    'debian-policy' : 'Proposed changes in the Debian policy documentation',
-    'debian-i18n' :  'Requests regarding Internationalization (i18n) of the distribution',
-    'ftp.debian.org' : 'Problems with the FTP site and Package removal requests',
-    'general' : 'General problems (e.g., that many manpages are mode 755)',
-    'installation-reports' : 'Problems with installing Debian',
-    'listarchives' :  'Problems with the WWW mailing list archives',
-    'lists.debian.org' : 'The mailing lists, debian-*@lists.debian.org.',
-    'mirrors' : 'Problems with Debian archive mirrors.',
-    'nm.debian.org' : 'New Maintainer process and nm.debian.org website',
-    'press' : 'Press release issues',
-    'project' : 'Problems related to project administration',
-    'qa.debian.org' : 'Problems related to the quality assurance group',
-    'release.debian.org' : 'Requests regarding Debian releases and release team tools',
-    'release-notes' : 'Problems with the release notes',
-    'security-tracker' : 'The Debian Security Bug Tracker',
-    'security.debian.org' : 'Problems with the security updates server',
-    'snapshot.debian.org' :  'Issues with the snapshot.debian.org service',
-    'spam' : 'Spam (reassign spam to here so we can complain about it)',
-    'tech-ctte' : 'Issues to be referred to the technical committee',
-    'upgrade-reports' : 'Reports of successful and unsucessful upgrades',
-    'wiki.debian.org' : 'Problems with the Debian wiki',
-    'wnpp' : 'Work-Needing and Prospective Packages list',
-    'www.debian.org' : 'Problems with the WWW site (including other *.debian.org sites, except alioth)'
-    }
+    'bugs.debian.org': 'The bug tracking system, @bugs.debian.org',
+    'buildd.debian.org': 'Problems and requests related to the Debian Buildds',
+    'buildd.emdebian.org': 'Problems related to building packages for Emdebian',
+    'cdimage.debian.org': 'CD Image issues',
+    'cdrom': 'Problems with installation from CD-ROMs',
+    'debian-maintainers': 'Problems and requests related to Debian Maintainers',
+    'debian-policy': 'Proposed changes in the Debian policy documentation',
+    'debian-i18n': 'Requests regarding Internationalization (i18n) of the distribution',
+    'ftp.debian.org': 'Problems with the FTP site and Package removal requests',
+    'general': 'General problems (e.g., that many manpages are mode 755)',
+    'installation-reports': 'Problems with installing Debian',
+    'listarchives': 'Problems with the WWW mailing list archives',
+    'lists.debian.org': 'The mailing lists, debian-*@lists.debian.org.',
+    'mirrors': 'Problems with Debian archive mirrors.',
+    'nm.debian.org': 'New Maintainer process and nm.debian.org website',
+    'press': 'Press release issues',
+    'project': 'Problems related to project administration',
+    'qa.debian.org': 'Problems related to the quality assurance group',
+    'release.debian.org': 'Requests regarding Debian releases and release team tools',
+    'release-notes': 'Problems with the release notes',
+    'security-tracker': 'The Debian Security Bug Tracker',
+    'security.debian.org': 'Problems with the security updates server',
+    'snapshot.debian.org': 'Issues with the snapshot.debian.org service',
+    'spam': 'Spam (reassign spam to here so we can complain about it)',
+    'tech-ctte': 'Issues to be referred to the technical committee',
+    'upgrade-reports': 'Reports of successful and unsucessful upgrades',
+    'wiki.debian.org': 'Problems with the Debian wiki',
+    'wnpp': 'Work-Needing and Prospective Packages list',
+    'www.debian.org': 'Problems with the WWW site (including other *.debian.org sites, except alioth)'
+}
 
 progenyother = {
-    'debian-general' : 'Any non-package-specific bug',
-    }
+    'debian-general': 'Any non-package-specific bug',
+}
+
 
 def handle_debian_ftp(package, bts, ui, fromaddr, timeout, online=True, http_proxy=None):
     body = reason = archs = section = priority = ''
@@ -207,27 +213,17 @@ def handle_debian_ftp(package, bts, ui, fromaddr, timeout, online=True, http_pro
                   'things mean anything to you, or you are trying to report '
                   'a bug in an existing package, please press Enter to '
                   'exit reportbug.)', {
-        'ROM' :
-        "Package removal - Request Of Maintainer.",
-        'RoQA' :
-        "Package removal - Requested by the QA team.",
-        'ROP' :
-        "Package removal - Request of Porter.",
-        'NBS' :
-        "Package removal - Not Built [by] Source.",
-        'NPOASR' :
-        "Package removal - Never Part Of A Stable Release.",
-        'NVIU' :
-        "Package removal - Newer Version In Unstable.",
-        'ANAIS' :
-        "Package removal - Architecture Not Allowed In Source.",
-        'ICE' :
-        "Package removal - Internal Compiler Error.",
-        'override' :
-        "Change override request.",
-        'other' :
-        "Not a package removal request, report other problems.",
-        }, 'Choose the request type: ', empty_ok=True)
+                      'ROM': "Package removal - Request Of Maintainer.",
+                      'RoQA': "Package removal - Requested by the QA team.",
+                      'ROP': "Package removal - Request of Porter.",
+                      'NBS': "Package removal - Not Built [by] Source.",
+                      'NPOASR': "Package removal - Never Part Of A Stable Release.",
+                      'NVIU': "Package removal - Newer Version In Unstable.",
+                      'ANAIS': "Package removal - Architecture Not Allowed In Source.",
+                      'ICE': "Package removal - Internal Compiler Error.",
+                      'override': "Change override request.",
+                      'other': "Not a package removal request, report other problems.",
+                  }, 'Choose the request type: ', empty_ok=True)
     if not tag:
         ui.long_message('To report a bug in a package, use the name of the package, not ftp.debian.org.\n')
         raise SystemExit
@@ -256,7 +252,7 @@ def handle_debian_ftp(package, bts, ui, fromaddr, timeout, online=True, http_pro
             cont = ui.select_options(
                 "This package doesn't appear to exist; continue?",
                 'yN', {'y': 'Ignore this problem and continue.',
-                       'n': 'Exit without filing a report.' })
+                       'n': 'Exit without filing a report.'})
             if cont == 'n':
                 sys.exit(1)
         else:
@@ -269,30 +265,30 @@ def handle_debian_ftp(package, bts, ui, fromaddr, timeout, online=True, http_pro
     if tag == 'override':
         # we handle here the override change request
         new_section = ui.menu('Select the new section', {
-                'admin': "", 'cli-mono': "", 'comm': "", 'database': "",
-                'debian-installer': "", 'debug': "", 'devel': "", 'doc': "",
-                'editors': "", 'education': "", 'electronics': "",
-                'embedded': "", 'fonts': "", 'games': "", 'gnome': "",
-                'gnu-r': "", 'gnustep': "", 'graphics': "", 'hamradio': "",
-                'haskell': "", 'httpd': "", 'interpreters': "",
-                'introspection': "", 'java': "", 'kde': "", 'kernel': "",
-                'libdevel': "", 'libs': "", 'lisp': "", 'localization': "",
-                'mail': "", 'math': "", 'metapackages': "", 'misc': "",
-                'net': "", 'news': "", 'ocaml': "", 'oldlibs': "",
-                'otherosfs': "", 'perl': "", 'php': "", 'python': "",
-                'ruby': "", 'science': "", 'shells': "", 'sound': "", 'tex': "",
-                'text': "", 'utils': "", 'vcs': "", 'video': "", 'web': "",
-                'x11': "", 'xfce': "", 'zope': "",
+            'admin': "", 'cli-mono': "", 'comm': "", 'database': "",
+            'debian-installer': "", 'debug': "", 'devel': "", 'doc': "",
+            'editors': "", 'education': "", 'electronics': "",
+            'embedded': "", 'fonts': "", 'games': "", 'gnome': "",
+            'gnu-r': "", 'gnustep': "", 'graphics': "", 'hamradio': "",
+            'haskell': "", 'httpd': "", 'interpreters': "",
+            'introspection': "", 'java': "", 'kde': "", 'kernel': "",
+            'libdevel': "", 'libs': "", 'lisp': "", 'localization': "",
+            'mail': "", 'math': "", 'metapackages': "", 'misc': "",
+            'net': "", 'news': "", 'ocaml': "", 'oldlibs': "",
+            'otherosfs': "", 'perl': "", 'php': "", 'python': "",
+            'ruby': "", 'science': "", 'shells': "", 'sound': "", 'tex': "",
+            'text': "", 'utils': "", 'vcs': "", 'video': "", 'web': "",
+            'x11': "", 'xfce': "", 'zope': "",
         }, 'Choose the section: ', default=section, empty_ok=True)
         if not new_section:
             new_section = section
 
         new_priority = ui.menu('Select the new priority', {
-                'required': "",
-                'important': "",
-                'standard': "",
-                'optional': "",
-                'extra': "",
+            'required': "",
+            'important': "",
+            'standard': "",
+            'optional': "",
+            'extra': "",
         }, 'Choose the priority: ', default=priority, empty_ok=True)
         if not new_priority:
             new_priority = priority
@@ -302,19 +298,19 @@ def handle_debian_ftp(package, bts, ui, fromaddr, timeout, online=True, http_pro
                 "You didn't change section nor priority: is this because it's "
                 "ftp.debian.org override file that needs updating?",
                 'Yn', {'y': 'ftp.debian.org override file needs updating',
-                       'n': 'No, it\'s not the override file' })
+                       'n': 'No, it\'s not the override file'})
             if cont == 'n':
                 ui.long_message("There's nothing we can do for you, then; "
                                 "exiting...")
                 sys.exit(1)
 
         arch_section = ui.menu('Is this request for an archive section other than "main"?', {
-            'main' : "",
-            'contrib' : "",
-            'non-free' : "",
+            'main': "",
+            'contrib': "",
+            'non-free': "",
         }, 'Choose the archive section: ', default='main', empty_ok=True)
         if not arch_section:
-           arch_section = 'main'
+            arch_section = 'main'
 
         if arch_section != 'main':
             subject = "override: %s:%s/%s %s" % (package, arch_section, new_section, new_priority)
@@ -325,14 +321,14 @@ def handle_debian_ftp(package, bts, ui, fromaddr, timeout, online=True, http_pro
         # we handle here the removal requests
         suite = ui.menu('Is the removal to be done in a suite other than'
                         ' "unstable"?  Don\'t select anything for "unstable"', {
-            'oldstable' : "Old stable.",
-            'oldstable-proposed-updates' : "Old stable proposed updates.",
-            'stable' : "Stable.",
-            'stable-proposed-updates' : "Stable proposed updates.",
-            'testing' : "Testing only (NOT unstable)",
-	    'testing-proposed-updates' : "Testing proposed updates",
-            'experimental' : "Experimental.",
-        }, 'Choose the suite: ', empty_ok=True)
+                            'oldstable': "Old stable.",
+                            'oldstable-proposed-updates': "Old stable proposed updates.",
+                            'stable': "Stable.",
+                            'stable-proposed-updates': "Stable proposed updates.",
+                            'testing': "Testing only (NOT unstable)",
+                            'testing-proposed-updates': "Testing proposed updates",
+                            'experimental': "Experimental.",
+                        }, 'Choose the suite: ', empty_ok=True)
         if not suite:
             suite = 'unstable'
 
@@ -342,12 +338,13 @@ def handle_debian_ftp(package, bts, ui, fromaddr, timeout, online=True, http_pro
 
         why = 'Please enter the reason for removal: '
         reason = ui.get_string(why)
-        if not reason: return
+        if not reason:
+            return
 
         partial = ui.select_options(
             "Is this removal request for specific architectures?",
             'yN', {'y': 'This is a partial (specific architectures) removal.',
-                   'n': 'This removal is for all architectures.' })
+                   'n': 'This removal is for all architectures.'})
         if partial == 'y':
             prompt = 'Please enter the arch list separated by a space: '
             archs = ui.get_string(prompt)
@@ -355,14 +352,13 @@ def handle_debian_ftp(package, bts, ui, fromaddr, timeout, online=True, http_pro
                 ui.long_message('Partial removal requests must have a list of architectures.\n')
                 raise SystemExit
 
-
         if suite == 'testing' and archs:
             ui.long_message('Partial removal for testing; forcing suite to '
                             '\'unstable\', since it\'s the proper way to do that.')
             suite = 'unstable'
-            body = '(please explain the reason for the removal here)\n\n' +\
-                'Note: this was a request for a partial removal from testing, ' +\
-                'converted in one for unstable'
+            body = '(please explain the reason for the removal here)\n\n' + \
+                   'Note: this was a request for a partial removal from testing, ' + \
+                   'converted in one for unstable'
 
         if archs:
             if suite != 'unstable':
@@ -395,15 +391,15 @@ def handle_debian_release(package, bts, ui, fromaddr, timeout, online=True, http
                   'things mean anything to you, or you are trying to report '
                   'a bug in an existing package, please press Enter to '
                   'exit reportbug.)', {
-        'binnmu':           "binNMU requests",
-        'britney':          "testing migration script bugs",
-        'transition':       "transition tracking",
-        'unblock':          "unblock requests",
-        'wheezy-pu':        "wheezy proposed updates requests",
-        'jessie-pu':        "jessie proposed updates requests",
-        'rm':               "Stable/Testing removal requests",
-        'other' :           "None of the other options",
-        }, 'Choose the request type: ', empty_ok=True)
+                      'binnmu': "binNMU requests",
+                      'britney': "testing migration script bugs",
+                      'transition': "transition tracking",
+                      'unblock': "unblock requests",
+                      'wheezy-pu': "wheezy proposed updates requests",
+                      'jessie-pu': "jessie proposed updates requests",
+                      'rm': "Stable/Testing removal requests",
+                      'other': "None of the other options",
+                  }, 'Choose the request type: ', empty_ok=True)
     if not tag:
         ui.long_message('To report a bug in a package, use the name of the package, not release.debian.org.\n')
         raise SystemExit
@@ -419,7 +415,7 @@ def handle_debian_release(package, bts, ui, fromaddr, timeout, online=True, http
             sys.exit(1)
     else:
         # package checks code
-        prompt  = 'Please enter the name of the package: '
+        prompt = 'Please enter the name of the package: '
         package = ui.get_string(prompt)
         if not package:
             ui.log_message('You seem to want to report a generic bug.\n')
@@ -439,7 +435,7 @@ def handle_debian_release(package, bts, ui, fromaddr, timeout, online=True, http
             cont = ui.select_options(
                 "This package doesn't appear to exist; continue?",
                 'yN', {'y': 'Ignore this problem and continue.',
-                       'n': 'Exit without filing a report.' })
+                       'n': 'Exit without filing a report.'})
             if cont == 'n':
                 sys.exit(1)
         else:
@@ -467,14 +463,14 @@ def handle_debian_release(package, bts, ui, fromaddr, timeout, online=True, http
         partial = ui.select_options(
             "Is this request for specific architectures?",
             'yN', {'y': 'This is a partial (specific architectures) request.',
-                   'n': 'This request is for all architectures.' })
+                   'n': 'This request is for all architectures.'})
         if partial == 'y':
             if tag == 'rm':
                 ui.long_message('The proper way to request a partial removal '
-                   'from testing is to file a partial removal from unstable: '
-                   'this way the package for the specified architectures will '
-                   'be automatically removed from testing too. Please re-run '
-                   'reportbug against ftp.debian.org package.')
+                                'from testing is to file a partial removal from unstable: '
+                                'this way the package for the specified architectures will '
+                                'be automatically removed from testing too. Please re-run '
+                                'reportbug against ftp.debian.org package.')
                 raise SystemExit
             prompt = 'Please enter the arch list separated by a space: '
             archs = ui.get_string(prompt)
@@ -484,15 +480,15 @@ def handle_debian_release(package, bts, ui, fromaddr, timeout, online=True, http
     if tag == 'binnmu':
         suite = ui.menu("For which suite are you requesting this binNMU?"
                         "  Don't select anything for \"unstable\"", {
-            'jessie' : "",
-            'jessie-backports' : "",
-            'jessie-security' : "",
-            'wheezy' : "",
-            'wheezy-backports' : "",
-            'wheezy-security' : "",
-            'stretch': "",
-            'experimental' : "",
-        }, 'Choose the suite: ', empty_ok=True)
+                            'jessie': "",
+                            'jessie-backports': "",
+                            'jessie-security': "",
+                            'wheezy': "",
+                            'wheezy-backports': "",
+                            'wheezy-security': "",
+                            'stretch': "",
+                            'experimental': "",
+                        }, 'Choose the suite: ', empty_ok=True)
         if not suite:
             suite = 'unstable'
 
@@ -504,13 +500,13 @@ def handle_debian_release(package, bts, ui, fromaddr, timeout, online=True, http
         pseudos.append("Usertags: %s" % (tag))
 
     if tag == 'binnmu':
-        reason  = ui.get_string("binNMU changelog entry: ")
+        reason = ui.get_string("binNMU changelog entry: ")
         subject = "nmu: %s_%s" % (package, version)
-        body    = "nmu %s_%s . %s . %s . -m \"%s\"\n" % (package, version, archs or "ANY", suite, reason)
+        body = "nmu %s_%s . %s . %s . -m \"%s\"\n" % (package, version, archs or "ANY", suite, reason)
     elif tag == 'transition':
         subject = 'transition: %s' % (package)
-        body    = '(please explain about the transition: impacted packages, reason, ...\n' \
-                  ' for more info see: https://wiki.debian.org/Teams/ReleaseTeam/Transitions)\n'
+        body = '(please explain about the transition: impacted packages, reason, ...\n' \
+               ' for more info see: https://wiki.debian.org/Teams/ReleaseTeam/Transitions)\n'
         affected = '<Fill out>'
         good = '<Fill out>'
         bad = '<Fill out>'
@@ -536,7 +532,7 @@ def handle_debian_release(package, bts, ui, fromaddr, timeout, online=True, http
             # Compute a ben file from this.
 
             # (quote if x does not start with a "/")
-            quote=lambda x: (x[0] == '/' and x) or '"%s"' % x
+            quote = lambda x: (x[0] == '/' and x) or '"%s"' % x
 
             listbad = [quote(x) for x in tfrom.strip().split()]
             listgood = [quote(x) for x in tto.strip().split()]
@@ -546,7 +542,6 @@ def handle_debian_release(package, bts, ui, fromaddr, timeout, online=True, http
             good = ".depends ~ " + j(listgood)
             bad = ".depends ~ " + j(listbad)
 
-
         body += textwrap.dedent(u"""\
 
                Ben file:
@@ -563,7 +558,7 @@ def handle_debian_release(package, bts, ui, fromaddr, timeout, online=True, http
         body = ''
     elif tag == 'unblock':
         subject = 'unblock: %s/%s' % (package, version)
-        body    = textwrap.dedent(u"""\
+        body = textwrap.dedent(u"""\
                 Please unblock package %s
 
                 (explain the reason for the unblock here)
@@ -574,13 +569,14 @@ def handle_debian_release(package, bts, ui, fromaddr, timeout, online=True, http
                 """ % (package, package, version))
     elif tag.endswith('-pu'):
         subject = '%s: package %s/%s' % (tag, package, version)
-        body    = '(please explain the reason for this update here)\n'
+        body = '(please explain the reason for this update here)\n'
     elif tag == 'rm':
         subject = 'RM: %s/%s' % (package, version)
         body = '(explain the reason for the removal here)\n'
 
     return (subject, severity, headers, pseudos, body, query)
 
+
 itp_template = textwrap.dedent(u"""\
     * Package name    : %(package)s
       Version         : x.y.z
@@ -613,17 +609,12 @@ def handle_wnpp(package, bts, ui, fromaddr, timeout, online=True, http_proxy=Non
                   'things mean anything to you, or you are trying to report '
                   'a bug in an existing package, please press Enter to '
                   'exit reportbug.)', {
-        'O' :
-        "The package has been `Orphaned'. It needs a new maintainer as soon as possible.",
-        'RFA' :
-        "This is a `Request for Adoption'. Due to lack of time, resources, interest or something similar, the current maintainer is asking for someone else to maintain this package. They will maintain it in the meantime, but perhaps not in the best possible way. In short: the package needs a new maintainer.",
-        'RFH' :
-        "This is a `Request For Help'. The current maintainer wants to continue to maintain this package, but they need some help to do this because their time is limited or the package is quite big and needs several maintainers.",
-        'ITP' :
-        "This is an `Intent To Package'. Please submit a package description along with copyright and URL in such a report.",
-        'RFP' :
-        "This is a `Request For Package'. You have found an interesting piece of software and would like someone else to maintain it for Debian. Please submit a package description along with copyright and URL in such a report.",
-        }, 'Choose the request type: ', empty_ok=True)
+                      'O': "The package has been `Orphaned'. It needs a new maintainer as soon as possible.",
+                      'RFA': "This is a `Request for Adoption'. Due to lack of time, resources, interest or something similar, the current maintainer is asking for someone else to maintain this package. They will maintain it in the meantime, but perhaps not in the best possible way. In short: the package needs a new maintainer.",
+                      'RFH': "This is a `Request For Help'. The current maintainer wants to continue to maintain this package, but they need some help to do this because their time is limited or the package is quite big and needs several maintainers.",
+                      'ITP': "This is an `Intent To Package'. Please submit a package description along with copyright and URL in such a report.",
+                      'RFP': "This is a `Request For Package'. You have found an interesting piece of software and would like someone else to maintain it for Debian. Please submit a package description along with copyright and URL in such a report.",
+                  }, 'Choose the request type: ', empty_ok=True)
     if not tag:
         ui.long_message('To report a bug in a package, use the name of the package, not wnpp.\n')
         raise SystemExit
@@ -648,14 +639,14 @@ def handle_wnpp(package, bts, ui, fromaddr, timeout, online=True, http_proxy=Non
     severity = 'normal'
     if tag in ('ITP', 'RFP'):
         if available and (not online or checkversions.check_available(
-            package, '0', timeout, http_proxy=http_proxy)):
+                package, '0', timeout, http_proxy=http_proxy)):
             if not ui.yes_no(
-                ('A package called %s already appears to exist (at least on '
-                 'your system); continue?' % package),
-                'Ignore this problem and continue.  If you have '
-                'already locally created a package with this name, this '
-                'warning message may have been produced in error.',
-                'Exit without filing a report.', default=0):
+                    ('A package called %s already appears to exist (at least on '
+                     'your system); continue?' % package),
+                    'Ignore this problem and continue.  If you have '
+                    'already locally created a package with this name, this '
+                    'warning message may have been produced in error.',
+                    'Exit without filing a report.', default=0):
                 sys.exit(1)
 
         severity = 'wishlist'
@@ -687,7 +678,7 @@ def handle_wnpp(package, bts, ui, fromaddr, timeout, online=True, http_proxy=Non
             cont = ui.select_options(
                 "This package doesn't appear to exist; continue?",
                 'yN', {'y': 'Ignore this problem and continue.',
-                       'n': 'Exit without filing a report.' })
+                       'n': 'Exit without filing a report.'})
             if cont == 'n':
                 sys.exit(1)
             short_desc = long_desc = ''
@@ -697,7 +688,7 @@ def handle_wnpp(package, bts, ui, fromaddr, timeout, online=True, http_proxy=Non
             long_desc = info[13]
 
         if tag == 'O' and info and info[9] in \
-               ('required', 'important', 'standard'):
+                ('required', 'important', 'standard'):
             severity = 'important'
 
         if tag == 'RFH':
@@ -723,6 +714,7 @@ def handle_wnpp(package, bts, ui, fromaddr, timeout, online=True, http_proxy=Non
 
     return (subject, severity, headers, pseudos, body, query)
 
+
 def dpkg_infofunc():
     debarch = utils.get_arch()
     utsmachine = os.uname()[4]
@@ -739,75 +731,80 @@ def dpkg_infofunc():
     debinfo += '\n'
     return debinfo
 
+
 def debian_infofunc():
     return utils.get_debian_release_info() + dpkg_infofunc()
 
+
 def ubuntu_infofunc():
     return utils.lsb_release_info() + dpkg_infofunc()
 
+
 def generic_infofunc():
     utsmachine = os.uname()[4]
     return utils.lsb_release_info() + u'Architecture: %s\n\n' % utsmachine
 
+
 # Supported servers
 # Theoretically support for GNATS and Jitterbug could be added here.
-SYSTEMS = { 'debian' :
-            { 'name' : 'Debian', 'email': '%s at bugs.debian.org',
-              'btsroot' : 'http://www.debian.org/Bugs/',
-              'otherpkgs' : debother,
-              'nonvirtual' : ['linux-image', 'kernel-image'],
-              'specials' :
-                { 'wnpp': handle_wnpp,
-                  'ftp.debian.org': handle_debian_ftp,
-                  'release.debian.org': handle_debian_release },
-              # Dependency packages
-              'deppkgs' : ('gcc', 'g++', 'cpp', 'gcj', 'gpc', 'gobjc',
-                           'chill', 'gij', 'g77', 'python', 'python-base',
-                           'x-window-system-core', 'x-window-system'),
-              'cgiroot' : 'https://bugs.debian.org/cgi-bin/',
-              'infofunc' : debian_infofunc,
-              },
-            'ubuntu' :
-            { 'name' : 'Ubuntu', 'email' : 'ubuntu-users at lists.ubuntu.com',
-              'type' : 'mailto',
-              'infofunc' : ubuntu_infofunc,
-              },
-            'guug' :
-            { 'name' : 'GUUG (German Unix User Group)',
-              'email' : '%s at bugs.guug.de', 'query-dpkg' : False },
-            }
+SYSTEMS = {'debian':
+           {'name': 'Debian', 'email': '%s at bugs.debian.org',
+            'btsroot': 'http://www.debian.org/Bugs/',
+            'otherpkgs': debother,
+            'nonvirtual': ['linux-image', 'kernel-image'],
+            'specials':
+                {'wnpp': handle_wnpp,
+                 'ftp.debian.org': handle_debian_ftp,
+                 'release.debian.org': handle_debian_release},
+            # Dependency packages
+            'deppkgs': ('gcc', 'g++', 'cpp', 'gcj', 'gpc', 'gobjc',
+                        'chill', 'gij', 'g77', 'python', 'python-base',
+                        'x-window-system-core', 'x-window-system'),
+            'cgiroot': 'https://bugs.debian.org/cgi-bin/',
+            'infofunc': debian_infofunc,
+            },
+           'ubuntu':
+               {'name': 'Ubuntu', 'email': 'ubuntu-users at lists.ubuntu.com',
+                'type': 'mailto',
+                'infofunc': ubuntu_infofunc,
+                },
+           'guug':
+               {'name': 'GUUG (German Unix User Group)',
+                'email': '%s at bugs.guug.de', 'query-dpkg': False},
+           }
 
 CLASSES = {
-    'sw-bug' : 'The problem is a bug in the software or code.  For'
-    'example, a crash would be a sw-bug.',
-    'doc-bug' : 'The problem is in the documentation.  For example,'
-    'an error in a man page would be a doc-bug.',
-    'change-request' : 'You are requesting a new feature or a change'
-    'in the behavior of software, or are making a suggestion.  For'
-    'example, if you wanted reportbug to be able to get your local'
-    'weather forecast, as well as report bugs, that would be a'
-    'change-request.',
-    }
+    'sw-bug': 'The problem is a bug in the software or code.  For'
+              'example, a crash would be a sw-bug.',
+    'doc-bug': 'The problem is in the documentation.  For example,'
+               'an error in a man page would be a doc-bug.',
+    'change-request': 'You are requesting a new feature or a change'
+                      'in the behavior of software, or are making a suggestion.  For'
+                      'example, if you wanted reportbug to be able to get your local'
+                      'weather forecast, as well as report bugs, that would be a'
+                      'change-request.',
+}
 
 CLASSLIST = ['sw-bug', 'doc-bug', 'change-request']
 
 CRITICAL_TAGS = {
-    'security' : 'This problem is a security vulnerability in Debian.',
+    'security': 'This problem is a security vulnerability in Debian.',
 }
 
 EXPERT_TAGS = {
-    'security' : 'This problem is a security vulnerability in Debian.',
+    'security': 'This problem is a security vulnerability in Debian.',
 }
 
 TAGS = {
-    'patch' : 'You are including a patch to fix this problem.',
-    'upstream' : 'This bug applies to the upstream part of the package.',
-    'd-i' : 'This bug is relevant to the development of debian-installer.',
-    'ipv6' : 'This bug affects support for Internet Protocol version 6.',
-    'lfs' : 'This bug affects support for large files (over 2 gigabytes).',
-    'l10n' : 'This bug reports a localization/internationalization issue.',
-    'newcomer' : 'This bug has a known solution but the maintainer requests someone else implement it.',
-    }
+    'patch': 'You are including a patch to fix this problem.',
+    'upstream': 'This bug applies to the upstream part of the package.',
+    'd-i': 'This bug is relevant to the development of debian-installer.',
+    'ipv6': 'This bug affects support for Internet Protocol version 6.',
+    'lfs': 'This bug affects support for large files (over 2 gigabytes).',
+    'l10n': 'This bug reports a localization/internationalization issue.',
+    'newcomer': 'This bug has a known solution but the maintainer requests someone else implement it.',
+}
+
 
 def get_tags(severity='', mode=utils.MODE_NOVICE):
     """Returns the current tags list.
@@ -825,6 +822,7 @@ def get_tags(severity='', mode=utils.MODE_NOVICE):
 
     return tags
 
+
 def yn_bool(setting):
     if setting:
         if str(setting) == 'no':
@@ -833,6 +831,7 @@ def yn_bool(setting):
     else:
         return 'no'
 
+
 def cgi_report_url(system, number, archived=False, mbox=False):
     root = SYSTEMS[system].get('cgiroot')
     if root:
@@ -840,16 +839,18 @@ def cgi_report_url(system, number, archived=False, mbox=False):
             root, number, archived, yn_bool(mbox))
     return None
 
+
 def cgi_package_url(system, package, archived=False, source=False,
                     repeatmerged=True, version=None):
     root = SYSTEMS[system].get('cgiroot')
-    if not root: return None
+    if not root:
+        return None
 
-    #package = urllib.quote_plus(package.lower())
+    # package = urllib.quote_plus(package.lower())
     if source:
-        query = {'src' : package.lower()}
+        query = {'src': package.lower()}
     else:
-        query = {'pkg' : package.lower()}
+        query = {'pkg': package.lower()}
 
     query['repeatmerged'] = yn_bool(repeatmerged)
     query['archived'] = yn_bool(archived)
@@ -858,50 +859,61 @@ def cgi_package_url(system, package, archived=False, source=False,
         query['version'] = str(version)
 
     qstr = urllib.urlencode(query)
-    #print qstr
+    # print qstr
     return '%spkgreport.cgi?%s' % (root, qstr)
 
+
 # TODO: to be removed
 def package_url(system, package, mirrors=None, source=False,
                 repeatmerged=True):
-    btsroot=get_btsroot(system, mirrors)
+    btsroot = get_btsroot(system, mirrors)
     package = urllib.quote_plus(package.lower())
-    return btsroot+('db/pa/l%s.html' % package)
+    return btsroot + ('db/pa/l%s.html' % package)
+
 
 # TODO: to be removed
 def report_url(system, number, mirrors=None):
+
     number = str(number)
-    if len(number) < 2: return None
-    btsroot=get_btsroot(system, mirrors)
-    return btsroot+('db/%s/%s.html' % (number[:2], number))
+    if len(number) < 2:
+        return None
+    btsroot = get_btsroot(system, mirrors)
+    return btsroot + ('db/%s/%s.html' % (number[:2], number))
+
 
 def get_package_url(system, package, mirrors=None, source=False,
                     archived=False, repeatmerged=True):
     return (cgi_package_url(system, package, archived, source, repeatmerged) or
             package_url(system, package, mirrors, source, repeatmerged))
 
+
 def get_report_url(system, number, mirrors=None, archived=False, mbox=False):
     return (cgi_report_url(system, number, archived, mbox) or
             report_url(system, number, mirrors))
 
+
 def parse_bts_url(url):
     bits = url.split(':', 1)
-    if len(bits) != 2: return None
+    if len(bits) != 2:
+        return None
 
     type, loc = bits
-    if loc.startswith('//'): loc = loc[2:]
-    while loc.endswith('/'): loc = loc[:-1]
+    if loc.startswith('//'):
+        loc = loc[2:]
+    while loc.endswith('/'):
+        loc = loc[:-1]
     return type, loc
 
+
 # Dynamically add any additional systems found
 for origin in glob.glob('/etc/dpkg/origins/*'):
     try:
         fp = file(origin)
         system = os.path.basename(origin)
-        SYSTEMS[system] = SYSTEMS.get(system, { 'otherpkgs' : {},
-                                                'query-dpkg' : True,
-                                                'mirrors' : {},
-                                                'cgiroot' : None } )
+        SYSTEMS[system] = SYSTEMS.get(system, {'otherpkgs': {},
+                                               'query-dpkg': True,
+                                               'mirrors': {},
+                                               'cgiroot': None})
         for line in fp:
             try:
                 (header, content) = line.split(': ', 1)
@@ -913,8 +925,8 @@ for origin in glob.glob('/etc/dpkg/origins/*'):
                     (type, root) = parse_bts_url(content)
                     SYSTEMS[system]['type'] = type
                     if type == 'debbugs':
-                        SYSTEMS[system]['btsroot'] = 'http://'+root+'/'
-                        SYSTEMS[system]['email'] = '%s@'+root
+                        SYSTEMS[system]['btsroot'] = 'http://' + root + '/'
+                        SYSTEMS[system]['email'] = '%s@' + root
                     elif type == 'mailto':
                         SYSTEMS[system]['btsroot'] = None
                         SYSTEMS[system]['email'] = root
@@ -927,6 +939,7 @@ for origin in glob.glob('/etc/dpkg/origins/*'):
     except IOError:
         pass
 
+
 # For summary pages, we want to keep:
 #
 # - Contents of <title>...</title>
@@ -989,7 +1002,8 @@ class BTSParser(sgmllib.SGMLParser):
         self.mode = self.oldmode
 
     def start_h2(self, attrs):
-        if self.lidata: self.check_li()
+        if self.lidata:
+            self.check_li()
 
         self.save_bgn()
 
@@ -997,8 +1011,8 @@ class BTSParser(sgmllib.SGMLParser):
         if self.mode == 'summary':
             hiertitle = self.save_end()
             if 'bug' in hiertitle:
-                self.hierarchy.append( (hiertitle, []) )
-        self.endh2 = True # We are at the end of a title, flag <pre>
+                self.hierarchy.append((hiertitle, []))
+        self.endh2 = True  # We are at the end of a title, flag <pre>
 
     def start_ul(self, attrs):
         if self.mode == 'summary':
@@ -1050,7 +1064,8 @@ class BTSParser(sgmllib.SGMLParser):
 
     def do_li(self, attrs):
         if self.mode == 'summary' and self.inbuglist:
-            if self.lidata: self.check_li()
+            if self.lidata:
+                self.check_li()
 
             self.lidata = True
             if self.hierarchy:
@@ -1062,16 +1077,19 @@ class BTSParser(sgmllib.SGMLParser):
     def start_pre(self, attrs):
         "Save <pre> when we follow a </h2>"
         if self.followups:
-            if not self.endh2: return
+            if not self.endh2:
+                return
         else:
-            if self.cgi and self.preblock: return
+            if self.cgi and self.preblock:
+                return
 
         self.save_bgn()
 
     def end_pre(self):
         if self.followups:
-            if not self.endh2: return
-            self.endh2 = False	# Done with a report, reset </h2>.
+            if not self.endh2:
+                return
+            self.endh2 = False  # Done with a report, reset </h2>.
             stuff = self.save_end(1)
             if not self.cgi:
                 self.preblock.insert(0, stuff)
@@ -1091,7 +1109,7 @@ class BTSParser(sgmllib.SGMLParser):
 
         for (title, buglist) in self.hierarchy:
             if 'Resolved' in title:
-                newhierarchy.append( (title, buglist) )
+                newhierarchy.append((title, buglist))
                 continue
 
             bugs = []
@@ -1108,11 +1126,12 @@ class BTSParser(sgmllib.SGMLParser):
                 else:
                     title += ' (1 bug)'
 
-                newhierarchy.append( (title, bugs) )
+                newhierarchy.append((title, bugs))
 
         if fixed:
             self.hierarchy = [('Bugs fixed in subsequent releases (%d bugs)' % len(fixed), fixed)] + newhierarchy
 
+
 # TODO: to be removed
 def parse_html_report(number, url, http_proxy, timeout, followups=False, cgi=True):
     page = open_url(url, http_proxy, timeout)
@@ -1148,7 +1167,7 @@ def parse_html_report(number, url, http_proxy, timeout, followups=False, cgi=Tru
         if not stuff:
             continue
 
-        item = date_submitted+stuff+os.linesep
+        item = date_submitted + stuff + os.linesep
         output.append(item)
 
     if not output:
@@ -1156,6 +1175,7 @@ def parse_html_report(number, url, http_proxy, timeout, followups=False, cgi=Tru
 
     return (title, output)
 
+
 # XXX: Need to handle charsets properly
 def parse_mbox_report(number, url, http_proxy, timeout, followups=False):
     page = open_url(url, http_proxy, timeout)
@@ -1213,25 +1233,26 @@ def parse_mbox_report(number, url, http_proxy, timeout, followups=False):
     title = "#%d: %s" % (number, title)
     return (title, output)
 
+
 def get_cgi_reports(package, timeout, system='debian', http_proxy='',
                     archived=False, source=False, version=None):
     try:
         page = open_url(cgi_package_url(system, package, archived, source,
-                                    version=version), http_proxy, timeout)
+                                        version=version), http_proxy, timeout)
     except:
         raise NoNetwork
 
     if not page:
         return (0, None, None)
 
-    #content = page.read()
-    #if 'Maintainer' not in content:
+    # content = page.read()
+    # if 'Maintainer' not in content:
     #    return (0, None, None)
 
     parser = BTSParser(cgi=True)
     for line in page:
         try:
-            line = line.decode('utf-8') # BTS pages are encoded in utf-8
+            line = line.decode('utf-8')  # BTS pages are encoded in utf-8
         except UnicodeDecodeError:
             # page has a bad char
             line = line.decode('utf-8', 'replace')
@@ -1257,25 +1278,27 @@ def get_cgi_reports(package, timeout, system='debian', http_proxy='',
 
     return data
 
+
 def get_cgi_report(number, timeout, system='debian', http_proxy='', archived=False,
                    followups=False):
     number = int(number)
 
     url = cgi_report_url(system, number, archived='no', mbox=True)
     return parse_mbox_report(number, url, http_proxy, timeout, followups)
-    #return parse_html_report(number, url, http_proxy, followups, cgi=True)
+    # return parse_html_report(number, url, http_proxy, followups, cgi=True)
+
 
 def get_btsroot(system, mirrors=None):
     if mirrors:
         alternates = SYSTEMS[system].get('mirrors')
         for mirror in mirrors:
-            if alternates.has_key(mirror):
+            if mirror in alternates:
                 return alternates[mirror]
     return SYSTEMS[system].get('btsroot', '')
 
+
 def get_reports(package, timeout, system='debian', mirrors=None, version=None,
                 http_proxy='', archived=False, source=False):
-
     if system == 'debian':
         if isinstance(package, basestring):
             if source:
@@ -1315,10 +1338,11 @@ def get_reports(package, timeout, system='debian', mirrors=None, version=None,
         if SYSTEMS[system].get('cgiroot'):
             try:
                 result = get_cgi_reports(package, timeout, system, http_proxy, archived,
-                                     source, version=version)
+                                         source, version=version)
             except:
                 raise NoNetwork
-            if result: return result
+            if result:
+                return result
 
         url = package_url(system, package, mirrors, source)
         try:
@@ -1328,8 +1352,8 @@ def get_reports(package, timeout, system='debian', mirrors=None, version=None,
         if not page:
             return (0, None, None)
 
-        #content = page.read()
-        #if 'Maintainer' not in content:
+        # content = page.read()
+        # if 'Maintainer' not in content:
         #    return (0, None, None)
 
         parser = BTSParser()
@@ -1353,7 +1377,7 @@ def get_reports(package, timeout, system='debian', mirrors=None, version=None,
         if result:
             title, body = result
             this_hierarchy.append(title)
-            #print title
+            # print title
 
     title = "Multiple bug reports"
     bugcount = len(this_hierarchy)
@@ -1361,6 +1385,7 @@ def get_reports(package, timeout, system='debian', mirrors=None, version=None,
 
     return bugcount, title, hierarchy
 
+
 def get_report(number, timeout, system='debian', mirrors=None,
                http_proxy='', archived=False, followups=False):
     number = int(number)
@@ -1387,9 +1412,11 @@ def get_report(number, timeout, system='debian', mirrors=None,
     if SYSTEMS[system].get('cgiroot'):
         result = get_cgi_report(number, timeout, system, http_proxy,
                                 archived, followups)
-        if result: return result
+        if result:
+            return result
 
     url = report_url(system, number, mirrors)
-    if not url: return None
+    if not url:
+        return None
 
     return parse_html_report(number, url, http_proxy, timeout, followups, cgi=False)
diff --git a/reportbug/exceptions.py b/reportbug/exceptions.py
index 51e2c42..39261b9 100644
--- a/reportbug/exceptions.py
+++ b/reportbug/exceptions.py
@@ -5,59 +5,70 @@
 #
 # This program is freely distributable per the following license:
 #
-##  Permission to use, copy, modify, and distribute this software and its
-##  documentation for any purpose and without fee is hereby granted,
-##  provided that the above copyright notice appears in all copies and that
-##  both that copyright notice and this permission notice appear in
-##  supporting documentation.
-##
-##  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-##  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
-##  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
-##  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-##  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-##  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-##  SOFTWARE.
+#  Permission to use, copy, modify, and distribute this software and its
+#  documentation for any purpose and without fee is hereby granted,
+#  provided that the above copyright notice appears in all copies and that
+#  both that copyright notice and this permission notice appear in
+#  supporting documentation.
+#
+#  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
+#  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+#  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+#  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+#  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+#  SOFTWARE.
+
 
 class reportbug_exception(Exception):
     pass
 
+
 class reportbug_ui_exception(reportbug_exception):
     pass
 
+
 # Can't initialize interface
 class UINotImportable(reportbug_ui_exception):
     pass
 
+
 # No package found
 class NoPackage(reportbug_ui_exception):
     pass
 
+
 # No bugs found
 class NoBugs(reportbug_ui_exception):
     pass
 
+
 # Nothing to report
 class NoReport(reportbug_ui_exception):
     pass
 
+
 # Code is not implemented
 class UINotImplemented(reportbug_ui_exception):
     pass
 
+
 # Other exceptions
 # No network access
 class NoNetwork(reportbug_exception):
     pass
 
+
 # Invalid regular expression
 class InvalidRegex(reportbug_exception):
     pass
 
+
 # Lame empty exception used later to save some coding
 class NoMessage(reportbug_exception):
     pass
 
+
 # There was a problem accessing BTS
 class QuertBTSError(reportbug_exception):
-    pass
\ No newline at end of file
+    pass
diff --git a/reportbug/hiermatch.py b/reportbug/hiermatch.py
index 121ad23..4551ee5 100644
--- a/reportbug/hiermatch.py
+++ b/reportbug/hiermatch.py
@@ -6,6 +6,7 @@
 import re
 import exceptions
 
+
 def egrep_list(strlist, pattern_str, subindex=None):
     """Use the pattern_str to find any match in a list of strings."""
     """Return: a list of index for the matchs into the origin list."""
@@ -14,10 +15,10 @@ def egrep_list(strlist, pattern_str, subindex=None):
         return None
 
     try:
-        pat = re.compile(pattern_str, re.I|re.M)
+        pat = re.compile(pattern_str, re.I | re.M)
     except:
         raise exceptions.InvalidRegex
-    
+
     resultlist = []
     if subindex is None:
         subindex = range(len(strlist))
@@ -26,6 +27,7 @@ def egrep_list(strlist, pattern_str, subindex=None):
             resultlist.append(i)
     return resultlist
 
+
 def egrep_hierarchy(hier, pattern_str, subhier=None, nth=1):
     """Grep the nth item of a hierarchy [(x, [a, b]),...]."""
     """Return a subhier like [[n, m],[],...], n, m string index."""
@@ -33,7 +35,7 @@ def egrep_hierarchy(hier, pattern_str, subhier=None, nth=1):
 
     for i in range(len(hier)):
         if subhier:
-            if subhier[i]: # Only if have something to match.
+            if subhier[i]:  # Only if have something to match.
                 resultlist = egrep_list(hier[i][nth], pattern_str, subhier[i])
             else:
                 resultlist = []
@@ -43,6 +45,7 @@ def egrep_hierarchy(hier, pattern_str, subhier=None, nth=1):
         resulthier.append(resultlist)
     return resulthier
 
+
 def matched_hierarchy(hier, pattern_str):
     """Actually create a new hierarchy from a pattern matching."""
     mhier = []
@@ -54,4 +57,3 @@ def matched_hierarchy(hier, pattern_str):
     return mhier
 
 # vim:ts=8:sw=4:expandtab:
-
diff --git a/reportbug/submit.py b/reportbug/submit.py
index a81aeac..8a42a4e 100644
--- a/reportbug/submit.py
+++ b/reportbug/submit.py
@@ -5,19 +5,19 @@
 #
 # This program is freely distributable per the following license:
 #
-##  Permission to use, copy, modify, and distribute this software and its
-##  documentation for any purpose and without fee is hereby granted,
-##  provided that the above copyright notice appears in all copies and that
-##  both that copyright notice and this permission notice appear in
-##  supporting documentation.
-##
-##  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-##  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
-##  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
-##  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-##  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-##  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-##  SOFTWARE.
+#  Permission to use, copy, modify, and distribute this software and its
+#  documentation for any purpose and without fee is hereby granted,
+#  provided that the above copyright notice appears in all copies and that
+#  both that copyright notice and this permission notice appear in
+#  supporting documentation.
+#
+#  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
+#  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+#  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+#  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+#  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+#  SOFTWARE.
 
 import sys
 import os
@@ -41,15 +41,16 @@ from __init__ import VERSION, VERSION_NUMBER
 from tempfiles import TempFile, open_write_safe, tempfile_prefix
 from exceptions import (
     NoMessage,
-    )
+)
 import ui.text_ui as ui
 from utils import get_email_addr
 
 quietly = False
 
-ascii_range = ''.join([chr(ai) for ai in range(32,127)])
-notascii = re.compile(r'[^'+re.escape(ascii_range)+']')
-notascii2 = re.compile(r'[^'+re.escape(ascii_range)+r'\s]')
+ascii_range = ''.join([chr(ai) for ai in range(32, 127)])
+notascii = re.compile(r'[^' + re.escape(ascii_range) + ']')
+notascii2 = re.compile(r'[^' + re.escape(ascii_range) + r'\s]')
+
 
 # Wrapper for MIMEText
 class BetterMIMEText(MIMEText):
@@ -60,6 +61,7 @@ class BetterMIMEText(MIMEText):
         if notascii2.search(_text):
             self.set_param('charset', _charset)
 
+
 def encode_if_needed(text, charset, encoding='q'):
     needed = False
 
@@ -72,28 +74,33 @@ def encode_if_needed(text, charset, encoding='q'):
     else:
         return Header(text, 'us-ascii')
 
+
 def rfc2047_encode_address(addr, charset, mua=None):
     newlist = []
     addresses = rfc822.AddressList(addr).addresslist
     for (realname, address) in addresses:
         if realname:
-            newlist.append( email.Utils.formataddr(
+            newlist.append(email.Utils.formataddr(
                 (str(rfc2047_encode_header(realname, charset, mua)), address)))
         else:
-            newlist.append( address )
+            newlist.append(address)
     return ', '.join(newlist)
 
+
 def rfc2047_encode_header(header, charset, mua=None):
-    if mua: return header
-    #print repr(header), repr(charset)
+    if mua:
+        return header
+    # print repr(header), repr(charset)
 
     return encode_if_needed(header, charset)
 
+
 # Cheat for now.
 # ewrite() may put stuff on the status bar or in message boxes depending on UI
 def ewrite(*args):
     return quietly or ui.log_message(*args)
 
+
 def sign_message(body, fromaddr, package='x', pgp_addr=None, sign='gpg', draftpath=None):
     '''Sign message with pgp key.'''
     ''' Return: a signed body.
@@ -118,10 +125,10 @@ def sign_message(body, fromaddr, package='x', pgp_addr=None, sign='gpg', draftpa
             signcmd = "gpg --local-user '%s' --clearsign " % pgp_addr
         else:
             signcmd = "gpg --local-user '%s' --use-agent --clearsign " % pgp_addr
-        signcmd += '--output '+commands.mkarg(file2)+ ' ' + commands.mkarg(file1)
+        signcmd += '--output ' + commands.mkarg(file2) + ' ' + commands.mkarg(file1)
     else:
         signcmd = "pgp -u '%s' -fast" % pgp_addr
-        signcmd += '<'+commands.mkarg(file1)+' >'+commands.mkarg(file2)
+        signcmd += '<' + commands.mkarg(file1) + ' >' + commands.mkarg(file2)
 
     try:
         os.system(signcmd)
@@ -145,6 +152,7 @@ def sign_message(body, fromaddr, package='x', pgp_addr=None, sign='gpg', draftpa
         body = None
     return body
 
+
 def mime_attach(body, attachments, charset, body_charset=None):
     mimetypes.init()
 
@@ -166,8 +174,8 @@ def mime_attach(body, attachments, charset, body_charset=None):
             continue
         ctype = None
         cset = charset
-        info = Popen(['file','--mime', '--brief', attachment],
-            stdout=PIPE, stderr=STDOUT).communicate()[0]
+        info = Popen(['file', '--mime', '--brief', attachment],
+                     stdout=PIPE, stderr=STDOUT).communicate()[0]
         if info:
             match = re.match(r'([^;, ]*)(,[^;]+)?(?:; )?(.*)', info)
             if match:
@@ -215,6 +223,7 @@ def mime_attach(body, attachments, charset, body_charset=None):
         message.attach(part)
     return (message, failed)
 
+
 def send_report(body, attachments, mua, fromaddr, sendto, ccaddr, bccaddr,
                 headers, package='x', charset="us-ascii", mailing=True,
                 sysinfo=None,
@@ -320,7 +329,7 @@ def send_report(body, attachments, mua, fromaddr, sendto, ccaddr, bccaddr,
             msgname = '/var/tmp/%s.bug' % package
         if os.path.exists(msgname):
             try:
-                os.rename(msgname, msgname+'~')
+                os.rename(msgname, msgname + '~')
             except OSError:
                 ewrite('Unable to rename existing %s as %s~\n',
                        msgname, msgname)
@@ -351,7 +360,7 @@ def send_report(body, attachments, mua, fromaddr, sendto, ccaddr, bccaddr,
             envfrom = faddr
         ewrite("Sending message via %s...\n", mta)
         pipe = os.popen('%s -f %s -oi -oem %s' % (
-                mta, commands.mkarg(envfrom), jalist), 'w')
+            mta, commands.mkarg(envfrom), jalist), 'w')
         using_sendmail = True
 
     if smtphost:
@@ -369,8 +378,8 @@ def send_report(body, attachments, mua, fromaddr, sendto, ccaddr, bccaddr,
                 # if we're using reportbug.debian.org, send mail to
                 # submit
                 if smtphost.lower() == 'reportbug.debian.org':
-                    conn = smtplib.SMTP(smtphost,587)
-                else: 
+                    conn = smtplib.SMTP(smtphost, 587)
+                else:
                     conn = smtplib.SMTP(smtphost)
                 response = conn.ehlo()
                 if not (200 <= response[0] <= 299):
@@ -401,8 +410,9 @@ def send_report(body, attachments, mua, fromaddr, sendto, ccaddr, bccaddr,
                         tryagain = False
 
                 # In case of failure, ask to retry or to save & exit
-                if ui.yes_no('SMTP send failure: %s. Do you want to retry (or else save the report and exit)?' % x, 'Yes, please retry.',
-                         'No, save and exit.'):
+                if ui.yes_no('SMTP send failure: %s. Do you want to retry (or else save the report and exit)?' % x,
+                             'Yes, please retry.',
+                             'No, save and exit.'):
                     tryagain = True
                     continue
                 else:
@@ -451,8 +461,8 @@ def send_report(body, attachments, mua, fromaddr, sendto, ccaddr, bccaddr,
                 ewrite("Mutt users should be aware it is mandatory to edit the draft before sending.\n")
                 mtitle = 'Report has not been sent yet; what do you want to do now?'
                 mopts = 'Eq'
-                moptsdesc = {'e' : 'Edit the message.',
-                'q' : 'Quit reportbug; will save the draft for future use.'}
+                moptsdesc = {'e': 'Edit the message.',
+                             'q': 'Quit reportbug; will save the draft for future use.'}
                 x = ui.select_options(mtitle, mopts, moptsdesc)
                 if x == 'q':
                     failed = True
diff --git a/reportbug/tempfiles.py b/reportbug/tempfiles.py
index 10b6cdc..2f1b63f 100644
--- a/reportbug/tempfiles.py
+++ b/reportbug/tempfiles.py
@@ -6,24 +6,25 @@
 #
 # This program is freely distributable per the following license:
 #
-##  Permission to use, copy, modify, and distribute this software and its
-##  documentation for any purpose and without fee is hereby granted,
-##  provided that the above copyright notice appears in all copies and that
-##  both that copyright notice and this permission notice appear in
-##  supporting documentation.
-##
-##  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-##  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
-##  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
-##  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-##  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-##  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-##  SOFTWARE.
+#  Permission to use, copy, modify, and distribute this software and its
+#  documentation for any purpose and without fee is hereby granted,
+#  provided that the above copyright notice appears in all copies and that
+#  both that copyright notice and this permission notice appear in
+#  supporting documentation.
+#
+#  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
+#  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+#  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+#  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+#  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+#  SOFTWARE.
 
 import os
 import tempfile
 import time
 
+
 def tempfile_prefix(package=None, extra=None):
     if extra:
         if package:
@@ -36,6 +37,7 @@ def tempfile_prefix(package=None, extra=None):
             package, time.strftime('%Y%m%d'), os.getpid())
     return 'reportbug-%s-%d-' % (time.strftime('%Y%m%d'), os.getpid())
 
+
 template = tempfile_prefix()
 
 # Derived version of mkstemp that returns a Python file object
@@ -49,6 +51,7 @@ _bin_openflags = _text_openflags
 if hasattr(os, 'O_BINARY'):
     _bin_openflags |= os.O_BINARY
 
+
 # Safe open, prevents filename races in shared tmp dirs
 # Based on python-1.5.2/Lib/tempfile.py
 def open_write_safe(filename, mode='w+b', bufsize=-1):
@@ -63,6 +66,7 @@ def open_write_safe(filename, mode='w+b', bufsize=-1):
         os.close(fd)
         raise
 
+
 # Wrapper for mkstemp; main difference is that text defaults to True, and it
 # returns a Python file object instead of an os-level file descriptor
 def TempFile(suffix="", prefix=template, dir=None, text=True,
@@ -71,6 +75,7 @@ def TempFile(suffix="", prefix=template, dir=None, text=True,
     fd = os.fdopen(fh, mode, bufsize)
     return (fd, filename)
 
+
 def cleanup_temp_file(temp_filename):
     """ Clean up a temporary file.
 
diff --git a/reportbug/ui/__init__.py b/reportbug/ui/__init__.py
index e945f31..11ad80a 100644
--- a/reportbug/ui/__init__.py
+++ b/reportbug/ui/__init__.py
@@ -7,19 +7,19 @@
 #
 # This program is freely distributable per the following license:
 #
-##  Permission to use, copy, modify, and distribute this software and its
-##  documentation for any purpose and without fee is hereby granted,
-##  provided that the above copyright notice appears in all copies and that
-##  both that copyright notice and this permission notice appear in
-##  supporting documentation.
-##
-##  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-##  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
-##  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
-##  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-##  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-##  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-##  SOFTWARE.
+#  Permission to use, copy, modify, and distribute this software and its
+#  documentation for any purpose and without fee is hereby granted,
+#  provided that the above copyright notice appears in all copies and that
+#  both that copyright notice and this permission notice appear in
+#  supporting documentation.
+#
+#  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
+#  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+#  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+#  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+#  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+#  SOFTWARE.
 
 
 __all__ = ['text_ui', 'urwid_ui', 'gtk2_ui']
@@ -37,9 +37,9 @@ __LOADED_UIS = {}
 for uis in UIS.keys():
     try:
         # let's try to import the ui...
-        ui_module = __import__('reportbug.ui', fromlist=[uis+'_ui'])
+        ui_module = __import__('reportbug.ui', fromlist=[uis + '_ui'])
         # ... and check if it's really imported
-        ui = getattr(ui_module, uis+'_ui')
+        ui = getattr(ui_module, uis + '_ui')
         # then we can finally add it to AVAILABLE_UIS
         AVAILABLE_UIS[uis] = UIS[uis]
         __LOADED_UIS[uis] = ui
@@ -47,10 +47,11 @@ for uis in UIS.keys():
         # we can't import uis, so just skip it
         pass
 
+
 def getUI(ui):
     """Returns the requested UI, or default to text if not available"""
 
-    if __LOADED_UIS.has_key(ui):
+    if ui in __LOADED_UIS:
         print "loading %s" % ui
         return __LOADED_UIS[ui]
     else:
diff --git a/reportbug/ui/gtk2_ui.py b/reportbug/ui/gtk2_ui.py
index 043bc8c..329b9f3 100644
--- a/reportbug/ui/gtk2_ui.py
+++ b/reportbug/ui/gtk2_ui.py
@@ -6,26 +6,26 @@
 #
 # This program is freely distributable per the following license:
 #
-##  Permission to use, copy, modify, and distribute this software and its
-##  documentation for any purpose and without fee is hereby granted,
-##  provided that the above copyright notice appears in all copies and that
-##  both that copyright notice and this permission notice appear in
-##  supporting documentation.
-##
-##  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-##  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
-##  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
-##  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-##  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-##  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-##  SOFTWARE.
+#  Permission to use, copy, modify, and distribute this software and its
+#  documentation for any purpose and without fee is hereby granted,
+#  provided that the above copyright notice appears in all copies and that
+#  both that copyright notice and this permission notice appear in
+#  supporting documentation.
+#
+#  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
+#  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+#  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+#  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+#  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+#  SOFTWARE.
 
 try:
     import gtk
     import gobject
     import pango
 except ImportError:
-    raise UINotImportable, 'Please install the python-gtk2 package to use this interface.'
+    raise UINotImportable('Please install the python-gtk2 package to use this interface.')
 
 global vte
 
@@ -35,8 +35,8 @@ try:
 except:
     has_spell = False
 
-gtk.set_interactive (0)
-gtk.gdk.threads_init ()
+gtk.set_interactive(0)
+gtk.gdk.threads_init()
 
 import sys
 import re
@@ -57,160 +57,170 @@ global application, assistant, report_message
 
 # Utilities
 
-def highlight (s):
+
+def highlight(s):
     return '<b>%s</b>' % s
 
-re_markup_free = re.compile ("<.*?>")
+re_markup_free = re.compile("<.*?>")
+
 
-def markup_free (s):
-    return re_markup_free.sub ("", s)
+def markup_free(s):
+    return re_markup_free.sub("", s)
 
-def ask_free (s):
-    s = s.strip ()
-    if s[-1] in ('?', ':'):
+
+def ask_free(s):
+    s = s.strip()
+    if s[-1] in('?', ':'):
         return s[:-1]
     return s
 
-def create_scrollable (widget, with_viewport=False):
-    scrolled = gtk.ScrolledWindow ()
-    scrolled.set_shadow_type (gtk.SHADOW_ETCHED_IN)
-    scrolled.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
+
+def create_scrollable(widget, with_viewport=False):
+    scrolled = gtk.ScrolledWindow()
+    scrolled.set_shadow_type(gtk.SHADOW_ETCHED_IN)
+    scrolled.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
     if with_viewport:
-        scrolled.add_with_viewport (widget)
+        scrolled.add_with_viewport(widget)
     else:
-        scrolled.add (widget)
+        scrolled.add(widget)
     return scrolled
 
-def info_dialog (message):
-    dialog = gtk.MessageDialog (assistant, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
-                                gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, message)
-    dialog.connect ('response', lambda d, *args: d.destroy ())
-    dialog.set_title ('Reportbug')
-    dialog.show_all ()
-
-def error_dialog (message):
-    dialog = gtk.MessageDialog (assistant, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
-                                gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, message)
-    dialog.connect ('response', lambda d, *args: d.destroy ())
-    dialog.set_title ('Reportbug')
-    dialog.show_all ()
-
-class CustomDialog (gtk.Dialog):
-    def __init__ (self, stock_image, message, buttons, *args, **kwargs):
-        gtk.Dialog.__init__ (self, "Reportbug", assistant,
-                             gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
-                             buttons)
+
+def info_dialog(message):
+    dialog = gtk.MessageDialog(assistant, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+                               gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, message)
+    dialog.connect('response', lambda d, *args: d.destroy())
+    dialog.set_title('Reportbug')
+    dialog.show_all()
+
+
+def error_dialog(message):
+    dialog = gtk.MessageDialog(assistant, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+                               gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, message)
+    dialog.connect('response', lambda d, *args: d.destroy())
+    dialog.set_title('Reportbug')
+    dialog.show_all()
+
+
+class CustomDialog(gtk.Dialog):
+    def __init__(self, stock_image, message, buttons, *args, **kwargs):
+        gtk.Dialog.__init__(self, "Reportbug", assistant,
+                            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+                            buttons)
         # Try following the HIG
-        self.set_default_response (buttons[-1]) # this is the response of the last button
-        self.set_border_width (5)
+        self.set_default_response(buttons[-1])  # this is the response of the last button
+        self.set_border_width(5)
+
+        vbox = gtk.VBox(spacing=10)
+        vbox.set_border_width(6)
+        self.vbox.pack_start(vbox)
 
-        vbox = gtk.VBox (spacing=10)
-        vbox.set_border_width (6)
-        self.vbox.pack_start (vbox)
-        
         # The header image + label
-        hbox = gtk.HBox (spacing=10)
-        vbox.pack_start (hbox, expand=False)
-
-        align = gtk.Alignment (0.5, 0.5, 1.0, 1.0)
-        hbox.pack_start (align, expand=False)
-
-        image = gtk.image_new_from_stock (stock_image, gtk.ICON_SIZE_DIALOG)
-        hbox.pack_start (image)
-        
-        label = gtk.Label (message)
-        label.set_line_wrap (True)
-        label.set_justify (gtk.JUSTIFY_FILL)
-        label.set_selectable (True)
-        label.set_property ("can-focus", False)
-        hbox.pack_start (label, expand=False)
-
-        self.setup_dialog (vbox, *args, **kwargs)
-
-class InputStringDialog (CustomDialog):
-    def __init__ (self, message):
-        CustomDialog.__init__ (self, gtk.STOCK_DIALOG_INFO, message,
-                               (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
-                                gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
-
-    def setup_dialog (self, vbox):
-        self.entry = gtk.Entry ()
-        vbox.pack_start (self.entry, expand=False)
-
-    def get_value (self):
-        return self.entry.get_text ()
-
-class ExceptionDialog (CustomDialog):
+        hbox = gtk.HBox(spacing=10)
+        vbox.pack_start(hbox, expand=False)
+
+        align = gtk.Alignment(0.5, 0.5, 1.0, 1.0)
+        hbox.pack_start(align, expand=False)
+
+        image = gtk.image_new_from_stock(stock_image, gtk.ICON_SIZE_DIALOG)
+        hbox.pack_start(image)
+
+        label = gtk.Label(message)
+        label.set_line_wrap(True)
+        label.set_justify(gtk.JUSTIFY_FILL)
+        label.set_selectable(True)
+        label.set_property("can-focus", False)
+        hbox.pack_start(label, expand=False)
+
+        self.setup_dialog(vbox, *args, **kwargs)
+
+
+class InputStringDialog(CustomDialog):
+    def __init__(self, message):
+        CustomDialog.__init__(self, gtk.STOCK_DIALOG_INFO, message,
+                              (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+                               gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
+
+    def setup_dialog(self, vbox):
+        self.entry = gtk.Entry()
+        vbox.pack_start(self.entry, expand=False)
+
+    def get_value(self):
+        return self.entry.get_text()
+
+
+class ExceptionDialog(CustomDialog):
     # Register an exception hook to display an error when the GUI breaks
     @classmethod
-    def create_excepthook (cls, oldhook):
-        def excepthook (exctype, value, tb):
+    def create_excepthook(cls, oldhook):
+        def excepthook(exctype, value, tb):
             if oldhook:
-                oldhook (exctype, value, tb)
-            application.run_once_in_main_thread (cls.start_dialog,
-                                                 ''.join (traceback.format_exception (exctype, value, tb)))
+                oldhook(exctype, value, tb)
+            application.run_once_in_main_thread(cls.start_dialog,
+                                                ''.join(traceback.format_exception(exctype, value, tb)))
         return excepthook
 
     @classmethod
-    def start_dialog (cls, tb):
+    def start_dialog(cls, tb):
         try:
-            dialog = cls (tb)
-            dialog.show_all ()
+            dialog = cls(tb)
+            dialog.show_all()
         except:
-            sys.exit (1)
+            sys.exit(1)
 
-    def __init__ (self, tb):
-        CustomDialog.__init__ (self, gtk.STOCK_DIALOG_ERROR, "An error has occurred while doing an operation in Reportbug.\nPlease report the bug.", (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE), tb)
+    def __init__(self, tb):
+        CustomDialog.__init__(self, gtk.STOCK_DIALOG_ERROR, "An error has occurred while doing an operation in Reportbug.\nPlease report the bug.", (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE), tb)
 
-    def setup_dialog (self, vbox, tb):
+    def setup_dialog(self, vbox, tb):
         # The traceback
-        expander = gtk.Expander ("More details")
-        vbox.pack_start (expander, True)
-
-        view = gtk.TextView ()
-        view.set_editable (False)
-        view.get_buffer().set_text (tb)
-        scrolled = create_scrollable (view)
-        expander.add (scrolled)
-
-        self.connect ('response', self.on_response)
-
-    def on_response (self, dialog, res):
-        sys.exit (1)
-
-class ReportViewerDialog (gtk.Dialog):
-    def __init__ (self, message):
-        gtk.Dialog.__init__ (self, "Reportbug", assistant,
-                             gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
-                             (gtk.STOCK_COPY, gtk.RESPONSE_APPLY,
-                              gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
+        expander = gtk.Expander("More details")
+        vbox.pack_start(expander, True)
+
+        view = gtk.TextView()
+        view.set_editable(False)
+        view.get_buffer().set_text(tb)
+        scrolled = create_scrollable(view)
+        expander.add(scrolled)
+
+        self.connect('response', self.on_response)
+
+    def on_response(self, dialog, res):
+        sys.exit(1)
+
+
+class ReportViewerDialog(gtk.Dialog):
+    def __init__(self, message):
+        gtk.Dialog.__init__(self, "Reportbug", assistant,
+                            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+                            (gtk.STOCK_COPY, gtk.RESPONSE_APPLY,
+                             gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
         self.message = message
 
-        self.set_default_size (400, 400)
-        self.set_default_response (gtk.RESPONSE_CLOSE)
-        self.set_border_width (6)
-        self.connect ('response', self.on_response)
+        self.set_default_size(400, 400)
+        self.set_default_response(gtk.RESPONSE_CLOSE)
+        self.set_border_width(6)
+        self.connect('response', self.on_response)
 
-        view = gtk.TextView ()
-        view.get_buffer().set_text (self.message)
-        self.vbox.pack_start (create_scrollable (view))
+        view = gtk.TextView()
+        view.get_buffer().set_text(self.message)
+        self.vbox.pack_start(create_scrollable(view))
 
-        self.show_all ()
+        self.show_all()
 
-    def on_response (self, dialog, res):
+    def on_response(self, dialog, res):
         # ok gtk.RESPONSE_APPLY is ugly for gtk.STOCK_COPY, but who cares?
         # maybe adding it as a secondary button or such is better
         if res == gtk.RESPONSE_APPLY:
-            clipboard = gtk.clipboard_get ()
-            clipboard.set_text (self.message)
+            clipboard = gtk.clipboard_get()
+            clipboard.set_text(self.message)
         else:
-            self.destroy ()
+            self.destroy()
 
-# BTS
 
-class Bug (object):
+# BTS
+class Bug(object):
     """Encapsulate a bug report for the GTK+ UI"""
-    def __init__ (self, bug):
+    def __init__(self, bug):
         self.id = bug.bug_num
         self.tag = u', '.join(bug.tags)
         self.package = bug.package
@@ -223,7 +233,7 @@ class Bug (object):
         self.modified_date = bug.log_modified
         self.info = bug.subject
 
-    def __iter__ (self):
+    def __iter__(self):
         yield self.id
         yield self.tag
         yield self.package
@@ -236,53 +246,54 @@ class Bug (object):
         yield self.filed_date
         yield self.modified_date
 
-class BugReport (object):
-    def __init__ (self, message):
-        lines = message.split ('\n')
+
+class BugReport(object):
+    def __init__(self, message):
+        lines = message.split('\n')
         i = 0
 
         self.headers = []
-        while i < len (lines):
+        while i < len(lines):
             line = lines[i]
             i += 1
-            if not line.strip ():
+            if not line.strip():
                 break
-            self.headers.append (line)
+            self.headers.append(line)
 
         store = 0
         info = []
-        while i < len (lines):
+        while i < len(lines):
             line = lines[i]
-            info.append (line)
+            info.append(line)
             i += 1
             if store < 2 and not line.strip():
                 store += 1
                 continue
-            if store == 2 and (line.startswith ('-- ') or line.startswith ('** ')):
+            if store == 2 and(line.startswith('-- ') or line.startswith('** ')):
                 break
             store = 0
-        self.original_info = '\n'.join (info[:-3])
+        self.original_info = '\n'.join(info[:-3])
 
-        self.others = '\n'.join (lines[i-1:])
+        self.others = '\n'.join(lines[i - 1:])
 
-    def get_others (self):
+    def get_others(self):
         return self.others
 
-    def get_original_info (self):
+    def get_original_info(self):
         return self.original_info
 
-    def get_subject (self):
+    def get_subject(self):
         for header in self.headers:
             if 'Subject' in header:
-                return header[len ('Subject: '):]
+                return header[len('Subject: '):]
 
-    def set_subject (self, subject):
-        for i in range (len (self.headers)):
+    def set_subject(self, subject):
+        for i in range(len(self.headers)):
             if 'Subject' in self.headers[i]:
-                self.headers[i] = 'Subject: '+subject
+                self.headers[i] = 'Subject: ' + subject
                 break
 
-    def wrap_bug_body (self, msg, width=79, break_long_words=False):
+    def wrap_bug_body(self, msg, width=79, break_long_words=False):
         """Wrap every line in the message"""
 
         # resulting body text
@@ -296,28 +307,28 @@ class BugReport (object):
             if tmp == []:
                 body += '\n'
             else:
-                # join the "sub-lines" and add a \n at the end (if there is
+                # join the "sub-lines" and add a \n at the end(if there is
                 # only one item in the list, else there wouldn't be a \n)
                 body += '\n'.join(tmp) + '\n'
 
         return body
 
-    def create_message (self, info):
+    def create_message(self, info):
         message = """%s
 
 %s
 
 
-%s""" % ('\n'.join (self.headers), self.wrap_bug_body (info), self.others)
+%s""" % ('\n'.join(self.headers), self.wrap_bug_body(info), self.others)
         return message
 
-# BTS GUI
 
-class BugPage (gtk.EventBox, threading.Thread):
-    def __init__ (self, assistant, dialog, number, queryonly, bts, mirrors, http_proxy, timeout, archived):
-        threading.Thread.__init__ (self)
-        gtk.EventBox.__init__ (self)
-        self.setDaemon (True)
+# BTS GUI
+class BugPage(gtk.EventBox, threading.Thread):
+    def __init__(self, assistant, dialog, number, queryonly, bts, mirrors, http_proxy, timeout, archived):
+        threading.Thread.__init__(self)
+        gtk.EventBox.__init__(self)
+        self.setDaemon(True)
 
         self.dialog = dialog
         self.assistant = assistant
@@ -332,528 +343,539 @@ class BugPage (gtk.EventBox, threading.Thread):
 
         self.bug_status = None
 
-        vbox = gtk.VBox (spacing=12)
-        vbox.pack_start (gtk.Label ("Retrieving bug information."), expand=False)
+        vbox = gtk.VBox(spacing=12)
+        vbox.pack_start(gtk.Label("Retrieving bug information."), expand=False)
 
-        self.progress = gtk.ProgressBar ()
-        self.progress.set_pulse_step (0.01)
-        vbox.pack_start (self.progress, expand=False)
+        self.progress = gtk.ProgressBar()
+        self.progress.set_pulse_step(0.01)
+        vbox.pack_start(self.progress, expand=False)
 
-        self.add (vbox)
+        self.add(vbox)
 
-    def run (self):
+    def run(self):
         # Start the progress bar
-        gobject.timeout_add (10, self.pulse)
+        gobject.timeout_add(10, self.pulse)
 
-        info = debbugs.get_report (int (self.number), self.timeout,
-                                     self.bts, mirrors=self.mirrors,
-                                     http_proxy=self.http_proxy, archived=self.archived)
+        info = debbugs.get_report(int(self.number), self.timeout,
+                                  self.bts, mirrors=self.mirrors,
+                                  http_proxy=self.http_proxy, archived=self.archived)
         if not info:
-            self.application.run_once_in_main_thread (self.not_found)
+            self.application.run_once_in_main_thread(self.not_found)
         else:
             self.bug_status = info[0]
-            self.application.run_once_in_main_thread (self.found, info)
+            self.application.run_once_in_main_thread(self.found, info)
 
-    def drop_progressbar (self):
-        child = self.get_child ()
+    def drop_progressbar(self):
+        child = self.get_child()
         if child:
-            self.remove (child)
-            child.unparent ()
-
-    def pulse (self):
-        self.progress.pulse ()
-        return self.isAlive ()
-
-    def not_found (self):
-        self.drop_progressbar ()
-        self.add (gtk.Label ("The bug can't be fetched or it doesn't exist."))
-        self.show_all ()
-        
-    def found (self, info):
-        self.drop_progressbar ()
+            self.remove(child)
+            child.unparent()
+
+    def pulse(self):
+        self.progress.pulse()
+        return self.isAlive()
+
+    def not_found(self):
+        self.drop_progressbar()
+        self.add(gtk.Label("The bug can't be fetched or it doesn't exist."))
+        self.show_all()
+
+    def found(self, info):
+        self.drop_progressbar()
         desc = info[0].subject
         bodies = info[1]
-        vbox = gtk.VBox (spacing=12)
-        vbox.set_border_width (12)
-        label = gtk.Label ('Description: '+desc)
-        label.set_line_wrap (True)
-        label.set_justify (gtk.JUSTIFY_FILL)
-        vbox.pack_start (label, expand=False)
-
-        views = gtk.VBox ()
+        vbox = gtk.VBox(spacing=12)
+        vbox.set_border_width(12)
+        label = gtk.Label('Description: ' + desc)
+        label.set_line_wrap(True)
+        label.set_justify(gtk.JUSTIFY_FILL)
+        vbox.pack_start(label, expand=False)
+
+        views = gtk.VBox()
         odd = False
         for body in bodies:
-            view = gtk.TextView ()
-            view.set_editable (False)
-            view.get_buffer().set_text (body)
+            view = gtk.TextView()
+            view.set_editable(False)
+            view.get_buffer().set_text(body)
             if odd:
-                view.set_state (gtk.STATE_PRELIGHT)
-            views.pack_start (view, False)
+                view.set_state(gtk.STATE_PRELIGHT)
+            views.pack_start(view, False)
             odd = not odd
-        scrolled = create_scrollable (views, True)
-        vbox.pack_start (scrolled)
+        scrolled = create_scrollable(views, True)
+        vbox.pack_start(scrolled)
 
-        bbox = gtk.HButtonBox ()
-        button = gtk.Button ("Open in browser")
-        button.connect ('clicked', self.on_open_browser)
-        bbox.pack_start (button)
+        bbox = gtk.HButtonBox()
+        button = gtk.Button("Open in browser")
+        button.connect('clicked', self.on_open_browser)
+        bbox.pack_start(button)
         if not self.queryonly:
-            button = gtk.Button ("Reply")
-            button.set_image (gtk.image_new_from_stock (gtk.STOCK_EDIT, gtk.ICON_SIZE_BUTTON))
-            button.connect ('clicked', self.on_reply)
-            bbox.pack_start (button)
-        vbox.pack_start (bbox, expand=False)
-
-        self.add (vbox)
-        self.show_all ()
-            
-    def on_open_browser (self, button):
-        launch_browser (debbugs.get_report_url (self.bts, int (self.number), self.archived))
-
-    def on_reply (self, button):
+            button = gtk.Button("Reply")
+            button.set_image(gtk.image_new_from_stock(gtk.STOCK_EDIT, gtk.ICON_SIZE_BUTTON))
+            button.connect('clicked', self.on_reply)
+            bbox.pack_start(button)
+        vbox.pack_start(bbox, expand=False)
+
+        self.add(vbox)
+        self.show_all()
+
+    def on_open_browser(self, button):
+        launch_browser(debbugs.get_report_url(self.bts, int(self.number), self.archived))
+
+    def on_reply(self, button):
         # Return the bug number to reportbug
-        self.application.set_next_value (self.bug_status)
+        self.application.set_next_value(self.bug_status)
         # Forward the assistant to the progress bar
-        self.assistant.forward_page ()
+        self.assistant.forward_page()
         # Though we're only a page, we are authorized to destroy our parent :)
         # This would be better handled connecting externally to self.reply_button
-        self.dialog.destroy ()
+        self.dialog.destroy()
+
 
-class BugsDialog (gtk.Dialog):
-    def __init__ (self, assistant, queryonly):
-        gtk.Dialog.__init__ (self, "Reportbug: bug information", assistant,
-                             gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
-                             (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
+class BugsDialog(gtk.Dialog):
+    def __init__(self, assistant, queryonly):
+        gtk.Dialog.__init__(self, "Reportbug: bug information", assistant,
+                            gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+                            (gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
         self.assistant = assistant
         self.queryonly = queryonly
         self.application = assistant.application
-        self.notebook = gtk.Notebook ()
-        self.vbox.pack_start (self.notebook)
-        self.connect ('response', self.on_response)
-        self.set_default_size (600, 600)
-
-    def on_response (self, *args):
-        self.destroy ()
-
-    def show_bug (self, number, *args):
-        page = BugPage (self.assistant, self, number, self.queryonly, *args)
-        self.notebook.append_page (page, gtk.Label (number))
-        page.start ()
-        
-# Application
+        self.notebook = gtk.Notebook()
+        self.vbox.pack_start(self.notebook)
+        self.connect('response', self.on_response)
+        self.set_default_size(600, 600)
+
+    def on_response(self, *args):
+        self.destroy()
+
+    def show_bug(self, number, *args):
+        page = BugPage(self.assistant, self, number, self.queryonly, *args)
+        self.notebook.append_page(page, gtk.Label(number))
+        page.start()
 
-class ReportbugApplication (threading.Thread):
-    def __init__ (self):
-        threading.Thread.__init__ (self)
-        self.setDaemon (True)
 
-        self.queue = Queue ()
+# Application
+class ReportbugApplication(threading.Thread):
+    def __init__(self):
+        threading.Thread.__init__(self)
+        self.setDaemon(True)
+
+        self.queue = Queue()
         self.next_value = None
-        
-    def run (self):
-        gtk.gdk.threads_enter ()
-        gtk.main ()
-        gtk.gdk.threads_leave ()
 
-    def get_last_value (self):
-        return self.queue.get ()
+    def run(self):
+        gtk.gdk.threads_enter()
+        gtk.main()
+        gtk.gdk.threads_leave()
+
+    def get_last_value(self):
+        return self.queue.get()
 
-    def put_next_value (self):
-        self.queue.put (self.next_value)
+    def put_next_value(self):
+        self.queue.put(self.next_value)
         self.next_value = None
-    
-    def set_next_value (self, value):
+
+    def set_next_value(self, value):
         self.next_value = value
 
     @staticmethod
-    def create_idle_callback (func, *args, **kwargs):
-        def callback ():
-            func (*args, **kwargs)
+    def create_idle_callback(func, *args, **kwargs):
+        def callback():
+            func(*args, **kwargs)
             return False
         return callback
 
-    def run_once_in_main_thread (self, func, *args, **kwargs):
-        gobject.idle_add (self.create_idle_callback (func, *args, **kwargs))
+    def run_once_in_main_thread(self, func, *args, **kwargs):
+        gobject.idle_add(self.create_idle_callback(func, *args, **kwargs))
 
-# Connection with reportbug
 
+# Connection with reportbug
 # Syncronize "pipe" with reportbug
-
-class SyncReturn (RuntimeError):
-    def __init__ (self, result):
-        RuntimeError.__init__ (self, result)
+class SyncReturn(RuntimeError):
+    def __init__(self, result):
+        RuntimeError.__init__(self, result)
         self.result = result
 
-class ReportbugConnector (object):
+
+class ReportbugConnector(object):
     # Executed in the glib thread
-    def execute_operation (self, *args, **kwargs):
+    def execute_operation(self, *args, **kwargs):
         pass
 
-    # Executed in sync with reportbug. raise SyncResult (value) to directly return to reportbug
+    # Executed in sync with reportbug. raise SyncResult(value) to directly return to reportbug
     # Returns args and kwargs to pass to execute_operation
-    def sync_pre_operation (cls, *args, **kwargs):
+    def sync_pre_operation(cls, *args, **kwargs):
         return args, kwargs
-        
-# Assistant
 
-class Page (ReportbugConnector):
+
+# Assistant
+class Page(ReportbugConnector):
     next_page_num = 0
     page_type = gtk.ASSISTANT_PAGE_CONTENT
     default_complete = False
     side_image = DEBIAN_LOGO
-    WARNING_COLOR = gtk.gdk.color_parse ("#fff8ae")
+    WARNING_COLOR = gtk.gdk.color_parse("#fff8ae")
 
-    def __init__ (self, assistant):
+    def __init__(self, assistant):
         self.assistant = assistant
         self.application = assistant.application
-        self.widget = self.create_widget ()
+        self.widget = self.create_widget()
         self.widget.page = self
-        self.widget.set_border_width (6)
-        self.widget.show_all ()
+        self.widget.set_border_width(6)
+        self.widget.show_all()
         self.page_num = Page.next_page_num
 
-    def execute_operation (self, *args, **kwargs):
-        self.switch_in ()
-        self.connect_signals ()
-        self.empty_ok = kwargs.pop ('empty_ok', False)
-        self.presubj = kwargs.pop ('presubj', False)
-        self.execute (*args, **kwargs)
-        self.assistant.show ()
-        self.setup_focus ()
+    def execute_operation(self, *args, **kwargs):
+        self.switch_in()
+        self.connect_signals()
+        self.empty_ok = kwargs.pop('empty_ok', False)
+        self.presubj = kwargs.pop('presubj', False)
+        self.execute(*args, **kwargs)
+        self.assistant.show()
+        self.setup_focus()
 
-    def connect_signals (self):
+    def connect_signals(self):
         pass
 
-    def set_page_complete (self, complete):
-        self.assistant.set_page_complete (self.widget, complete)
+    def set_page_complete(self, complete):
+        self.assistant.set_page_complete(self.widget, complete)
 
-    def set_page_type (self, type):
-        self.assistant.set_page_type (self.widget, type)
+    def set_page_type(self, type):
+        self.assistant.set_page_type(self.widget, type)
 
-    def set_page_title (self, title):
+    def set_page_title(self, title):
         if title:
-            self.assistant.set_page_title (self.widget, title)
+            self.assistant.set_page_title(self.widget, title)
 
     # The user will see this as next page
-    def switch_in (self):
+    def switch_in(self):
         Page.next_page_num += 1
-        self.assistant.insert_page (self.widget, self.page_num)
-        self.set_page_complete (self.default_complete)
-        self.set_page_type (self.page_type)
-        self.assistant.set_page_side_image (self.widget, gtk.gdk.pixbuf_new_from_file (self.side_image))
-        self.assistant.set_next_page (self)
-        self.set_page_title ("Reportbug")
+        self.assistant.insert_page(self.widget, self.page_num)
+        self.set_page_complete(self.default_complete)
+        self.set_page_type(self.page_type)
+        self.assistant.set_page_side_image(self.widget, gtk.gdk.pixbuf_new_from_file(self.side_image))
+        self.assistant.set_next_page(self)
+        self.set_page_title("Reportbug")
 
     # Setup keyboard focus in the page
-    def setup_focus (self):
-        self.widget.grab_focus ()
+    def setup_focus(self):
+        self.widget.grab_focus()
 
-    # Forward page when a widget is activated (e.g. GtkEntry) only if page is complete
-    def activate_forward (self, *args):
-        if self.assistant.get_page_complete (self.widget):
-            self.assistant.forward_page ()
+    # Forward page when a widget is activated(e.g. GtkEntry) only if page is complete
+    def activate_forward(self, *args):
+        if self.assistant.get_page_complete(self.widget):
+            self.assistant.forward_page()
 
     # The user forwarded the assistant to see the next page
-    def switch_out (self):
+    def switch_out(self):
         pass
 
-    def is_valid (self, value):
+    def is_valid(self, value):
         if self.empty_ok:
             return True
         else:
-            return bool (value)
+            return bool(value)
 
-    def validate (self, *args, **kwargs):
-        value = self.get_value ()
-        if self.is_valid (value):
-            self.application.set_next_value (value)
-            self.set_page_complete (True)
+    def validate(self, *args, **kwargs):
+        value = self.get_value()
+        if self.is_valid(value):
+            self.application.set_next_value(value)
+            self.set_page_complete(True)
         else:
-            self.set_page_complete (False)
+            self.set_page_complete(False)
 
-class IntroPage (Page):
+
+class IntroPage(Page):
     page_type = gtk.ASSISTANT_PAGE_INTRO
     default_complete = True
 
-    def create_widget (self):
-        vbox = gtk.VBox (spacing=24)
+    def create_widget(self):
+        vbox = gtk.VBox(spacing=24)
 
-        label = gtk.Label ("""
+        label = gtk.Label("""
 <b>Reportbug</b> is a tool designed to make the reporting of bugs in Debian and derived distributions relatively painless.
 
 This wizard will guide you through the bug reporting process step by step.
 
-<b>Note:</b> bug reports are publicly archived (including the email address of the submitter).""")
-        label.set_use_markup (True)
-        label.set_line_wrap (True)
-        label.set_justify (gtk.JUSTIFY_FILL)
-        vbox.pack_start (label, expand=False)
+<b>Note:</b> bug reports are publicly archived(including the email address of the submitter).""")
+        label.set_use_markup(True)
+        label.set_line_wrap(True)
+        label.set_justify(gtk.JUSTIFY_FILL)
+        vbox.pack_start(label, expand=False)
 
-        link = gtk.LinkButton ("http://alioth.debian.org/projects/reportbug",
-                               "Homepage of reportbug project")
-        vbox.pack_start (link, expand=False)
+        link = gtk.LinkButton("http://alioth.debian.org/projects/reportbug",
+                              "Homepage of reportbug project")
+        vbox.pack_start(link, expand=False)
         return vbox
 
-class GetStringPage (Page):
-    def setup_focus (self):
-        self.entry.grab_focus ()
-
-    def create_widget (self):
-        vbox = gtk.VBox (spacing=12)
-        self.label = gtk.Label ()
-        self.label.set_line_wrap (True)
-        self.label.set_justify (gtk.JUSTIFY_FILL)
-        self.label.set_selectable (True)
-        self.label.set_property ("can-focus", False)
-        self.entry = gtk.Entry ()
-        vbox.pack_start (self.label, expand=False)
-        vbox.pack_start (self.entry, expand=False)
+
+class GetStringPage(Page):
+    def setup_focus(self):
+        self.entry.grab_focus()
+
+    def create_widget(self):
+        vbox = gtk.VBox(spacing=12)
+        self.label = gtk.Label()
+        self.label.set_line_wrap(True)
+        self.label.set_justify(gtk.JUSTIFY_FILL)
+        self.label.set_selectable(True)
+        self.label.set_property("can-focus", False)
+        self.entry = gtk.Entry()
+        vbox.pack_start(self.label, expand=False)
+        vbox.pack_start(self.entry, expand=False)
         return vbox
 
-    def connect_signals (self):
-        self.entry.connect ('changed', self.validate)
-        self.entry.connect ('activate', self.activate_forward)
+    def connect_signals(self):
+        self.entry.connect('changed', self.validate)
+        self.entry.connect('activate', self.activate_forward)
 
-    def get_value (self):
-        return self.entry.get_text ()
+    def get_value(self):
+        return self.entry.get_text()
 
-    def execute (self, prompt, options=None, force_prompt=False, default=''):
+    def execute(self, prompt, options=None, force_prompt=False, default=''):
         # Hackish: remove the text needed for textual UIs...
-        gobject.idle_add (self.label.set_text, prompt.replace(' (enter Ctrl+c to exit reportbug without reporting a bug)', ''))
-        self.entry.set_text (default)
+        gobject.idle_add(self.label.set_text, prompt.replace('(enter Ctrl+c to exit reportbug without reporting a bug)', ''))
+        self.entry.set_text(default)
 
         if options:
-            options.sort ()
-            completion = gtk.EntryCompletion ()
-            model = gtk.ListStore (str)
+            options.sort()
+            completion = gtk.EntryCompletion()
+            model = gtk.ListStore(str)
             for option in options:
-                model.append ([option])
-            completion.set_model (model)
-            completion.set_inline_selection (True)
-            completion.set_text_column (0)
-            self.entry.set_completion (completion)
+                model.append([option])
+            completion.set_model(model)
+            completion.set_inline_selection(True)
+            completion.set_text_column(0)
+            self.entry.set_completion(completion)
         else:
             self.completion = None
 
-        self.validate ()
+        self.validate()
+
 
-class GetPasswordPage (GetStringPage):
-    def create_widget (self):
-        widget = GetStringPage.create_widget (self)
-        self.entry.set_visibility (False)
+class GetPasswordPage(GetStringPage):
+    def create_widget(self):
+        widget = GetStringPage.create_widget(self)
+        self.entry.set_visibility(False)
         return widget
 
-class GetMultilinePage (Page):
-    def setup_focus (self):
-        self.view.grab_focus ()
-
-    def create_widget (self):
-        vbox = gtk.VBox (spacing=12)
-        self.label = gtk.Label ()
-        self.label.set_line_wrap (True)
-        self.label.set_justify (gtk.JUSTIFY_FILL)
-        self.label.set_selectable (True)
-        self.label.set_property ("can-focus", False)
-        vbox.pack_start (self.label, expand=False)
-
-        self.view = gtk.TextView ()
-        self.buffer = view.get_buffer ()
-        scrolled = create_scrollable (self.view)
-        vbox.pack_start (scrolled)
+
+class GetMultilinePage(Page):
+    def setup_focus(self):
+        self.view.grab_focus()
+
+    def create_widget(self):
+        vbox = gtk.VBox(spacing=12)
+        self.label = gtk.Label()
+        self.label.set_line_wrap(True)
+        self.label.set_justify(gtk.JUSTIFY_FILL)
+        self.label.set_selectable(True)
+        self.label.set_property("can-focus", False)
+        vbox.pack_start(self.label, expand=False)
+
+        self.view = gtk.TextView()
+        self.buffer = view.get_buffer()
+        scrolled = create_scrollable(self.view)
+        vbox.pack_start(scrolled)
         return vbox
 
-    def connect_signals (self):
-        self.buffer.connect ('changed', self.validate)
+    def connect_signals(self):
+        self.buffer.connect('changed', self.validate)
 
-    def get_value (self):
-        text = self.buffer.get_text (self.buffer.get_start_iter (), self.buffer.get_end_iter ())
-        lines = text.split ('\n')
+    def get_value(self):
+        text = self.buffer.get_text(self.buffer.get_start_iter(), self.buffer.get_end_iter())
+        lines = text.split('\n')
         # Remove the trailing empty line at the end
-        if len (lines) > 0 and not lines[-1].strip ():
+        if len(lines) > 0 and not lines[-1].strip():
             del lines[-1]
-        return text.split ('\n')
+        return text.split('\n')
 
-    def execute (self, prompt):
+    def execute(self, prompt):
         self.empty_ok = True
         # The result must be iterable for reportbug even if it's empty and not modified
-        gobject.idle_add (self.label.set_text, prompt)
-        self.buffer.set_text ("")
-        self.buffer.emit ('changed')
+        gobject.idle_add(self.label.set_text, prompt)
+        self.buffer.set_text("")
+        self.buffer.emit('changed')
 
-class TreePage (Page):
+
+class TreePage(Page):
     value_column = None
 
-    def __init__ (self, *args, **kwargs):
-        Page.__init__ (self, *args, **kwargs)
+    def __init__(self, *args, **kwargs):
+        Page.__init__(self, *args, **kwargs)
         self.selection = self.view.get_selection()
 
-    def setup_focus (self):
-        self.view.grab_focus ()
+    def setup_focus(self):
+        self.view.grab_focus()
 
-    def connect_signals (self):
-        self.selection.connect ('changed', self.validate)
+    def connect_signals(self):
+        self.selection.connect('changed', self.validate)
 
-    def get_value (self):
-        model, paths = self.selection.get_selected_rows ()
-        multiple = self.selection.get_mode () == gtk.SELECTION_MULTIPLE
+    def get_value(self):
+        model, paths = self.selection.get_selected_rows()
+        multiple = self.selection.get_mode() == gtk.SELECTION_MULTIPLE
         result = []
         for path in paths:
-            value = model.get_value (model.get_iter (path), self.value_column)
+            value = model.get_value(model.get_iter(path), self.value_column)
             if value is not None:
-                result.append (markup_free (value))
+                result.append(markup_free(value))
         if result and not multiple:
             return result[0]
         return result
 
-class GetListPage (TreePage):
+
+class GetListPage(TreePage):
     value_column = 0
 
-    def create_widget (self):
-        vbox = gtk.VBox (spacing=12)
-        self.label = gtk.Label ()
-        self.label.set_line_wrap (True)
-        self.label.set_justify (gtk.JUSTIFY_FILL)
-        vbox.pack_start (self.label, expand=False)
-
-        hbox = gtk.HBox (spacing=6)
-
-        self.view = gtk.TreeView ()
-        self.view.set_rules_hint (True)
-        self.view.get_selection().set_mode (gtk.SELECTION_MULTIPLE)
-        scrolled = create_scrollable (self.view)
-        hbox.pack_start (scrolled)
-
-        bbox = gtk.VButtonBox ()
-        bbox.set_spacing (6)
-        bbox.set_layout (gtk.BUTTONBOX_START)
-        button = gtk.Button (stock=gtk.STOCK_ADD)
-        button.connect ('clicked', self.on_add)
-        bbox.pack_start (button, expand=False)
-        button = gtk.Button (stock=gtk.STOCK_REMOVE)
-        button.connect ('clicked', self.on_remove)
-        bbox.pack_start (button, expand=False)
-        hbox.pack_start (bbox, expand=False)
-
-        vbox.pack_start (hbox)
+    def create_widget(self):
+        vbox = gtk.VBox(spacing=12)
+        self.label = gtk.Label()
+        self.label.set_line_wrap(True)
+        self.label.set_justify(gtk.JUSTIFY_FILL)
+        vbox.pack_start(self.label, expand=False)
+
+        hbox = gtk.HBox(spacing=6)
+
+        self.view = gtk.TreeView()
+        self.view.set_rules_hint(True)
+        self.view.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
+        scrolled = create_scrollable(self.view)
+        hbox.pack_start(scrolled)
+
+        bbox = gtk.VButtonBox()
+        bbox.set_spacing(6)
+        bbox.set_layout(gtk.BUTTONBOX_START)
+        button = gtk.Button(stock=gtk.STOCK_ADD)
+        button.connect('clicked', self.on_add)
+        bbox.pack_start(button, expand=False)
+        button = gtk.Button(stock=gtk.STOCK_REMOVE)
+        button.connect('clicked', self.on_remove)
+        bbox.pack_start(button, expand=False)
+        hbox.pack_start(bbox, expand=False)
+
+        vbox.pack_start(hbox)
         return vbox
 
-    def get_value (self):
+    def get_value(self):
         values = []
         for row in self.model:
-            values.append (row[self.value_column])
+            values.append(row[self.value_column])
         return values
 
-    def on_add (self, button):
-        dialog = InputStringDialog ("Add a new item to the list")
-        dialog.show_all ()
-        dialog.connect ('response', self.on_add_dialog_response)
+    def on_add(self, button):
+        dialog = InputStringDialog("Add a new item to the list")
+        dialog.show_all()
+        dialog.connect('response', self.on_add_dialog_response)
 
-    def on_add_dialog_response (self, dialog, res):
+    def on_add_dialog_response(self, dialog, res):
         if res == gtk.RESPONSE_ACCEPT:
-            self.model.append ([dialog.get_value ()])
-        dialog.destroy ()
+            self.model.append([dialog.get_value()])
+        dialog.destroy()
 
-    def on_remove (self, button):
-        model, paths = self.selection.get_selected_rows ()
+    def on_remove(self, button):
+        model, paths = self.selection.get_selected_rows()
         # We need to transform them to iters, since paths change when removing rows
         iters = []
         for path in paths:
-            iters.append (self.model.get_iter (path))
+            iters.append(self.model.get_iter(path))
         for iter in iters:
-            self.model.remove (iter)
+            self.model.remove(iter)
 
-    def execute (self, prompt):
+    def execute(self, prompt):
         self.empty_ok = True
 
-        gobject.idle_add (self.label.set_text, prompt)
+        gobject.idle_add(self.label.set_text, prompt)
+
+        self.model = gtk.ListStore(str)
+        self.model.connect('row-changed', self.validate)
+        self.view.set_model(self.model)
 
-        self.model = gtk.ListStore (str)
-        self.model.connect ('row-changed', self.validate)
-        self.view.set_model (self.model)
+        self.selection.set_mode(gtk.SELECTION_MULTIPLE)
 
-        self.selection.set_mode (gtk.SELECTION_MULTIPLE)
+        self.view.append_column(gtk.TreeViewColumn('Item', gtk.CellRendererText(), text=0))
 
-        self.view.append_column (gtk.TreeViewColumn ('Item', gtk.CellRendererText (), text=0))
 
-class WrapRendererText (gtk.CellRendererText):
-    def do_render (self, window, widget, background_area, cell_area, expose_area, flags):
-        self.set_property ('wrap-width', cell_area.width)
-        gtk.CellRendererText.do_render (self, window, widget, background_area, cell_area, expose_area, flags)
+class WrapRendererText(gtk.CellRendererText):
+    def do_render(self, window, widget, background_area, cell_area, expose_area, flags):
+        self.set_property('wrap-width', cell_area.width)
+        gtk.CellRendererText.do_render(self, window, widget, background_area, cell_area, expose_area, flags)
 
-gobject.type_register (WrapRendererText)
 
-class MenuPage (TreePage):
+gobject.type_register(WrapRendererText)
+
+
+class MenuPage(TreePage):
     value_column = 0
 
-    def create_widget (self):
-        vbox = gtk.VBox (spacing=12)
-        self.label = gtk.Label ()
-        self.label.set_line_wrap (True)
-        self.label.set_justify (gtk.JUSTIFY_FILL)
-        vbox.pack_start (self.label, expand=False)
-
-        self.view = gtk.TreeView ()
-        self.view.set_rules_hint (True)
-        scrolled = create_scrollable (self.view)
-        scrolled.set_policy (gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
-        vbox.pack_start (scrolled)
-        vbox.show_all ()
+    def create_widget(self):
+        vbox = gtk.VBox(spacing=12)
+        self.label = gtk.Label()
+        self.label.set_line_wrap(True)
+        self.label.set_justify(gtk.JUSTIFY_FILL)
+        vbox.pack_start(self.label, expand=False)
+
+        self.view = gtk.TreeView()
+        self.view.set_rules_hint(True)
+        scrolled = create_scrollable(self.view)
+        scrolled.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS)
+        vbox.pack_start(scrolled)
+        vbox.show_all()
         return vbox
 
-    def connect_signals (self):
-        TreePage.connect_signals (self)
-        self.view.connect ('row-activated', self.activate_forward)
+    def connect_signals(self):
+        TreePage.connect_signals(self)
+        self.view.connect('row-activated', self.activate_forward)
 
-    def execute (self, par, options, prompt, default=None, any_ok=False,
-                 order=None, extras=None, multiple=False):
-        gobject.idle_add (self.label.set_text, par)
+    def execute(self, par, options, prompt, default=None, any_ok=False,
+                order=None, extras=None, multiple=False):
+        gobject.idle_add(self.label.set_text, par)
 
-        self.model = gtk.ListStore (str, str)
-        self.view.set_model (self.model)
+        self.model = gtk.ListStore(str, str)
+        self.view.set_model(self.model)
 
         if multiple:
-            self.selection.set_mode (gtk.SELECTION_MULTIPLE)
+            self.selection.set_mode(gtk.SELECTION_MULTIPLE)
 
-        self.view.append_column (gtk.TreeViewColumn ('Option', gtk.CellRendererText (), markup=0))
-        rend = WrapRendererText ()
-        rend.set_property ('wrap-mode', pango.WRAP_WORD)
-        rend.set_property ('wrap-width', 300)
-        self.view.append_column (gtk.TreeViewColumn ('Description', rend, text=1))
+        self.view.append_column(gtk.TreeViewColumn('Option', gtk.CellRendererText(), markup=0))
+        rend = WrapRendererText()
+        rend.set_property('wrap-mode', pango.WRAP_WORD)
+        rend.set_property('wrap-width', 300)
+        self.view.append_column(gtk.TreeViewColumn('Description', rend, text=1))
 
         default_iter = None
         # here below, 'text' is the value of the description of the item, but
         # writen all on a single-line, it will be wrapped by the list settings
-        if isinstance (options, dict):
+        if isinstance(options, dict):
             if order:
                 for option in order:
                     if option in options:
                         text = ' '.join(options[option].split())
-                        iter = self.model.append ((highlight (option), text))
+                        iter = self.model.append((highlight(option), text))
                         if option == default:
                             default_iter = iter
-            for option, desc in options.iteritems ():
+            for option, desc in options.iteritems():
                 if not order or option not in order:
                     text = ' '.join(desc.split())
-                    iter = self.model.append ((highlight (option), text))
+                    iter = self.model.append((highlight(option), text))
                     if option == default:
                         default_iter = iter
         else:
             for row in options:
                 text = ' '.join(row[1].split())
-                iter = self.model.append ((highlight (row[0]), text))
+                iter = self.model.append((highlight(row[0]), text))
                 if row[0] == default:
                     default_iter = iter
 
         if default_iter:
-            self.selection.select_iter (default_iter)
+            self.selection.select_iter(default_iter)
+
 
-class HandleBTSQueryPage (TreePage):
+class HandleBTSQueryPage(TreePage):
     default_complete = True
     value_column = 0
 
-    def sync_pre_operation (self, package, bts, timeout, mirrors=None, http_proxy="", queryonly=False, screen=None,
-                            archived='no', source=False, title=None,
-                            version=None, buglist=None, mbox_reader_cmd=None, latest_first=False):
+    def sync_pre_operation(self, package, bts, timeout, mirrors=None, http_proxy="", queryonly=False, screen=None,
+                           archived='no', source=False, title=None,
+                           version=None, buglist=None, mbox_reader_cmd=None, latest_first=False):
         self.bts = bts
         self.mirrors = mirrors
         self.http_proxy = http_proxy
@@ -873,22 +895,21 @@ class HandleBTSQueryPage (TreePage):
         if isinstance(package, basestring):
             pkgname = package
             if source:
-                pkgname += ' (source)'
+                pkgname += '(source)'
 
             progress_label = 'Querying %s bug tracking system for reports on %s' % (debbugs.SYSTEMS[bts]['name'], pkgname)
         else:
             progress_label = 'Querying %s bug tracking system for reports %s' % (debbugs.SYSTEMS[bts]['name'], ' '.join([str(x) for x in package]))
 
-
-        self.application.run_once_in_main_thread (self.assistant.set_progress_label, progress_label)
+        self.application.run_once_in_main_thread(self.assistant.set_progress_label, progress_label)
 
         try:
-            (count, sectitle, hierarchy) = debbugs.get_reports (
+            (count, sectitle, hierarchy) = debbugs.get_reports(
                 package, timeout, bts, mirrors=mirrors, version=version,
                 http_proxy=http_proxy, archived=archived, source=source)
 
             if not count:
-                if hierarchy == None:
+                if hierarchy is None:
                     raise NoPackage
                 else:
                     raise NoBugs
@@ -902,154 +923,155 @@ class HandleBTSQueryPage (TreePage):
                 for category, bugs in hierarchy:
                     buglist = []
                     for bug in bugs:
-                        buglist.append (bug)
+                        buglist.append(bug)
                     # XXX: this needs to be fixed in debianbts; Bugreport are
-                    # not sortable (on bug_num) - see #639458
+                    # not sortable(on bug_num) - see #639458
                     sorted(buglist, reverse=latest_first)
-                    report.append ((category, map(Bug, buglist)))
+                    report.append((category, map(Bug, buglist)))
 
-                return (report, sectitle), {}
+                return(report, sectitle), {}
 
-        except (IOError, NoNetwork):
-            error_dialog ("Unable to connect to %s BTS." % sysinfo['name'])
+        except(IOError, NoNetwork):
+            error_dialog("Unable to connect to %s BTS." % sysinfo['name'])
         except NoPackage:
-            error_dialog ('No record of this package found.')
+            error_dialog('No record of this package found.')
             raise NoPackage
 
-        raise SyncReturn (None)
-
-    def setup_focus (self):
-        self.entry.grab_focus ()
-
-    def create_widget (self):
-        vbox = gtk.VBox (spacing=6)
-        self.label = gtk.Label ("List of bugs. Select a bug to retrieve and submit more information.")
-        vbox.pack_start (self.label, expand=False, padding=6)
-
-        hbox = gtk.HBox (spacing=6)
-        label = gtk.Label ("Filter:")
-        hbox.pack_start (label, expand=False)
-        self.entry = gtk.Entry ()
-        hbox.pack_start (self.entry)
-        button = gtk.Button ()
-        button.set_image (gtk.image_new_from_stock (gtk.STOCK_CLEAR, gtk.ICON_SIZE_MENU))
-        button.set_relief (gtk.RELIEF_NONE)
-        button.connect ('clicked', self.on_filter_clear)
-        hbox.pack_start (button, expand=False)
-        vbox.pack_start (hbox, expand=False)
-
-        self.view = gtk.TreeView ()
-        self.view.set_rules_hint (True)
-        scrolled = create_scrollable (self.view)
+        raise SyncReturn(None)
+
+    def setup_focus(self):
+        self.entry.grab_focus()
+
+    def create_widget(self):
+        vbox = gtk.VBox(spacing=6)
+        self.label = gtk.Label("List of bugs. Select a bug to retrieve and submit more information.")
+        vbox.pack_start(self.label, expand=False, padding=6)
+
+        hbox = gtk.HBox(spacing=6)
+        label = gtk.Label("Filter:")
+        hbox.pack_start(label, expand=False)
+        self.entry = gtk.Entry()
+        hbox.pack_start(self.entry)
+        button = gtk.Button()
+        button.set_image(gtk.image_new_from_stock(gtk.STOCK_CLEAR, gtk.ICON_SIZE_MENU))
+        button.set_relief(gtk.RELIEF_NONE)
+        button.connect('clicked', self.on_filter_clear)
+        hbox.pack_start(button, expand=False)
+        vbox.pack_start(hbox, expand=False)
+
+        self.view = gtk.TreeView()
+        self.view.set_rules_hint(True)
+        scrolled = create_scrollable(self.view)
         self.columns = ['ID', 'Tag', 'Package', 'Description', 'Status', 'Submitter', 'Date', 'Severity', 'Version',
                         'Filed date', 'Modified date']
-        for col in zip (self.columns, range (len (self.columns))):
-            column = gtk.TreeViewColumn (col[0], gtk.CellRendererText (), text=col[1])
-            column.set_reorderable (True)
-            self.view.append_column (column)
-        vbox.pack_start (scrolled)
-
-        button = gtk.Button ("Retrieve and submit bug information")
-        button.set_image (gtk.image_new_from_stock (gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON))
-        button.connect ('clicked', self.on_retrieve_info)
-        vbox.pack_start (button, expand=False)
+        for col in zip(self.columns, range(len(self.columns))):
+            column = gtk.TreeViewColumn(col[0], gtk.CellRendererText(), text=col[1])
+            column.set_reorderable(True)
+            self.view.append_column(column)
+        vbox.pack_start(scrolled)
+
+        button = gtk.Button("Retrieve and submit bug information")
+        button.set_image(gtk.image_new_from_stock(gtk.STOCK_INFO, gtk.ICON_SIZE_BUTTON))
+        button.connect('clicked', self.on_retrieve_info)
+        vbox.pack_start(button, expand=False)
         return vbox
 
-    def connect_signals (self):
-        TreePage.connect_signals (self)
-        self.view.connect ('row-activated', self.on_retrieve_info)
-        self.entry.connect ('changed', self.on_filter_changed)
+    def connect_signals(self):
+        TreePage.connect_signals(self)
+        self.view.connect('row-activated', self.on_retrieve_info)
+        self.entry.connect('changed', self.on_filter_changed)
 
-    def on_filter_clear (self, button):
-        self.entry.set_text ("")
+    def on_filter_clear(self, button):
+        self.entry.set_text("")
 
-    def on_filter_changed (self, entry):
-        self.model.filter_text = entry.get_text().lower ()
-        self.filter.refilter ()
+    def on_filter_changed(self, entry):
+        self.model.filter_text = entry.get_text().lower()
+        self.filter.refilter()
 
-    def on_retrieve_info (self, *args):
-        bug_ids = TreePage.get_value (self)
+    def on_retrieve_info(self, *args):
+        bug_ids = TreePage.get_value(self)
         if not bug_ids:
-            info_dialog ("Please select one ore more bugs")
+            info_dialog("Please select one ore more bugs")
             return
 
-        dialog = BugsDialog (self.assistant, self.queryonly)
+        dialog = BugsDialog(self.assistant, self.queryonly)
         for id in bug_ids:
-            dialog.show_bug (id, self.bts, self.mirrors, self.http_proxy, self.timeout, self.archived)
-        dialog.show_all ()
+            dialog.show_bug(id, self.bts, self.mirrors, self.http_proxy, self.timeout, self.archived)
+        dialog.show_all()
 
-    def is_valid (self, value):
+    def is_valid(self, value):
         return True
 
-    def get_value (self):
+    def get_value(self):
         # The value returned to reportbug doesn't depend by a selection, but by the dialog of a bug
         return None
 
-    def match_filter (self, iter):
+    def match_filter(self, iter):
         # Flatten the columns into a single string
         text = ""
-        for col in range (len (self.columns)):
-            value = self.model.get_value (iter, col)
+        for col in range(len(self.columns)):
+            value = self.model.get_value(iter, col)
             if value:
-                text += self.model.get_value (iter, col) + " "
+                text += self.model.get_value(iter, col) + " "
 
-        text = text.lower ()
+        text = text.lower()
         # Tokens shouldn't be adjacent by default
-        for token in self.model.filter_text.split (' '):
+        for token in self.model.filter_text.split(' '):
             if token in text:
                 return True
         return False
 
-    def filter_visible_func (self, model, iter):
-        matches = self.match_filter (iter)
-        if not self.model.iter_parent (iter) and not matches:
+    def filter_visible_func(self, model, iter):
+        matches = self.match_filter(iter)
+        if not self.model.iter_parent(iter) and not matches:
             # If no children are visible, hide it
-            it = model.iter_children (iter)
+            it = model.iter_children(iter)
             while it:
-                if self.match_filter (it):
+                if self.match_filter(it):
                     return True
-                it = model.iter_next (it)
+                it = model.iter_next(it)
             return False
 
         return matches
 
-    def execute (self, buglist, sectitle):
-        gobject.idle_add (self.label.set_text, "%s. Double-click a bug to retrieve and submit more information." % sectitle)
+    def execute(self, buglist, sectitle):
+        gobject.idle_add(self.label.set_text, "%s. Double-click a bug to retrieve and submit more information." % sectitle)
 
-        self.model = gtk.TreeStore (*([str] * len (self.columns)))
+        self.model = gtk.TreeStore(*([str] * len(self.columns)))
         for category in buglist:
-            row = [None] * len (self.columns)
+            row = [None] * len(self.columns)
             row[3] = category[0]
-            iter = self.model.append (None, row)
+            iter = self.model.append(None, row)
             for bug in category[1]:
-                self.model.append (iter, list (bug))
+                self.model.append(iter, list(bug))
 
-        self.selection.set_mode (gtk.SELECTION_MULTIPLE)
+        self.selection.set_mode(gtk.SELECTION_MULTIPLE)
 
         self.model.filter_text = ""
-        self.filter = self.model.filter_new ()
-        self.filter.set_visible_func (self.filter_visible_func)
-        self.view.set_model (self.filter)
+        self.filter = self.model.filter_new()
+        self.filter.set_visible_func(self.filter_visible_func)
+        self.view.set_model(self.filter)
+
 
-class ShowReportPage (Page):
+class ShowReportPage(Page):
     default_complete = True
 
-    def create_widget (self):
-        self.page = BugPage (self.assistant, None, None, None, None, None, None, None, None)
+    def create_widget(self):
+        self.page = BugPage(self.assistant, None, None, None, None, None, None, None, None)
         return self.page
 
-    def get_value (self):
+    def get_value(self):
         return None
 
-    def is_valid (self, value):
+    def is_valid(self, value):
         return True
 
-    def sync_pre_operation (self, *args, **kwargs):
-        if kwargs.get ('queryonly'):
+    def sync_pre_operation(self, *args, **kwargs):
+        if kwargs.get('queryonly'):
             self.page_type = gtk.ASSISTANT_PAGE_CONFIRM
         return args, kwargs
 
-    def execute (self, number, system, mirrors, http_proxy, timeout, queryonly=False, title='', archived='no', mbox_reader_cmd=None):
+    def execute(self, number, system, mirrors, http_proxy, timeout, queryonly=False, title='', archived='no', mbox_reader_cmd=None):
         self.page.number = number
         self.page.bts = system
         self.page.mirrors = mirrors
@@ -1057,175 +1079,180 @@ class ShowReportPage (Page):
         self.page.timeout = timeout
         self.page.queryonly = queryonly
         self.page.archived = archived
-        self.page.start ()
-        self.validate ()
+        self.page.start()
+        self.validate()
+
 
-class DisplayReportPage (Page):
+class DisplayReportPage(Page):
     default_complete = True
 
-    def create_widget (self):
-        self.view = gtk.TextView ()
-        self.view.set_editable (False)
-        scrolled = create_scrollable (self.view)
+    def create_widget(self):
+        self.view = gtk.TextView()
+        self.view.set_editable(False)
+        scrolled = create_scrollable(self.view)
         return scrolled
 
-    def execute (self, message, *args):
+    def execute(self, message, *args):
         # 'use' args only if it's passed
         if args:
             message = message % args
         self.view.get_buffer().set_text(message)
 
-class LongMessagePage (Page):
+
+class LongMessagePage(Page):
     default_complete = True
-    
-    def create_widget (self):
-        self.label = gtk.Label ()
-        self.label.set_line_wrap (True)
-        self.label.set_justify (gtk.JUSTIFY_FILL)
-        self.label.set_selectable (True)
-        self.label.set_property ("can-focus", False)
-        eb = gtk.EventBox ()
-        eb.add (self.label)
+
+    def create_widget(self):
+        self.label = gtk.Label()
+        self.label.set_line_wrap(True)
+        self.label.set_justify(gtk.JUSTIFY_FILL)
+        self.label.set_selectable(True)
+        self.label.set_property("can-focus", False)
+        eb = gtk.EventBox()
+        eb.add(self.label)
         return eb
 
-    def execute (self, message, *args):
+    def execute(self, message, *args):
         message = message % args
         # make it all on one line, it will be wrapped at display-time
         message = ' '.join(message.split())
-        gobject.idle_add (self.label.set_text, message)
+        gobject.idle_add(self.label.set_text, message)
         # Reportbug should use final_message, so emulate it
-        if ('999999' in message):
-            self.set_page_type (gtk.ASSISTANT_PAGE_CONFIRM)
-            self.set_page_title ("Thanks for your report")
+        if('999999' in message):
+            self.set_page_type(gtk.ASSISTANT_PAGE_CONFIRM)
+            self.set_page_title("Thanks for your report")
 
-class FinalMessagePage (LongMessagePage):
+
+class FinalMessagePage(LongMessagePage):
     page_type = gtk.ASSISTANT_PAGE_CONFIRM
     default_complete = True
 
-    def execute (self, *args, **kwargs):
-        LongMessagePage.execute (self, *args, **kwargs)
-        self.set_page_title ("Thanks for your report")
+    def execute(self, *args, **kwargs):
+        LongMessagePage.execute(self, *args, **kwargs)
+        self.set_page_title("Thanks for your report")
+
 
-class EditorPage (Page):
-    def create_widget (self):
-        vbox = gtk.VBox (spacing=6)
-        hbox = gtk.HBox (spacing=12)
-        hbox.pack_start (gtk.Label ("Subject: "), expand=False)
-        self.subject = gtk.Entry ()
-        hbox.pack_start (self.subject)
-        vbox.pack_start (hbox, expand=False)
+class EditorPage(Page):
+    def create_widget(self):
+        vbox = gtk.VBox(spacing=6)
+        hbox = gtk.HBox(spacing=12)
+        hbox.pack_start(gtk.Label("Subject: "), expand=False)
+        self.subject = gtk.Entry()
+        hbox.pack_start(self.subject)
+        vbox.pack_start(hbox, expand=False)
 
-        self.view = gtk.TextView ()
+        self.view = gtk.TextView()
         self.view.modify_font(pango.FontDescription("Monospace"))
-        self.view.set_wrap_mode (gtk.WRAP_WORD)
+        self.view.set_wrap_mode(gtk.WRAP_WORD)
         if has_spell:
-            gtkspell.Spell (self.view)
-        self.info_buffer = self.view.get_buffer ()
-        scrolled = create_scrollable (self.view)
-        vbox.pack_start (scrolled)
-
-        expander = gtk.Expander ("Other system information")
-        view = gtk.TextView ()
-        view.set_editable (False)
-        self.others_buffer = view.get_buffer ()
-        scrolled = create_scrollable (view)
-        expander.add (scrolled)
-        vbox.pack_start (expander, False)
+            gtkspell.Spell(self.view)
+        self.info_buffer = self.view.get_buffer()
+        scrolled = create_scrollable(self.view)
+        vbox.pack_start(scrolled)
+
+        expander = gtk.Expander("Other system information")
+        view = gtk.TextView()
+        view.set_editable(False)
+        self.others_buffer = view.get_buffer()
+        scrolled = create_scrollable(view)
+        expander.add(scrolled)
+        vbox.pack_start(expander, False)
 
         if not has_spell:
-            box = gtk.EventBox ()
-            label = gtk.Label ("Please install <b>python-gtkspell</b> to enable spell checking")
-            label.set_use_markup (True)
-            label.set_line_wrap (True)
-            label.set_selectable (True)
-            label.set_property ("can-focus", False)
-            box.add (label)
-            box.modify_bg (gtk.STATE_NORMAL, self.WARNING_COLOR)
-            box.connect ('button-press-event', lambda *args: box.destroy ())
-            vbox.pack_start (box, False)
+            box = gtk.EventBox()
+            label = gtk.Label("Please install <b>python-gtkspell</b> to enable spell checking")
+            label.set_use_markup(True)
+            label.set_line_wrap(True)
+            label.set_selectable(True)
+            label.set_property("can-focus", False)
+            box.add(label)
+            box.modify_bg(gtk.STATE_NORMAL, self.WARNING_COLOR)
+            box.connect('button-press-event', lambda *args: box.destroy())
+            vbox.pack_start(box, False)
         return vbox
 
-    def switch_out (self):
+    def switch_out(self):
         global report_message
         report_message = self.get_value()[0]
-        f = file (self.filename, "w")
-        f.write (report_message)
-        f.close ()
-
-    def connect_signals (self):
-        self.info_buffer.connect ('changed', self.validate)
-        self.subject.connect ('changed', self.validate)
-
-    def get_value (self):
-        info = self.info_buffer.get_text (self.info_buffer.get_start_iter (),
-                                          self.info_buffer.get_end_iter ())
-        if not info.strip ():
+        f = file(self.filename, "w")
+        f.write(report_message)
+        f.close()
+
+    def connect_signals(self):
+        self.info_buffer.connect('changed', self.validate)
+        self.subject.connect('changed', self.validate)
+
+    def get_value(self):
+        info = self.info_buffer.get_text(self.info_buffer.get_start_iter(),
+                                         self.info_buffer.get_end_iter())
+        if not info.strip():
             return None
-        subject = self.subject.get_text().strip ()
-        if not subject.strip ():
+        subject = self.subject.get_text().strip()
+        if not subject.strip():
             return None
 
-        self.report.set_subject (subject)
-        message = self.report.create_message (info)
-        message = message.decode (self.charset, 'replace')
-        return (message, message != self.message)
+        self.report.set_subject(subject)
+        message = self.report.create_message(info)
+        message = message.decode(self.charset, 'replace')
+        return(message, message != self.message)
 
-    def handle_first_info (self):
-        self.focus_in_id = self.view.connect ('focus-in-event', self.on_view_focus_in_event)
+    def handle_first_info(self):
+        self.focus_in_id = self.view.connect('focus-in-event', self.on_view_focus_in_event)
 
-    def on_view_focus_in_event (self, view, *args):
+    def on_view_focus_in_event(self, view, *args):
         # Empty the buffer only the first time
-        self.info_buffer.set_text ("")
-        view.disconnect (self.focus_in_id)
+        self.info_buffer.set_text("")
+        view.disconnect(self.focus_in_id)
 
-    def execute (self, message, filename, editor, charset='utf-8'):
+    def execute(self, message, filename, editor, charset='utf-8'):
         self.message = message
-        self.report = BugReport (message)
+        self.report = BugReport(message)
         self.filename = filename
         self.charset = charset
-        self.subject.set_text (self.report.get_subject ())
-        self.others_buffer.set_text (self.report.get_others ())
+        self.subject.set_text(self.report.get_subject())
+        self.others_buffer.set_text(self.report.get_others())
 
-        info = self.report.get_original_info ()
-        if info.strip () == "*** Please type your report below this line ***":
+        info = self.report.get_original_info()
+        if info.strip() == "*** Please type your report below this line ***":
             info = "Please type your report here.\nThe text will be wrapped to be max 79 chars long per line."
-            self.handle_first_info ()
-        self.info_buffer.set_text (info)
+            self.handle_first_info()
+        self.info_buffer.set_text(info)
+
 
-class SelectOptionsPage (Page):
+class SelectOptionsPage(Page):
     default_complete = False
 
-    def create_widget (self):
-        self.label = gtk.Label ()
-        self.label.set_line_wrap (True)
-        self.label.set_justify (gtk.JUSTIFY_FILL)
-        self.vbox = gtk.VBox (spacing=6)
-        self.vbox.pack_start (self.label, expand=False, padding=6)
+    def create_widget(self):
+        self.label = gtk.Label()
+        self.label.set_line_wrap(True)
+        self.label.set_justify(gtk.JUSTIFY_FILL)
+        self.vbox = gtk.VBox(spacing=6)
+        self.vbox.pack_start(self.label, expand=False, padding=6)
         self.default = None
         return self.vbox
 
-    def on_clicked (self, button, menuopt):
-        self.application.set_next_value (menuopt)
-        self.assistant.forward_page ()
+    def on_clicked(self, button, menuopt):
+        self.application.set_next_value(menuopt)
+        self.assistant.forward_page()
 
-    def on_display_clicked (self, button):
+    def on_display_clicked(self, button):
         global report_message
-        ReportViewerDialog (report_message)
+        ReportViewerDialog(report_message)
 
-    def setup_focus (self):
+    def setup_focus(self):
         if self.default:
-            self.default.set_flags (gtk.CAN_DEFAULT | gtk.HAS_DEFAULT)
-            self.default.grab_default ()
-            self.default.grab_focus ()
+            self.default.set_flags(gtk.CAN_DEFAULT | gtk.HAS_DEFAULT)
+            self.default.grab_default()
+            self.default.grab_focus()
 
-    def execute (self, prompt, menuopts, options):
+    def execute(self, prompt, menuopts, options):
         # remove text UI indication
-        prompt = prompt.replace(' (e to edit)', '')
-        gobject.idle_add (self.label.set_text, prompt)
+        prompt = prompt.replace('(e to edit)', '')
+        gobject.idle_add(self.label.set_text, prompt)
 
         buttons = []
         for menuopt in menuopts:
-            desc = options[menuopt.lower ()]
+            desc = options[menuopt.lower()]
             # do we really need to launch an external editor?
             if 'Change editor' in desc:
                 continue
@@ -1234,102 +1261,105 @@ class SelectOptionsPage (Page):
                 continue
             # stdout is a textview for us
             if 'Print message to stdout' in desc:
-                button = gtk.Button ("Display message in a text view")
-                button.connect ('clicked', self.on_display_clicked)
-                buttons.append (button)
+                button = gtk.Button("Display message in a text view")
+                button.connect('clicked', self.on_display_clicked)
+                buttons.append(button)
             else:
-                button = gtk.Button ()
-                label = gtk.Label (options[menuopt.lower ()])
-                button.add (label)
-                button.connect ('clicked', self.on_clicked, menuopt.lower ())
-                if menuopt.isupper ():
-                    label.set_markup ("<b>%s</b>" % label.get_text ())
+                button = gtk.Button()
+                label = gtk.Label(options[menuopt.lower()])
+                button.add(label)
+                button.connect('clicked', self.on_clicked, menuopt.lower())
+                if menuopt.isupper():
+                    label.set_markup("<b>%s</b>" % label.get_text())
                     self.default = button
-                    buttons.insert (0, gtk.HSeparator ())
-                    buttons.insert (0, button)
+                    buttons.insert(0, gtk.HSeparator())
+                    buttons.insert(0, button)
                 else:
-                    buttons.append (button)
+                    buttons.append(button)
 
         for button in buttons:
-            self.vbox.pack_start (button, expand=False)
+            self.vbox.pack_start(button, expand=False)
 
-        self.vbox.show_all ()
+        self.vbox.show_all()
 
-class SystemPage (Page):
+
+class SystemPage(Page):
     default_complete = False
 
-    def create_widget (self):
-        hbox = gtk.HBox ()
+    def create_widget(self):
+        hbox = gtk.HBox()
 
-        self.terminal = vte.Terminal ()
-        self.terminal.set_cursor_blinks (True)
-        self.terminal.set_emulation ("xterm")
-        self.terminal.connect ('child-exited', self.on_child_exited)
-        hbox.pack_start (self.terminal)
+        self.terminal = vte.Terminal()
+        self.terminal.set_cursor_blinks(True)
+        self.terminal.set_emulation("xterm")
+        self.terminal.connect('child-exited', self.on_child_exited)
+        hbox.pack_start(self.terminal)
 
-        scrollbar = gtk.VScrollbar ()
-        scrollbar.set_adjustment (self.terminal.get_adjustment ())
-        hbox.pack_start (scrollbar)
+        scrollbar = gtk.VScrollbar()
+        scrollbar.set_adjustment(self.terminal.get_adjustment())
+        hbox.pack_start(scrollbar)
 
         return hbox
 
-    def on_child_exited (self, terminal):
-        self.application.set_next_value (None)
-        self.assistant.forward_page ()
+    def on_child_exited(self, terminal):
+        self.application.set_next_value(None)
+        self.assistant.forward_page()
+
+    def execute(self, cmdline):
+        self.terminal.fork_command('/bin/bash', ['/bin/bash', '-c', cmdline])
 
-    def execute (self, cmdline):
-        self.terminal.fork_command ('/bin/bash', ['/bin/bash', '-c', cmdline])
 
-class ProgressPage (Page):
+class ProgressPage(Page):
     page_type = gtk.ASSISTANT_PAGE_PROGRESS
 
-    def pulse (self):
-        self.progress.pulse ()
+    def pulse(self):
+        self.progress.pulse()
         return True
 
-    def create_widget (self):
-        vbox = gtk.VBox (spacing=6)
-        self.label = gtk.Label ()
-        self.label.set_line_wrap (True)
-        self.label.set_justify (gtk.JUSTIFY_FILL)
-        self.progress = gtk.ProgressBar ()
-        self.progress.set_pulse_step (0.01)
-        vbox.pack_start (self.label, expand=False)
-        vbox.pack_start (self.progress, expand=False)
-        gobject.timeout_add (10, self.pulse)
+    def create_widget(self):
+        vbox = gtk.VBox(spacing=6)
+        self.label = gtk.Label()
+        self.label.set_line_wrap(True)
+        self.label.set_justify(gtk.JUSTIFY_FILL)
+        self.progress = gtk.ProgressBar()
+        self.progress.set_pulse_step(0.01)
+        vbox.pack_start(self.label, expand=False)
+        vbox.pack_start(self.progress, expand=False)
+        gobject.timeout_add(10, self.pulse)
         return vbox
 
-    def set_label (self, text):
-        gobject.idle_add (self.label.set_text, text)
+    def set_label(self, text):
+        gobject.idle_add(self.label.set_text, text)
+
+    def reset_label(self):
+        self.set_label("This operation may take a while")
 
-    def reset_label (self):
-        self.set_label ("This operation may take a while")
 
-class ReportbugAssistant (gtk.Assistant):
-    def __init__ (self, application):
-        gtk.Assistant.__init__ (self)
+class ReportbugAssistant(gtk.Assistant):
+    def __init__(self, application):
+        gtk.Assistant.__init__(self)
         self.application = application
 
-        self.set_title ('Reportbug')
-        self.hack_buttons ()
+        self.set_title('Reportbug')
+        self.hack_buttons()
         self.showing_page = None
         self.requested_page = None
         self.progress_page = None
-        self.set_default_size (600, 400)
-        self.set_forward_page_func (self.forward)
-        self.connect_signals ()
-        self.setup_pages ()
+        self.set_default_size(600, 400)
+        self.set_forward_page_func(self.forward)
+        self.connect_signals()
+        self.setup_pages()
 
-    def _hack_buttons (self, widget):
+    def _hack_buttons(self, widget):
         # This is a real hack for two reasons:
         # 1. There's no other way to access action area but inspecting the assistant and searching for the back button
         # 2. Hide back button on show, because it can be shown-hidden by the assistant depending on the page
-        if isinstance (widget, gtk.Button):
+        if isinstance(widget, gtk.Button):
             if widget.get_label() == 'gtk-go-back':
-                widget.connect ('show', self.on_back_show)
+                widget.connect('show', self.on_back_show)
                 return
             if widget.get_label() == 'gtk-apply':
-                widget.connect ('show', self.on_back_show)
+                widget.connect('show', self.on_back_show)
                 return
             if widget.get_label() == 'gtk-cancel':
                 image = gtk.image_new_from_stock(gtk.STOCK_QUIT,
@@ -1338,219 +1368,228 @@ class ReportbugAssistant (gtk.Assistant):
                 widget.set_image(image)
                 return
             if widget.get_label() == 'gtk-go-forward':
-                image = gtk.image_new_from_stock (gtk.STOCK_GO_FORWARD, gtk.ICON_SIZE_BUTTON)
-                widget.set_label ("_Continue")
-                widget.set_image (image)
+                image = gtk.image_new_from_stock(gtk.STOCK_GO_FORWARD, gtk.ICON_SIZE_BUTTON)
+                widget.set_label("_Continue")
+                widget.set_image(image)
                 return
 
-        if isinstance (widget, gtk.Container):
-            widget.forall (self._hack_buttons)
+        if isinstance(widget, gtk.Container):
+            widget.forall(self._hack_buttons)
 
-    def hack_buttons (self):
-        self._hack_buttons (self)
+    def hack_buttons(self):
+        self._hack_buttons(self)
 
-    def connect_signals (self):
-        self.connect ('cancel', self.confirm_exit)
-        self.connect ('prepare', self.on_prepare)
-        self.connect ('delete-event', self.close)
-        self.connect ('apply', self.close)
+    def connect_signals(self):
+        self.connect('cancel', self.confirm_exit)
+        self.connect('prepare', self.on_prepare)
+        self.connect('delete-event', self.close)
+        self.connect('apply', self.close)
 
-    def on_back_show (self, widget):
-        widget.hide ()
+    def on_back_show(self, widget):
+        widget.hide()
 
-    def on_prepare (self, assistant, widget):
+    def on_prepare(self, assistant, widget):
         # If the user goes back then forward, we must ensure the feedback value to reportbug must be sent
         # when the user clicks on "Forward" to the requested page by reportbug
-        if self.showing_page and self.showing_page == self.requested_page and self.get_current_page () > self.showing_page.page_num:
-            self.application.put_next_value ()
+        if self.showing_page and self.showing_page == self.requested_page and self.get_current_page() > self.showing_page.page_num:
+            self.application.put_next_value()
             # Reportbug doesn't support going back, so make widgets insensitive
-            self.showing_page.widget.set_sensitive (False)
-            self.showing_page.switch_out ()
+            self.showing_page.widget.set_sensitive(False)
+            self.showing_page.switch_out()
 
         self.showing_page = widget.page
         # Some pages might have changed the label in the while
         if self.showing_page == self.progress_page:
-            self.progress_page.reset_label ()
+            self.progress_page.reset_label()
 
-        gobject.idle_add (self.showing_page.setup_focus)
+        gobject.idle_add(self.showing_page.setup_focus)
 
-    def close (self, *args):
-        sys.exit (0)
+    def close(self, *args):
+        sys.exit(0)
 
     def confirm_exit(self, *args):
-        dialog = gtk.MessageDialog (None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
-                                    gtk.MESSAGE_WARNING, gtk.BUTTONS_YES_NO,
-                                    "Are you sure you want to quit Reportbug?")
-        response = dialog.run ()
-        dialog.destroy ()
+        dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+                                   gtk.MESSAGE_WARNING, gtk.BUTTONS_YES_NO,
+                                   "Are you sure you want to quit Reportbug?")
+        response = dialog.run()
+        dialog.destroy()
         if response == gtk.RESPONSE_YES:
-            sys.exit (0)
-        
-    def forward (self, page_num):
+            sys.exit(0)
+
+    def forward(self, page_num):
         return page_num + 1
 
-    def forward_page (self):
-        self.set_current_page (self.forward (self.showing_page.page_num))
+    def forward_page(self):
+        self.set_current_page(self.forward(self.showing_page.page_num))
 
-    def set_next_page (self, page):
+    def set_next_page(self, page):
         self.requested_page = page
         # If we're in progress immediately show this guy
         if self.showing_page == self.progress_page:
-            self.set_current_page (page.page_num)
+            self.set_current_page(page.page_num)
 
-    def set_progress_label (self, text, *args, **kwargs):
-        self.progress_page.set_label (text % args)
+    def set_progress_label(self, text, *args, **kwargs):
+        self.progress_page.set_label(text % args)
 
-    def setup_pages (self):
+    def setup_pages(self):
         # We insert pages between the intro and the progress, so that we give the user the feedback
         # that the applications is still running when he presses the "Forward" button
-        self.showing_page = IntroPage (self)
-        self.showing_page.switch_in ()
-        self.progress_page = ProgressPage (self)
-        self.progress_page.switch_in ()
+        self.showing_page = IntroPage(self)
+        self.showing_page.switch_in()
+        self.progress_page = ProgressPage(self)
+        self.progress_page.switch_in()
         Page.next_page_num = 1
 
 
 # Dialogs
-
-
-class YesNoDialog (ReportbugConnector, gtk.MessageDialog):
-    def __init__ (self, application):
-        gtk.MessageDialog.__init__ (self, assistant, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
-                                    gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO)
+class YesNoDialog(ReportbugConnector, gtk.MessageDialog):
+    def __init__(self, application):
+        gtk.MessageDialog.__init__(self, assistant, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+                                   gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO)
         self.application = application
-        self.connect ('response', self.on_response)
+        self.connect('response', self.on_response)
 
-    def on_response (self, dialog, res):
-        self.application.set_next_value (res == gtk.RESPONSE_YES)
-        self.application.put_next_value ()
-        self.destroy ()
+    def on_response(self, dialog, res):
+        self.application.set_next_value(res == gtk.RESPONSE_YES)
+        self.application.put_next_value()
+        self.destroy()
 
-    def execute_operation (self, msg, yeshelp=None, nohelp=None, default=True, nowrap=False):
-        self.set_markup (msg)
+    def execute_operation(self, msg, yeshelp=None, nohelp=None, default=True, nowrap=False):
+        self.set_markup(msg)
         if default:
-            self.set_default_response (gtk.RESPONSE_YES)
+            self.set_default_response(gtk.RESPONSE_YES)
         else:
-            self.set_default_response (gtk.RESPONSE_NO)
-        self.show_all ()
+            self.set_default_response(gtk.RESPONSE_NO)
+        self.show_all()
+
 
-class DisplayFailureDialog (ReportbugConnector, gtk.MessageDialog):
-    def __init__ (self, application):
-        gtk.MessageDialog.__init__ (self, assistant, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
-                                    gtk.MESSAGE_WARNING, gtk.BUTTONS_CLOSE)
+class DisplayFailureDialog(ReportbugConnector, gtk.MessageDialog):
+    def __init__(self, application):
+        gtk.MessageDialog.__init__(self, assistant, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+                                   gtk.MESSAGE_WARNING, gtk.BUTTONS_CLOSE)
         self.application = application
-        self.connect ('response', self.on_response)
-
-    def on_response (self, dialog, res):
-        self.application.put_next_value ()
-        self.destroy ()
-
-    def execute_operation (self, msg, *args):
-        self.set_markup (msg % args)
-        self.show_all ()
-             
-class GetFilenameDialog (ReportbugConnector, gtk.FileChooserDialog):
-    def __init__ (self, application):
-        gtk.FileChooserDialog.__init__ (self, '', assistant, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
-                                                                      gtk.STOCK_OPEN, gtk.RESPONSE_OK))
+        self.connect('response', self.on_response)
+
+    def on_response(self, dialog, res):
+        self.application.put_next_value()
+        self.destroy()
+
+    def execute_operation(self, msg, *args):
+        self.set_markup(msg % args)
+        self.show_all()
+
+
+class GetFilenameDialog(ReportbugConnector, gtk.FileChooserDialog):
+    def __init__(self, application):
+        gtk.FileChooserDialog.__init__(self, '', assistant, buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
+                                                                     gtk.STOCK_OPEN, gtk.RESPONSE_OK))
         self.application = application
-        self.connect ('response', self.on_response)
+        self.connect('response', self.on_response)
 
-    def on_response (self, dialog, res):
+    def on_response(self, dialog, res):
         value = None
         if res == gtk.RESPONSE_OK:
-            value = self.get_filename ()
+            value = self.get_filename()
+
+        self.application.set_next_value(value)
+        self.application.put_next_value()
+        self.destroy()
+
+    def execute_operation(self, title, force_prompt=False):
+        self.set_title(ask_free(title))
+        self.show_all()
+
 
-        self.application.set_next_value (value)
-        self.application.put_next_value ()
-        self.destroy ()
+def log_message(*args, **kwargs):
+    return assistant.set_progress_label(*args, **kwargs)
 
-    def execute_operation (self, title, force_prompt=False):
-        self.set_title (ask_free (title))
-        self.show_all ()
-   
-def log_message (*args, **kwargs):
-    return assistant.set_progress_label (*args, **kwargs)
 
-def select_multiple (*args, **kwargs):
+def select_multiple(*args, **kwargs):
     kwargs['multiple'] = True
     kwargs['empty_ok'] = True
-    return menu (*args, **kwargs)
+    return menu(*args, **kwargs)
 
-def get_multiline (prompt, *args, **kwargs):
+
+def get_multiline(prompt, *args, **kwargs):
     if 'ENTER' in prompt:
         # This is a list, let's handle it the best way
-        return get_list (prompt, *args, **kwargs)
+        return get_list(prompt, *args, **kwargs)
     else:
-        return get_multiline (prompt, *args, **kwargs)
-
-pages = { 'get_string': GetStringPage,
-          'get_password': GetPasswordPage,
-          'menu': MenuPage,
-          'handle_bts_query': HandleBTSQueryPage,
-          'show_report': ShowReportPage,
-          'long_message': LongMessagePage,
-          'display_report': DisplayReportPage,
-          'final_message': FinalMessagePage,
-          'spawn_editor': EditorPage,
-          'select_options': SelectOptionsPage,
-          'get_list': GetListPage,
-          'system': SystemPage }
-dialogs = { 'yes_no': YesNoDialog,
-            'get_filename': GetFilenameDialog,
-            'display_failure': DisplayFailureDialog, }
-
-def create_forwarder (parent, klass):
-    def func (*args, **kwargs):
-        op = klass (parent)
+        return get_multiline(prompt, *args, **kwargs)
+
+pages = {'get_string': GetStringPage,
+         'get_password': GetPasswordPage,
+         'menu': MenuPage,
+         'handle_bts_query': HandleBTSQueryPage,
+         'show_report': ShowReportPage,
+         'long_message': LongMessagePage,
+         'display_report': DisplayReportPage,
+         'final_message': FinalMessagePage,
+         'spawn_editor': EditorPage,
+         'select_options': SelectOptionsPage,
+         'get_list': GetListPage,
+         'system': SystemPage,
+         }
+dialogs = {'yes_no': YesNoDialog,
+           'get_filename': GetFilenameDialog,
+           'display_failure': DisplayFailureDialog,
+           }
+
+
+def create_forwarder(parent, klass):
+    def func(*args, **kwargs):
+        op = klass(parent)
         try:
-            args, kwargs = op.sync_pre_operation (*args, **kwargs)
+            args, kwargs = op.sync_pre_operation(*args, **kwargs)
         except SyncReturn, e:
             return e.result
-        application.run_once_in_main_thread (op.execute_operation, *args, **kwargs)
-        return application.get_last_value ()
+        application.run_once_in_main_thread(op.execute_operation, *args, **kwargs)
+        return application.get_last_value()
     return func
-      
-def forward_operations (parent, operations):
-    for operation, klass in operations.iteritems ():
-        globals()[operation] = create_forwarder (parent, klass)
 
-def initialize ():
+
+def forward_operations(parent, operations):
+    for operation, klass in operations.iteritems():
+        globals()[operation] = create_forwarder(parent, klass)
+
+
+def initialize():
     global application, assistant, vte
 
     try:
-        vte = __import__ ("vte")
+        vte = __import__("vte")
     except ImportError:
-        message = """Please install the %s package to use the GTK+ (known as 'gtk2' in reportbug) interface.
+        message = """Please install the %s package to use the GTK+(known as 'gtk2' in reportbug) interface.
 Falling back to 'text' interface."""
-        dialog = gtk.MessageDialog (None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
-                                    gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, None)
-        dialog.set_markup (message % "<b>python-vte</b>")
-        dialog.run ()
-        dialog.destroy ()
-        while gtk.events_pending ():
-            gtk.main_iteration ()
-        if not sys.stdout.isatty ():
-            os.execlp ('x-terminal-emulator', 'x-terminal-emulator', '-e', 'reportbug -u text')
+        dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,
+                                   gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, None)
+        dialog.set_markup(message % "<b>python-vte</b>")
+        dialog.run()
+        dialog.destroy()
+        while gtk.events_pending():
+            gtk.main_iteration()
+        if not sys.stdout.isatty():
+            os.execlp('x-terminal-emulator', 'x-terminal-emulator', '-e', 'reportbug -u text')
         return False
 
     # Exception hook
     oldhook = sys.excepthook
-    sys.excepthook = ExceptionDialog.create_excepthook (oldhook)
+    sys.excepthook = ExceptionDialog.create_excepthook(oldhook)
 
     # GTK settings
-    gtk.window_set_default_icon_from_file (DEBIAN_LOGO)
-    gtk.link_button_set_uri_hook (lambda button, uri: launch_browser (uri))
+    gtk.window_set_default_icon_from_file(DEBIAN_LOGO)
+    gtk.link_button_set_uri_hook(lambda button, uri: launch_browser(uri))
 
-    application = ReportbugApplication ()
-    assistant = ReportbugAssistant (application)
+    application = ReportbugApplication()
+    assistant = ReportbugAssistant(application)
 
     # Forwarders
-    forward_operations (assistant, pages)
-    forward_operations (application, dialogs)
+    forward_operations(assistant, pages)
+    forward_operations(application, dialogs)
 
-    application.start ()
+    application.start()
     return True
 
-def can_input ():
+
+def can_input():
     return True
diff --git a/reportbug/ui/text_ui.py b/reportbug/ui/text_ui.py
index 3544d5c..66851c9 100644
--- a/reportbug/ui/text_ui.py
+++ b/reportbug/ui/text_ui.py
@@ -5,19 +5,19 @@
 #
 # This program is freely distributable per the following license:
 #
-##  Permission to use, copy, modify, and distribute this software and its
-##  documentation for any purpose and without fee is hereby granted,
-##  provided that the above copyright notice appears in all copies and that
-##  both that copyright notice and this permission notice appear in
-##  supporting documentation.
-##
-##  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-##  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
-##  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
-##  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-##  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-##  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-##  SOFTWARE.
+#  Permission to use, copy, modify, and distribute this software and its
+#  documentation for any purpose and without fee is hereby granted,
+#  provided that the above copyright notice appears in all copies and that
+#  both that copyright notice and this permission notice appear in
+#  supporting documentation.
+#
+#  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
+#  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+#  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+#  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+#  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+#  SOFTWARE.
 
 import sys
 import os
@@ -39,7 +39,7 @@ from reportbug import debbugs, hiermatch
 from reportbug.exceptions import (
     NoReport, NoPackage, NoBugs, NoNetwork,
     InvalidRegex,
-    )
+)
 from reportbug.urlutils import launch_browser
 import reportbug.utils
 
@@ -52,6 +52,7 @@ try:
 except:
     rows, columns = 24, 79
 
+
 def ewrite(message, *args):
     if not ISATTY:
         return
@@ -68,6 +69,7 @@ def ewrite(message, *args):
 log_message = ewrite
 display_failure = ewrite
 
+
 def system(cmdline):
     try:
         x = os.getcwd()
@@ -75,19 +77,20 @@ def system(cmdline):
         os.chdir('/')
     return os.system(cmdline)
 
+
 def indent_wrap_text(text, starttext='', indent=0, linelen=None):
     """Wrapper for textwrap.fill to the existing API."""
     if not linelen:
-        linelen = columns-1
+        linelen = columns - 1
 
     if indent:
-        si = ' '*indent
+        si = ' ' * indent
     else:
         si = ''
 
     text = ' '.join(text.split())
     if not text:
-        return starttext+'\n'
+        return starttext + '\n'
 
     output = textwrap.fill(text, width=linelen, initial_indent=starttext,
                            subsequent_indent=si)
@@ -104,20 +107,21 @@ if readline is not None:
     except:
         pass
 
+
 def _launch_mbox_reader(mbox_reader_cmd, bts, bugs, number, mirrors, archived,
                         mbox, http_proxy, timeout):
     try:
         number = int(number)
         if number not in bugs and 1 <= number <= len(bugs):
-            number = bugs[number-1]
+            number = bugs[number - 1]
         reportbug.utils.launch_mbox_reader(mbox_reader_cmd,
-            debbugs.get_report_url(
-                bts, number, mirrors, archived, mbox), http_proxy,
-            timeout)
+                                           debbugs.get_report_url(bts, number, mirrors, archived, mbox),
+                                           http_proxy, timeout)
     except ValueError:
         ewrite('Invalid report number: %s\n',
                number)
 
+
 class our_completer(object):
     def __init__(self, completions=None):
         self.completions = None
@@ -125,7 +129,8 @@ class our_completer(object):
             self.completions = tuple(map(str, completions))
 
     def complete(self, text, i):
-        if not self.completions: return None
+        if not self.completions:
+            return None
 
         matching = [x for x in self.completions if x.startswith(text)]
         if i < len(matching):
@@ -133,7 +138,8 @@ class our_completer(object):
         else:
             return None
 
-def our_raw_input(prompt = None, completions=None, completer=None):
+
+def our_raw_input(prompt=None, completions=None, completer=None):
     istty = sys.stdout.isatty()
     if not istty:
         sys.stderr.write(prompt)
@@ -157,26 +163,30 @@ def our_raw_input(prompt = None, completions=None, completer=None):
         readline.set_completer(None)
     return ret.strip()
 
+
 def select_options(msg, ok, help, allow_numbers=None, nowrap=False):
     err_message = ''
     for option in ok:
         if option in string.ascii_uppercase:
-            default=option
+            default = option
             break
 
-    if not help: help = {}
+    if not help:
+        help = {}
 
-    if '?' not in ok: ok = ok+'?'
+    if '?' not in ok:
+        ok = ok + '?'
 
     if nowrap:
-        longmsg = msg+' ['+'|'.join(ok)+']?'+' '
+        longmsg = msg + ' [' + '|'.join(ok) + ']?' + ' '
     else:
-        longmsg = indent_wrap_text(msg+' ['+'|'.join(ok)+']?').strip()+' '
+        longmsg = indent_wrap_text(msg + ' [' + '|'.join(ok) + ']?').strip() + ' '
     ch = our_raw_input(longmsg, allow_numbers)
     # Allow entry of a bug number here
     if allow_numbers:
-        while ch and ch[0] == '#': ch = ch[1:]
-        if type(allow_numbers) == type(1):
+        while ch and ch[0] == '#':
+            ch = ch[1:]
+        if isinstance(allow_numbers, int):
             try:
                 return str(int(ch))
             except ValueError:
@@ -189,14 +199,15 @@ def select_options(msg, ok, help, allow_numbers=None, nowrap=False):
                 else:
                     nums = list(allow_numbers)
                     nums.sort()
-                    err_message = 'Only the following entries are allowed: '+\
+                    err_message = 'Only the following entries are allowed: ' + \
                                   ', '.join(map(str, nums))
             except (ValueError, TypeError):
                 pass
 
-    if not ch: ch = default
+    if not ch:
+        ch = default
     ch = ch[0]
-    if ch=='?':
+    if ch == '?':
         help['?'] = 'Display this help.'
         for ch in ok:
             if ch in string.ascii_uppercase:
@@ -205,7 +216,7 @@ def select_options(msg, ok, help, allow_numbers=None, nowrap=False):
                 desc = ''
             desc += help.get(ch, help.get(ch.lower(),
                                           'No help for this option.'))
-            ewrite(indent_wrap_text(desc+'\n', '%s - '% ch, 4))
+            ewrite(indent_wrap_text(desc + '\n', '%s - ' % ch, 4))
         return select_options(msg, ok, help, allow_numbers, nowrap)
     elif (ch.lower() in ok) or (ch.upper() in ok):
         return ch.lower()
@@ -216,6 +227,7 @@ def select_options(msg, ok, help, allow_numbers=None, nowrap=False):
 
     return select_options(msg, ok, help, allow_numbers, nowrap)
 
+
 def yes_no(msg, yeshelp, nohelp, default=True, nowrap=False):
     "Return True for yes, False for no."
     if default:
@@ -223,12 +235,13 @@ def yes_no(msg, yeshelp, nohelp, default=True, nowrap=False):
     else:
         ok = 'yNq'
 
-    res = select_options(msg, ok, {'y': yeshelp, 'n': nohelp, 'q' : 'Quit.'},
+    res = select_options(msg, ok, {'y': yeshelp, 'n': nohelp, 'q': 'Quit.'},
                          nowrap=nowrap)
     if res == 'q':
         raise SystemExit
     return (res == 'y')
 
+
 def long_message(text, *args):
     if args:
         ewrite(indent_wrap_text(text % args))
@@ -237,9 +250,10 @@ def long_message(text, *args):
 
 final_message = long_message
 
+
 def get_string(prompt, options=None, title=None, empty_ok=False, force_prompt=False,
                default='', completer=None):
-    if prompt and (len(prompt) < 2*columns/3) and not force_prompt:
+    if prompt and (len(prompt) < 2 * columns / 3) and not force_prompt:
         if default:
             prompt = '%s [%s]: ' % (prompt, default)
             response = our_raw_input(prompt, options, completer) or default
@@ -259,6 +273,7 @@ def get_string(prompt, options=None, title=None, empty_ok=False, force_prompt=Fa
 
     return response
 
+
 def get_multiline(prompt):
     ewrite('\n')
     ewrite(indent_wrap_text(prompt + "  Press ENTER on a blank line to continue.\n"))
@@ -271,31 +286,37 @@ def get_multiline(prompt):
     ewrite('\n')
     return l
 
+
 def get_password(prompt=None):
     return getpass.getpass(prompt)
 
+
 def FilenameCompleter(text, i):
     text = os.path.expanduser(text)
     text = os.path.expandvars(text)
-    paths = glob.glob(text+'*')
-    if not paths: return None
+    paths = glob.glob(text + '*')
+    if not paths:
+        return None
 
     if i < len(paths):
         entry = paths[i]
         if os.path.isdir(entry):
-            return entry+'/'
+            return entry + '/'
         return entry
     else:
         return None
 
+
 def get_filename(prompt, title=None, force_prompt=False, default=''):
     return get_string(prompt, title=title, force_prompt=force_prompt,
                       default=default, completer=FilenameCompleter)
 
+
 def select_multiple(par, options, prompt, title=None, order=None, extras=None):
     return menu(par, options, prompt, title=title, order=order, extras=extras,
                 multiple=True, empty_ok=False)
 
+
 def menu(par, options, prompt, default=None, title=None, any_ok=False,
          order=None, extras=None, multiple=False, empty_ok=False):
     selected = {}
@@ -306,9 +327,9 @@ def menu(par, options, prompt, default=None, title=None, any_ok=False,
         extras = list(extras)
 
     if title:
-        ewrite(title+'\n\n')
+        ewrite(title + '\n\n')
 
-    ewrite(indent_wrap_text(par, linelen=columns)+'\n')
+    ewrite(indent_wrap_text(par, linelen=columns) + '\n')
 
     if isinstance(options, dict):
         options = options.copy()
@@ -316,40 +337,39 @@ def menu(par, options, prompt, default=None, title=None, any_ok=False,
         if order:
             olist = []
             for key in order:
-                if options.has_key(key):
-                    olist.append( (key, options[key]) )
+                if key in options:
+                    olist.append((key, options[key]))
                     del options[key]
 
             # Append anything out of order
             options = options.items()
             options.sort()
             for option in options:
-                olist.append( option )
+                olist.append(option)
             options = olist
         else:
             options = options.items()
             options.sort()
 
     if multiple:
-        options.append( ('none', '') )
+        options.append(('none', ''))
         default = 'none'
         extras += ['done']
 
     allowed = map(lambda x: x[0], options)
     allowed = allowed + extras
 
-    maxlen_name = min(max(map(len, allowed)), columns/3)
-    digits = int(math.ceil(math.log10(len(options)+1)))
+    maxlen_name = min(max(map(len, allowed)), columns / 3)
+    digits = int(math.ceil(math.log10(len(options) + 1)))
 
     i = 1
     for name, desc in options:
-        text = indent_wrap_text(desc, indent=(maxlen_name+digits+3),
-                                starttext=('%*d %-*.*s  ' % (
-            digits, i, maxlen_name, maxlen_name, name)))
+        text = indent_wrap_text(desc, indent=(maxlen_name + digits + 3),
+                                starttext=('%*d %-*.*s  ' % (digits, i, maxlen_name, maxlen_name, name)))
         ewrite(text)
         if len(options) < 5:
             ewrite('\n')
-        i = i+1
+        i += 1
     if len(options) >= 5:
         ewrite('\n')
 
@@ -363,12 +383,13 @@ def menu(par, options, prompt, default=None, title=None, any_ok=False,
             aprompt = prompt
 
         response = our_raw_input(aprompt, allowed)
-        if not response: response = default
+        if not response:
+            response = default
 
         try:
             num = int(response)
             if 1 <= num <= len(options):
-                response = options[num-1][0]
+                response = options[num - 1][0]
         except (ValueError, TypeError):
             pass
 
@@ -381,7 +402,7 @@ def menu(par, options, prompt, default=None, title=None, any_ok=False,
                 elif selected.get(response):
                     del selected[response]
                 else:
-                    selected[response]=1
+                    selected[response] = 1
                 ewrite('- selected: %s\n' % ', '.join(selected.keys()))
                 if len(selected):
                     default = 'done'
@@ -399,6 +420,7 @@ def menu(par, options, prompt, default=None, title=None, any_ok=False,
         ewrite('Invalid entry.\n')
     return
 
+
 # Things that are very UI dependent go here
 def show_report(number, system, mirrors,
                 http_proxy, timeout, screen=None, queryonly=False, title='',
@@ -409,8 +431,7 @@ def show_report(number, system, mirrors,
 
     try:
         info = debbugs.get_report(number, timeout, system, mirrors=mirrors,
-                                    followups=1,
-                                    http_proxy=http_proxy, archived=archived)
+                                  followups=1, http_proxy=http_proxy, archived=archived)
     except:
         info = None
 
@@ -431,7 +452,7 @@ def show_report(number, system, mirrors,
     while 1:
         if current_message:
             text = 'Followup %d - %s\n\n%s' % (current_message, buginfo.subject,
-                                                 messages[current_message])
+                                               messages[current_message])
         else:
             text = 'Original report - %s\n\n%s' % (buginfo.subject, messages[0])
 
@@ -449,23 +470,21 @@ def show_report(number, system, mirrors,
 
         options = 'xOrbeq'
 
-        if (current_message+1) < len(messages):
-            options = 'N'+options.lower()
+        if (current_message + 1) < len(messages):
+            options = 'N' + options.lower()
         if (current_message):
-            options = 'p'+options
+            options = 'p' + options
 
         x = select_options("What do you want to do now?", options,
-                           {'x' : 'Provide extra information.',
-                            'o' : 'Show other bug reports (return to '
-                            'bug listing).',
-                            'n' : 'Show next message (followup).',
-                            'p' : 'Show previous message (followup).',
-                            'r' : 'Redisplay this message.',
-                            'e' : 'Launch e-mail client to read full log.',
-                            'b' : 'Launch web browser to read '
-                            'full log.',
-                            'q' : "I'm bored; quit please."},
-                           allow_numbers = range(1, len(messages)+1))
+                           {'x': 'Provide extra information.',
+                            'o': 'Show other bug reports (return to bug listing).',
+                            'n': 'Show next message (followup).',
+                            'p': 'Show previous message (followup).',
+                            'r': 'Redisplay this message.',
+                            'e': 'Launch e-mail client to read full log.',
+                            'b': 'Launch web browser to read full log.',
+                            'q': "I'm bored; quit please."},
+                           allow_numbers=range(1, len(messages) + 1))
         if x == 'x':
             return buginfo
         elif x == 'q':
@@ -476,9 +495,8 @@ def show_report(number, system, mirrors,
             skip_pager = True
         elif x == 'e':
             reportbug.utils.launch_mbox_reader(mbox_reader_cmd,
-                debbugs.get_report_url(
-                    system, number, mirrors, archived, True), http_proxy,
-                    timeout)
+                                               debbugs.get_report_url(system, number, mirrors, archived, True),
+                                               http_proxy, timeout)
             skip_pager = True
         elif x == 'o':
             break
@@ -488,6 +506,7 @@ def show_report(number, system, mirrors,
             current_message -= 1
     return
 
+
 def handle_bts_query(package, bts, timeout, mirrors=None, http_proxy="",
                      queryonly=False, title="", screen=None, archived='no',
                      source=False, version=None, mbox=False, buglist=None,
@@ -512,13 +531,13 @@ def handle_bts_query(package, bts, timeout, mirrors=None, http_proxy="",
 
     bugs = []
     try:
-        (count, title, hierarchy)=debbugs.get_reports(
+        (count, title, hierarchy) = debbugs.get_reports(
             package, timeout, bts, mirrors=mirrors, version=version,
             source=source, http_proxy=http_proxy, archived=archived)
 
         # If there's no report, then skip all the rest
         if not count:
-            if hierarchy == None:
+            if hierarchy is None:
                 raise NoPackage
             else:
                 raise NoBugs
@@ -536,7 +555,7 @@ def handle_bts_query(package, bts, timeout, mirrors=None, http_proxy="",
             for entry in hierarchy:
                 # second item is a list of bugs report
                 for bug in entry[1]:
-                    msg = "#%d  %s" %(bug.bug_num, bug.subject)
+                    msg = "#%d  %s" % (bug.bug_num, bug.subject)
                     msg = msg.encode(charset, 'replace')
                     print msg
             sys.exit(0)
@@ -567,7 +586,7 @@ def handle_bts_query(package, bts, timeout, mirrors=None, http_proxy="",
         hierarchy = hierarchy_new
 
         if not count:
-            if hierarchy == None:
+            if hierarchy is None:
                 raise NoPackage
             else:
                 raise NoBugs
@@ -591,6 +610,7 @@ def handle_bts_query(package, bts, timeout, mirrors=None, http_proxy="",
         long_message('No record of this package found.')
         raise NoPackage
 
+
 def browse_bugs(hierarchy, count, bugs, bts, queryonly, mirrors,
                 http_proxy, timeout, screen, title, package, mbox_reader_cmd):
     try:
@@ -603,65 +623,65 @@ def browse_bugs(hierarchy, count, bugs, bts, queryonly, mirrors,
     category = hierarchy[0]
     lastpage = []
     digits = len(str(len(bugs)))
-    linefmt = '  %'+str(digits)+'d) %s\n'
+    linefmt = '  %' + str(digits) + 'd) %s\n'
     while category:
-        scount = scount + 1
+        scount += 1
         catname, reports = category[0:2]
-        while catname.endswith(':'): catname = catname[:-1]
+        while catname.endswith(':'):
+            catname = catname[:-1]
         total = len(reports)
 
         while len(reports):
-            these = reports[:rows-2]
-            reports = reports[rows-2:]
+            these = reports[:rows - 2]
+            reports = reports[rows - 2:]
             remain = len(reports)
 
             tplural = rplural = 's'
-            if total == 1: tplural=''
-            if remain != 1: rplural=''
+            if total == 1:
+                tplural = ''
+            if remain != 1:
+                rplural = ''
 
             if remain:
                 lastpage.append(' %s: %d remain%s\n' %
                                 (catname, remain, rplural))
             else:
-                lastpage.append(catname+'\n')
+                lastpage.append(catname + '\n')
 
             oldscount, oldecount = scount, endcount
             for report in these:
                 scount = scount + 1
                 endcount = endcount + 1
-                lastpage.append(linefmt % (endcount,report[:columns-digits-5]))
+                lastpage.append(linefmt % (endcount, report[:columns - digits - 5]))
 
             if category == hierarchy[-1] or \
-               (scount >= (rows - len(hierarchy[catcount+1][1]) - 1)):
+               (scount >= (rows - len(hierarchy[catcount + 1][1]) - 1)):
                 skipmsg = ' (s to skip rest)'
                 if endcount == count:
                     skipmsg = ''
 
                 options = 'yNbmrqsfe'
-                if queryonly: options = 'Nbmrqfe'
+                if queryonly:
+                    options = 'Nbmrqfe'
 
                 rstr = "(%d-%d/%d) " % (startcount, endcount, count)
                 pstr = rstr + "Is the bug you found listed above"
                 if queryonly:
                     pstr = rstr + "What would you like to do next"
-                allowed = bugs+range(1, count+1)
+                allowed = bugs + range(1, count + 1)
                 helptext = {
-                    'y' : 'Problem already reported; optionally '
-                    'add extra information.',
-                    'n' : 'Problem not listed above; possibly '
-                    'check more.',
-                    'b' : 'Open the complete bugs list in a web browser.',
-                    'm' : 'Get more information about a bug (you '
-                    'can also enter a number\n'
-                    '     without selecting "m" first).',
-                    'r' : 'Redisplay the last bugs shown.',
-                    'q' : "I'm bored; quit please.",
-                    's' : 'Skip remaining problems; file a new '
-                    'report immediately.',
-                    'e' : 'Open the report using an e-mail client.',
-                    'f' : 'Filter bug list using a pattern.'}
+                    'y': 'Problem already reported; optionally add extra information.',
+                    'n': 'Problem not listed above; possibly check more.',
+                    'b': 'Open the complete bugs list in a web browser.',
+                    'm': 'Get more information about a bug (you can also enter a number\n'
+                         '     without selecting "m" first).',
+                    'r': 'Redisplay the last bugs shown.',
+                    'q': "I'm bored; quit please.",
+                    's': 'Skip remaining problems; file a new report immediately.',
+                    'e': 'Open the report using an e-mail client.',
+                    'f': 'Filter bug list using a pattern.'}
                 if skipmsg:
-                    helptext['n'] = helptext['n'][:-1]+' (skip to Next page).'
+                    helptext['n'] = helptext['n'][:-1] + ' (skip to Next page).'
 
                 while 1:
                     for line in lastpage:
@@ -692,32 +712,28 @@ def browse_bugs(hierarchy, count, bugs, bts, queryonly, mirrors,
                                 'you want to give more info on,\n'
                                 'or press ENTER to exit: #', allowed)
                         while number and number[0] == '#':
-                            number=number[1:]
+                            number = number[1:]
                         if number:
                             try:
                                 number = int(number)
                                 if number not in bugs and 1 <= number <= len(bugs):
-                                    number = bugs[number-1]
+                                    number = bugs[number - 1]
                                 return debbugs.get_report(number, timeout)[0]
                             except ValueError:
                                 ewrite('Invalid report number: %s\n',
                                        number)
                         else:
                             raise NoReport
-		    elif x == 'f':
-			# Do filter. Recursive done.
-			retval = search_bugs(hierarchy,bts, queryonly, mirrors,
-                                             http_proxy, timeout, screen, title,
+                    elif x == 'f':
+                        # Do filter. Recursive done.
+                        retval = search_bugs(hierarchy, bts, queryonly, mirrors, http_proxy, timeout, screen, title,
                                              package, mbox_reader_cmd)
-			if isinstance(retval, basestring) and \
-                                retval in ["FilterEnd", "Top"]:
-			    continue
-			else:
-			    return retval
+                        if isinstance(retval, basestring) and retval in ["FilterEnd", "Top"]:
+                            continue
+                        else:
+                            return retval
                     elif x == 'e':
-                        number = our_raw_input('Please enter the number of the '
-                            'bug you would like to view: #',
-                            allowed)
+                        number = our_raw_input('Please enter the number of the bug you would like to view: #', allowed)
                         _launch_mbox_reader(mbox_reader_cmd, bts, bugs, number,
                                             mirrors, 'no', True, http_proxy,
                                             timeout)
@@ -726,21 +742,19 @@ def browse_bugs(hierarchy, count, bugs, bts, queryonly, mirrors,
                             if len(bugs) == 1:
                                 number = '1'
                             else:
-                                number = our_raw_input(
-                                    'Please enter the number of the bug '
-                                    'you would like more info on: #',
-                                    allowed)
+                                number = our_raw_input('Please enter the number of the bug '
+                                                       'you would like more info on: #', allowed)
                         else:
                             number = x
 
                         while number and number[0] == '#':
-                            number=number[1:]
+                            number = number[1:]
 
                         if number:
                             try:
                                 number = int(number)
                                 if number not in bugs and 1 <= number <= len(bugs):
-                                    number = bugs[number-1]
+                                    number = bugs[number - 1]
                                 res = show_report(number, bts, mirrors,
                                                   http_proxy, timeout,
                                                   queryonly=queryonly,
@@ -753,38 +767,41 @@ def browse_bugs(hierarchy, count, bugs, bts, queryonly, mirrors,
                                 ewrite('Invalid report number: %s\n',
                                        number)
 
-                startcount = endcount+1
-                scount = 0
+            startcount = endcount + 1
+            scount = 0
 
             # these now empty
 
-        if category == hierarchy[-1]: break
+        if category == hierarchy[-1]:
+            break
 
-        catcount = catcount+1
+        catcount = catcount + 1
         category = hierarchy[catcount]
         if scount:
             lastpage.append('\n')
             scount = scount + 1
 
+
 def proc_hierarchy(hierarchy):
     """Find out bug count and bug # in the hierarchy."""
 
     lenlist = [len(i[1]) for i in hierarchy]
     if lenlist:
-	count = reduce(lambda x, y: x+y, lenlist)
+        count = reduce(lambda x, y: x + y, lenlist)
     else:
-	return 0, 0
+        return 0, 0
 
     # Copy & paste from handle_bts_query()
     bugs = []
     exp = re.compile(r'\#(\d+)[ :]')
     for entry in hierarchy or []:
-	for bug in entry[1]:
-	    match = exp.match(bug)
-	    if match:
-		bugs.append(int(match.group(1)))
+        for bug in entry[1]:
+            match = exp.match(bug)
+            if match:
+                bugs.append(int(match.group(1)))
     return count, bugs
 
+
 def search_bugs(hierarchyfull, bts, queryonly, mirrors,
                 http_proxy, timeout, screen, title, package, mbox_reader_cmd):
     """Search for the bug list using a pattern."""
@@ -796,48 +813,50 @@ def search_bugs(hierarchyfull, bts, queryonly, mirrors,
         print msg
         sys.exit(1)
 
-    pattern = our_raw_input(
-	'Enter the search pattern (a Perl-compatible regular expression)\n'
-	'or press ENTER to exit: ')
+    pattern = our_raw_input('Enter the search pattern (a Perl-compatible regular expression)\n'
+                            'or press ENTER to exit: ')
     if not pattern:
-	return "FilterEnd"
+        return "FilterEnd"
 
-    " Create new hierarchy match the pattern."
+    # Create new hierarchy match the pattern.
     try:
         hierarchy = hiermatch.matched_hierarchy(hierarchyfull, pattern)
     except InvalidRegex:
-	our_raw_input('Invalid regular expression, press ENTER to continue.')
-	return "FilterEnd"
+        our_raw_input('Invalid regular expression, press ENTER to continue.')
+        return "FilterEnd"
 
     count, bugs = proc_hierarchy(hierarchy)
     exp = re.compile(r'\#(\d+):')
 
     if not count:
-	our_raw_input('No match found, press ENTER to continue.')
-	return "FilterEnd"
+        our_raw_input('No match found, press ENTER to continue.')
+        return "FilterEnd"
 
     endcount = catcount = 0
     scount = startcount = 1
     category = hierarchy[0]
     lastpage = []
     digits = len(str(len(bugs)))
-    linefmt = '  %'+str(digits)+'d) %s\n'
+    linefmt = '  %' + str(digits) + 'd) %s\n'
     # XXX: it's kinda non-sense to replicate all this code here!!! it's the same
     # as of browse_report!
     while category:
         scount = scount + 1
         catname, reports = category[0:2]
-        while catname.endswith(':'): catname = catname[:-1]
+        while catname.endswith(':'):
+            catname = catname[:-1]
         total = len(reports)
 
         while len(reports):
-            these = reports[:rows-2]
-            reports = reports[rows-2:]
+            these = reports[:rows - 2]
+            reports = reports[rows - 2:]
             remain = len(reports)
 
             tplural = rplural = 's'
-            if total == 1: tplural=''
-            if remain != 1: rplural=''
+            if total == 1:
+                tplural = ''
+            if remain != 1:
+                rplural = ''
 
             if remain:
                 lastpage.append(' %s: %d report%s (%d remain%s)\n' %
@@ -850,41 +869,38 @@ def search_bugs(hierarchyfull, bts, queryonly, mirrors,
             for report in these:
                 scount = scount + 1
                 endcount = endcount + 1
-                lastpage.append(linefmt % (endcount,report[:columns-digits-5]))
+                lastpage.append(linefmt % (endcount, report[:columns - digits - 5]))
 
             if category == hierarchy[-1] or \
-               (scount >= (rows - len(hierarchy[catcount+1][1]) - 1)):
+               (scount >= (rows - len(hierarchy[catcount + 1][1]) - 1)):
                 skipmsg = ' (s to skip rest)'
                 if endcount == count:
                     skipmsg = ''
 
                 options = 'yNbmrqsfute'
-                if queryonly: options = 'Nmbrqfute'
+                if queryonly:
+                    options = 'Nmbrqfute'
 
                 rstr = "(%d-%d/%d) " % (startcount, endcount, count)
                 pstr = rstr + "Is the bug you found listed above"
                 if queryonly:
                     pstr = rstr + "What would you like to do next"
-                allowed = bugs+range(1, count+1)
+                allowed = bugs + range(1, count + 1)
                 helptext = {
-                    'y' : 'Problem already reported; optionally '
-                    'add extra information.',
-                    'n' : 'Problem not listed above; possibly '
-                    'check more.',
-                    'b' : 'Open the complete bugs list in a web browser.',
-                    'm' : 'Get more information about a bug (you '
-                    'can also enter a number\n'
-                    '     without selecting "m" first).',
-                    'r' : 'Redisplay the last bugs shown.',
-                    'q' : "I'm bored; quit please.",
-                    's' : 'Skip remaining problems; file a new '
-                    'report immediately.',
-		    'f' : 'Filter (search) bug list using a pattern.',
-		    'u' : 'Up one level of filter.',
-                    'e' : 'Open the report using an e-mail client.',
-		    't' : 'Top of the bug list (remove all filters).'}
+                    'y': 'Problem already reported; optionally add extra information.',
+                    'n': 'Problem not listed above; possibly check more.',
+                    'b': 'Open the complete bugs list in a web browser.',
+                    'm': 'Get more information about a bug (you can also enter a number\n'
+                         '     without selecting "m" first).',
+                    'r': 'Redisplay the last bugs shown.',
+                    'q': "I'm bored; quit please.",
+                    's': 'Skip remaining problems; file a new report immediately.',
+                    'f': 'Filter (search) bug list using a pattern.',
+                    'u': 'Up one level of filter.',
+                    'e': 'Open the report using an e-mail client.',
+                    't': 'Top of the bug list (remove all filters).'}
                 if skipmsg:
-                    helptext['n'] = helptext['n'][:-1]+' (skip to Next page).'
+                    helptext['n'] = helptext['n'][:-1] + ' (skip to Next page).'
 
                 while 1:
                     for line in lastpage:
@@ -914,40 +930,37 @@ def search_bugs(hierarchyfull, bts, queryonly, mirrors,
                                 'you want to give more info on,\n'
                                 'or press ENTER to exit: #', allowed)
                         while number and number[0] == '#':
-                            number=number[1:]
+                            number = number[1:]
                         if number:
                             try:
                                 number = int(number)
                                 if number not in bugs and 1 <= number <= len(bugs):
-                                    number = bugs[number-1]
+                                    number = bugs[number - 1]
                                 return debbugs.get_report(number, timeout)[0]
                             except ValueError:
                                 ewrite('Invalid report number: %s\n',
                                        number)
                         else:
                             raise NoReport
-		    elif x == 'f':
-			# Do filter. Recursive done.
-			retval = search_bugs(hierarchy, bts, queryonly, mirrors,
-			    http_proxy, timeout, screen, title, package,
-                            mbox_reader_cmd)
-			if retval == "FilterEnd":
-			    continue
-			else:
-			    return retval
-		    elif x == 'u':
-			# Up a level
-			return "FilterEnd"
-		    elif x == 't':
-			# go back to the Top level.
-			return "Top"
+                    elif x == 'f':
+                        # Do filter. Recursive done.
+                        retval = search_bugs(hierarchy, bts, queryonly, mirrors, http_proxy, timeout, screen,
+                                             title, package, mbox_reader_cmd)
+                        if retval == "FilterEnd":
+                            continue
+                        else:
+                            return retval
+                    elif x == 'u':
+                        # Up a level
+                        return "FilterEnd"
+                    elif x == 't':
+                        # go back to the Top level.
+                        return "Top"
                     elif x == 'e':
                         number = our_raw_input('Please enter the number of the '
-                            'bug you would like to view: #',
-                            allowed)
+                                               'bug you would like to view: #', allowed)
                         _launch_mbox_reader(mbox_reader_cmd, bts, bugs, number,
-                                            mirrors, 'no', True, http_proxy,
-                                            timeout)
+                                            mirrors, 'no', True, http_proxy, timeout)
                     else:
                         if x == 'm' or x == 'i':
                             number = our_raw_input(
@@ -958,13 +971,13 @@ def search_bugs(hierarchyfull, bts, queryonly, mirrors,
                             number = x
 
                         while number and number[0] == '#':
-                            number=number[1:]
+                            number = number[1:]
 
                         if number:
                             try:
                                 number = int(number)
                                 if number not in bugs and 1 <= number <= len(bugs):
-                                    number = bugs[number-1]
+                                    number = bugs[number - 1]
                                 res = show_report(number, bts, mirrors,
                                                   http_proxy, timeout,
                                                   queryonly=queryonly,
@@ -973,23 +986,24 @@ def search_bugs(hierarchyfull, bts, queryonly, mirrors,
                                 if res:
                                     return res
                             except ValueError:
-                                ewrite('Invalid report number: %s\n',
-                                       number)
+                                ewrite('Invalid report number: %s\n', number)
 
-                startcount = endcount+1
+                startcount = endcount + 1
                 scount = 0
 
             # these now empty
 
-        if category == hierarchy[-1]: break
+        if category == hierarchy[-1]:
+            break
 
-        catcount = catcount+1
+        catcount += 1
         category = hierarchy[catcount]
         if scount:
             lastpage.append('\n')
-            scount = scount + 1
+            scount += 1
     return "FilterEnd"
 
+
 def display_report(text, use_pager=True, presubj=False):
     if not use_pager:
         ewrite(text)
@@ -1003,6 +1017,7 @@ def display_report(text, use_pager=True, presubj=False):
     except IOError:
         pass
 
+
 def spawn_editor(message, filename, editor, charset='utf-8'):
     if not editor:
         ewrite('No editor found!\n')
@@ -1015,9 +1030,6 @@ def spawn_editor(message, filename, editor, charset='utf-8'):
     for (lineno, line) in enumerate(file(filename)):
         if line == '\n' and not ourline:
             ourline = lineno + 2
-        # Morph @ 2008-08-31
-        #elif line.strip() == utils.NEWBIELINE:
-        #    ourline = lineno + 2
 
     opts = ''
     if 'vim' in edname:
@@ -1050,7 +1062,8 @@ def spawn_editor(message, filename, editor, charset='utf-8'):
         ewrite('Bug report file %s removed!', filename)
         sys.exit(1)
 
-    if '&' in editor: return (None, 1)
+    if '&' in editor:
+        return (None, 1)
 
     newmessage = file(filename).read().decode(charset, 'replace')
 
@@ -1059,8 +1072,10 @@ def spawn_editor(message, filename, editor, charset='utf-8'):
 
     return (newmessage, newmessage != message)
 
-def initialize ():
+
+def initialize():
     return True
 
+
 def can_input():
     return sys.stdin.isatty()
diff --git a/reportbug/ui/urwid_ui.py b/reportbug/ui/urwid_ui.py
index 675301d..49e7424 100644
--- a/reportbug/ui/urwid_ui.py
+++ b/reportbug/ui/urwid_ui.py
@@ -5,19 +5,19 @@
 #
 # This program is freely distributable per the following license:
 #
-##  Permission to use, copy, modify, and distribute this software and its
-##  documentation for any purpose and without fee is hereby granted,
-##  provided that the above copyright notice appears in all copies and that
-##  both that copyright notice and this permission notice appear in
-##  supporting documentation.
-##
-##  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-##  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
-##  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
-##  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-##  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-##  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-##  SOFTWARE.
+#  Permission to use, copy, modify, and distribute this software and its
+#  documentation for any purpose and without fee is hereby granted,
+#  provided that the above copyright notice appears in all copies and that
+#  both that copyright notice and this permission notice appear in
+# supporting documentation.
+#
+#  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
+#  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+#  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+#  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+#  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+#  SOFTWARE.
 #
 # Portions of this file are licensed under the Lesser GNU Public License
 # (LGPL) Version 2.1 or later.  On Debian systems, this license is available
@@ -29,25 +29,26 @@ import getpass
 from reportbug.exceptions import (
     UINotImportable,
     NoPackage, NoBugs, NoNetwork, NoReport,
-    )
+)
 from reportbug.urlutils import launch_browser
 from text_ui import (
     ewrite,
     spawn_editor,
     system
-    )
+)
 from reportbug import VERSION
 
 try:
     import urwid.raw_display
     import urwid
 except ImportError:
-    raise UINotImportable, 'Please install the python-urwid package to use this interface.'
+    raise UINotImportable('Please install the python-urwid package to use this interface.')
 
 ISATTY = sys.stdin.isatty()
 
 log_message = ewrite
 
+
 # Start a urwid session
 def initialize_urwid_ui():
     ui = urwid.raw_display.Screen()
@@ -56,33 +57,38 @@ def initialize_urwid_ui():
     ui.set_input_timeouts(max_wait=0.1)
     return ui
 
+
 # Empty function to satisfy ui.run_wrapper()
 def nullfunc():
     pass
 
+
 # Widgets ripped mercilessly from urwid examples (dialog.py)
 class buttonpush(Exception):
     pass
 
+
 def button_press(button):
-    raise buttonpush, button.exitcode
+    raise buttonpush(button.exitcode)
+
 
 class SelectableText(urwid.Edit):
     def valid_char(self, ch):
         return False
 
+
 class dialog(object):
     def __init__(self, message, body=None, width=None, height=None,
                  title='', long_message=''):
         self.body = body
 
-        self.scrollmode=False
+        self.scrollmode = False
         if not body:
             if long_message:
                 box = SelectableText(edit_text=long_message)
                 box.set_edit_pos(0)
                 self.body = body = urwid.ListBox([box])
-                self.scrollmode=True
+                self.scrollmode = True
             else:
                 self.body = body = urwid.Filler(urwid.Divider(), 'top')
 
@@ -99,21 +105,21 @@ class dialog(object):
 
         w = self.frame
         # pad area around listbox
-        w = urwid.Padding(w, ('fixed left',2), ('fixed right',2))
-        w = urwid.Filler(w, ('fixed top',1), ('fixed bottom',1))
+        w = urwid.Padding(w, ('fixed left', 2), ('fixed right', 2))
+        w = urwid.Filler(w, ('fixed top', 1), ('fixed bottom', 1))
         w = urwid.AttrWrap(w, 'body')
 
         if title:
             w = urwid.Frame(w)
-            w.header = urwid.Text( ('title', title) )
+            w.header = urwid.Text(('title', title))
 
         # "shadow" effect
-        w = urwid.Columns( [w, ('fixed', 1, urwid.AttrWrap( urwid.Filler(urwid.Text(('border',' ')), "top") ,'shadow'))])
-        w = urwid.Frame( w, footer = urwid.AttrWrap(urwid.Text(('border',' ')),'shadow'))
+        w = urwid.Columns([w, ('fixed', 1, urwid.AttrWrap(urwid.Filler(urwid.Text(('border', ' ')), "top"), 'shadow'))])
+        w = urwid.Frame(w, footer=urwid.AttrWrap(urwid.Text(('border', ' ')), 'shadow'))
         # outermost border area
-        w = urwid.Padding(w, 'center', width )
-        w = urwid.Filler(w, 'middle', height )
-        w = urwid.AttrWrap( w, 'border' )
+        w = urwid.Padding(w, 'center', width)
+        w = urwid.Filler(w, 'middle', height)
+        w = urwid.AttrWrap(w, 'border')
         self.view = w
 
     def add_buttons(self, buttons, default=0, vertical=False):
@@ -122,12 +128,12 @@ class dialog(object):
             if exitcode == '---':
                 # Separator is just a text label
                 b = urwid.Text(name)
-                b = urwid.AttrWrap( b, 'scrolllabel' )
+                b = urwid.AttrWrap(b, 'scrolllabel')
             else:
-                b = urwid.Button( name, self.button_press )
+                b = urwid.Button(name, self.button_press)
                 b.exitcode = exitcode
-                b = urwid.AttrWrap( b, 'selectable','focus' )
-            l.append( b )
+                b = urwid.AttrWrap(b, 'selectable', 'focus')
+            l.append(b)
 
         if vertical:
             box = urwid.ListBox(l)
@@ -137,35 +143,35 @@ class dialog(object):
         else:
             self.buttons = urwid.GridFlow(l, 12, 3, 1, 'center')
             self.buttons.set_focus(default or 0)
-            self.frame.footer = urwid.Pile( [ urwid.Divider(), self.buttons ],
-                                            focus_item = 1 )
+            self.frame.footer = urwid.Pile([urwid.Divider(), self.buttons],
+                                           focus_item=1)
 
     def button_press(self, button):
-        raise buttonpush, button.exitcode
+        raise buttonpush(button.exitcode)
 
     def run(self):
-        #self.ui.set_mouse_tracking()
+        # self.ui.set_mouse_tracking()
         size = self.ui.get_cols_rows()
         try:
             while True:
-                canvas = self.view.render( size, focus=True )
-                self.ui.draw_screen( size, canvas )
+                canvas = self.view.render(size, focus=True)
+                self.ui.draw_screen(size, canvas)
                 keys = None
                 while not keys:
                     keys = self.ui.get_input()
                 for k in keys:
                     if urwid.util.is_mouse_event(k):
                         event, button, col, row = k
-                        self.view.mouse_event( size,
-                                               event, button, col, row,
-                                               focus=True)
+                        self.view.mouse_event(size,
+                                              event, button, col, row,
+                                              focus=True)
                     if k == 'window resize':
                         size = self.ui.get_cols_rows()
-                    k = self.view.keypress( size, k )
+                    k = self.view.keypress(size, k)
                     if k:
-                        self.unhandled_key( size, k)
+                        self.unhandled_key(size, k)
         except buttonpush, e:
-            return self.on_exit( e.args[0] )
+            return self.on_exit(e.args[0])
 
     def on_exit(self, exitcode):
         return exitcode
@@ -178,7 +184,7 @@ class dialog(object):
             else:
                 self.frame.set_focus('footer')
 
-        if k in ('up','page up', 'down', 'page down'):
+        if k in ('up', 'page up', 'down', 'page down'):
             if self.scrollmode:
                 self.frame.set_focus('body')
                 self.body.keypress(size, k)
@@ -190,7 +196,7 @@ class dialog(object):
         if k == 'enter':
             # pass enter to the "ok" button
             self.frame.set_focus('footer')
-            self.view.keypress( size, k )
+            self.view.keypress(size, k)
 
     def main(self, ui=None):
         if ui:
@@ -199,6 +205,7 @@ class dialog(object):
             self.ui = initialize_urwid_ui()
         return self.ui.run_wrapper(self.run)
 
+
 class displaybox(dialog):
     def show(self, ui=None):
         if ui:
@@ -206,11 +213,12 @@ class displaybox(dialog):
         else:
             self.ui = initialize_urwid_ui()
         size = self.ui.get_cols_rows()
-        canvas = self.view.render( size, focus=True )
+        canvas = self.view.render(size, focus=True)
         self.ui.start()
-        self.ui.draw_screen( size, canvas )
+        self.ui.draw_screen(size, canvas)
         self.ui.stop()
 
+
 class textentry(dialog):
     def __init__(self, text, width=None, height=None, multiline=False,
                  title='', edit_text=''):
@@ -218,7 +226,7 @@ class textentry(dialog):
         body = urwid.ListBox([self.edit])
         body = urwid.AttrWrap(body, 'selectable', 'focustext')
         if not multiline:
-            body = urwid.Pile( [('fixed', 1, body), urwid.Divider()] )
+            body = urwid.Pile([('fixed', 1, body), urwid.Divider()])
             body = urwid.Filler(body)
 
         dialog.__init__(self, text, body, width, height, title)
@@ -228,6 +236,7 @@ class textentry(dialog):
     def on_exit(self, exitcode):
         return exitcode, self.edit.get_edit_text()
 
+
 class listdialog(dialog):
     def __init__(self, text, widgets, has_default=False, width=None,
                  height=None, title='', buttonwidth=12):
@@ -236,13 +245,13 @@ class listdialog(dialog):
         for (w, label) in widgets:
             self.items.append(w)
             if label:
-                w = urwid.Columns( [('fixed', buttonwidth, w),
-                                    urwid.Text(label)], 2 )
-            w = urwid.AttrWrap(w, 'selectable','focus')
+                w = urwid.Columns([('fixed', buttonwidth, w),
+                                   urwid.Text(label)], 2)
+            w = urwid.AttrWrap(w, 'selectable', 'focus')
             l.append(w)
 
         lb = urwid.ListBox(l)
-        lb = urwid.AttrWrap( lb, "selectable" )
+        lb = urwid.AttrWrap(lb, "selectable")
         dialog.__init__(self, text, height=height, width=width, body=lb,
                         title=title)
 
@@ -258,6 +267,7 @@ class listdialog(dialog):
                 return exitcode, i.get_label()
         return exitcode, None
 
+
 class checklistdialog(listdialog):
     def on_exit(self, exitcode):
         """
@@ -273,6 +283,7 @@ class checklistdialog(listdialog):
                 l.append(i.get_label())
         return exitcode, l
 
+
 def display_message(message, *args, **kwargs):
     if args:
         message = message % tuple(args)
@@ -295,6 +306,7 @@ def display_message(message, *args, **kwargs):
     box = displaybox('', long_message=message, title=title or VERSION)
     box.show(ui)
 
+
 def long_message(message, *args, **kwargs):
     if args:
         message = message % tuple(args)
@@ -315,13 +327,15 @@ def long_message(message, *args, **kwargs):
     message = '\n\n'.join(chunks).strip()
 
     box = dialog('', long_message=message, title=title or VERSION)
-    box.add_buttons([ ("OK", 0) ])
+    box.add_buttons([("OK", 0)])
     box.main(ui)
 
+
 final_message = long_message
 display_report = long_message
 display_failure = long_message
 
+
 def select_options(msg, ok, help=None, allow_numbers=False, nowrap=False,
                    ui=None, title=None):
     box = dialog('', long_message=msg, height=('relative', 80),
@@ -335,18 +349,20 @@ def select_options(msg, ok, help=None, allow_numbers=False, nowrap=False,
         if option.isupper():
             default = i
             option = option.lower()
-        buttons.append( (help.get(option, option), option) )
+        buttons.append((help.get(option, option), option))
 
     box.add_buttons(buttons, default, vertical=True)
     result = box.main(ui)
     return result
 
+
 def yes_no(msg, yeshelp, nohelp, default=True, nowrap=False, ui=None):
-    box = dialog('', long_message=msg+"?", title=VERSION)
-    box.add_buttons([ ('Yes', True), ('No', False) ], default=1-int(default))
+    box = dialog('', long_message=msg + "?", title=VERSION)
+    box.add_buttons([('Yes', True), ('No', False)], default=1 - int(default))
     result = box.main(ui)
     return result
 
+
 def get_string(prompt, options=None, title=None, empty_ok=False, force_prompt=False,
                default='', ui=None):
     if title:
@@ -355,10 +371,11 @@ def get_string(prompt, options=None, title=None, empty_ok=False, force_prompt=Fa
         title = VERSION
 
     box = textentry(prompt, title=title, edit_text=default)
-    box.add_buttons([ ("OK", 0) ])
+    box.add_buttons([("OK", 0)])
     code, text = box.main(ui)
     return text or default
 
+
 def get_multiline(prompt, options=None, title=None, force_prompt=False,
                   ui=None):
     if title:
@@ -367,14 +384,16 @@ def get_multiline(prompt, options=None, title=None, force_prompt=False,
         title = VERSION
 
     box = textentry(prompt, multiline=True)
-    box.add_buttons([ ("OK", 0) ])
+    box.add_buttons([("OK", 0)])
     code, text = box.main(ui)
     l = text.split('\n')
     return l
 
+
 def get_password(prompt=None):
     return getpass.getpass(prompt)
 
+
 def menu(par, options, prompt, default=None, title=None, any_ok=False,
          order=None, extras=None, multiple=False, empty_ok=False, ui=None,
          oklabel='Ok', cancellabel='Cancel', quitlabel=None):
@@ -397,15 +416,15 @@ def menu(par, options, prompt, default=None, title=None, any_ok=False,
         if order:
             olist = []
             for key in order:
-                if options.has_key(key):
-                    olist.append( (key, options[key]) )
+                if key in options:
+                    olist.append((key, options[key]))
                     del options[key]
 
             # Append anything out of order
             options = options.items()
             options.sort()
             for option in options:
-                olist.append( option )
+                olist.append(option)
             options = olist
         else:
             options = options.items()
@@ -425,10 +444,10 @@ def menu(par, options, prompt, default=None, title=None, any_ok=False,
         box = checklistdialog(par, widgets, height=('relative', 80),
                               title=title)
         if quitlabel:
-            box.add_buttons( [(oklabel, 0), (cancellabel, -1),
-                              (quitlabel, -2)] )
+            box.add_buttons([(oklabel, 0), (cancellabel, -1),
+                             (quitlabel, -2)])
         else:
-            box.add_buttons( [(oklabel, 0), (cancellabel, -1)] )
+            box.add_buttons([(oklabel, 0), (cancellabel, -1)])
         result, chosen = box.main(ui)
         if result < 0:
             # We return None to differentiate a Cancel/Quit from no selection, []
@@ -445,28 +464,20 @@ def menu(par, options, prompt, default=None, title=None, any_ok=False,
         if option == '---':
             # Separator is just a text label
             b = urwid.Text(desc)
-            b = urwid.AttrWrap( b, 'scrolllabel' )
+            b = urwid.AttrWrap(b, 'scrolllabel')
             desc = ''
         else:
-            b = urwid.RadioButton( rlist, label_button(option, desc), state=(option == default) )
+            b = urwid.RadioButton(rlist, label_button(option, desc), state=(option == default))
             b.exitcode = option
-            b = urwid.AttrWrap( b, 'selectable','focus' )
+            b = urwid.AttrWrap(b, 'selectable', 'focus')
         widgets.append((b, desc))
 
-##     if any_ok:
-##         editbox = urwid.Edit(multiline=False)
-##         e = urwid.ListBox([editbox])
-##         e = urwid.AttrWrap(e, 'selectable', 'focustext')
-##         e = urwid.Pile( [('fixed', 1, e)] )
-##         e = urwid.Filler(e)
-##         widgets.append((e, None))
-
     box = listdialog(par, widgets, height=('relative', 80),
                      title=title, buttonwidth=12)
     if quitlabel:
-        box.add_buttons( [(oklabel, 0), (cancellabel, -1), (quitlabel, -2)] )
+        box.add_buttons([(oklabel, 0), (cancellabel, -1), (quitlabel, -2)])
     else:
-        box.add_buttons( [(oklabel, 0), (cancellabel, -1)] )
+        box.add_buttons([(oklabel, 0), (cancellabel, -1)])
     focus = 0
     if default:
         for i, opt in enumerate(options):
@@ -480,15 +491,18 @@ def menu(par, options, prompt, default=None, title=None, any_ok=False,
 
     return chosen
 
+
 # A real file dialog would be nice here
 def get_filename(prompt, title=None, force_prompt=False, default=''):
     return get_string(prompt, title=title, force_prompt=force_prompt,
                       default=default)
 
+
 def select_multiple(par, options, prompt, title=None, order=None, extras=None):
     return menu(par, options, prompt, title=title, order=order, extras=extras,
                 multiple=True, empty_ok=False)
 
+
 # Things that are very UI dependent go here
 def show_report(number, system, mirrors,
                 http_proxy, timeout, screen=None, queryonly=False, title='',
@@ -501,10 +515,10 @@ def show_report(number, system, mirrors,
 
     sysinfo = debbugs.SYSTEMS[system]
     display_message('Retrieving report #%d from %s bug tracking system...',
-        number, sysinfo['name'], title=title, ui=ui)
+                    number, sysinfo['name'], title=title, ui=ui)
 
     info = debbugs.get_report(number, timeout, system, mirrors=mirrors,
-                                http_proxy=http_proxy, archived=archived)
+                              http_proxy=http_proxy, archived=archived)
     if not info:
         long_message('Bug report #%d not found.', number, title=title, ui=ui)
         return
@@ -529,6 +543,7 @@ def show_report(number, system, mirrors,
         launch_browser(debbugs.get_report_url(system, number, archived))
     return
 
+
 def handle_bts_query(package, bts, timeout, mirrors=None, http_proxy="",
                      queryonly=False, screen=None, title="", archived='no',
                      source=False, version=None, mbox=False, buglist=None,
@@ -557,7 +572,7 @@ def handle_bts_query(package, bts, timeout, mirrors=None, http_proxy="",
     else:
         display_message('Querying %s bug tracking system for reports %s',
                         debbugs.SYSTEMS[bts]['name'],
-                        ' '.join([str(x) for x in package]), ui=ui,title=title)
+                        ' '.join([str(x) for x in package]), ui=ui, title=title)
 
     result = None
     try:
@@ -567,7 +582,7 @@ def handle_bts_query(package, bts, timeout, mirrors=None, http_proxy="",
 
         if not count:
             ui.run_wrapper(nullfunc)
-            if hierarchy == None:
+            if hierarchy is None:
                 raise NoPackage
             else:
                 raise NoBugs
@@ -580,25 +595,25 @@ def handle_bts_query(package, bts, timeout, mirrors=None, http_proxy="",
             buglist = []
             for (t, bugs) in hierarchy:
                 bcount = len(bugs)
-                buglist.append( ('---', t) )
+                buglist.append(('---', t))
                 buglist_tmp = {}
                 for bug in bugs:
                     # show if the bugs is already resolved
                     done = ''
                     if bug.pending == 'done':
                         done = '  [RESOLVED]'
-                    buglist_tmp[bug.bug_num] = bug.subject+done
+                    buglist_tmp[bug.bug_num] = bug.subject + done
                 # append the sorted list of bugs for this severity
                 map(buglist.append, [(str(k), buglist_tmp[k]) for k in sorted(buglist_tmp, reverse=latest_first)])
 
             p = buglist[1][0]
-            #scr.popWindow()
+            # scr.popWindow()
             if queryonly:
                 cancellabel = 'Exit'
                 quitlabel = None
             else:
                 cancellabel = 'New bug'
-                quitlabel='Quit'
+                quitlabel = 'Quit'
 
             while True:
                 info = menu('Select a bug to read (and possibly report more information) or report a new bug:', buglist,
@@ -641,19 +656,22 @@ def handle_bts_query(package, bts, timeout, mirrors=None, http_proxy="",
 
     return result
 
+
 palette = [
-    ('body','black','light gray', 'standout'),
-    ('border','black','dark blue'),
-    ('shadow','white','black'),
-    ('selectable','black', 'dark cyan'),
-    ('focus','white','dark blue','bold'),
-    ('focustext','light gray','dark blue'),
+    ('body', 'black', 'light gray', 'standout'),
+    ('border', 'black', 'dark blue'),
+    ('shadow', 'white', 'black'),
+    ('selectable', 'black', 'dark cyan'),
+    ('focus', 'white', 'dark blue', 'bold'),
+    ('focustext', 'light gray', 'dark blue'),
     ('title', 'dark red', 'light gray'),
     ('scrolllabel', 'white', 'dark cyan'),
-    ]
+]
+
 
-def initialize ():
+def initialize():
     return True
 
+
 def can_input():
-    return sys.stdin.isatty()
\ No newline at end of file
+    return sys.stdin.isatty()
diff --git a/reportbug/urlutils.py b/reportbug/urlutils.py
index 9145e4f..354dd31 100644
--- a/reportbug/urlutils.py
+++ b/reportbug/urlutils.py
@@ -7,19 +7,19 @@
 #
 # This program is freely distributable per the following license:
 #
-##  Permission to use, copy, modify, and distribute this software and its
-##  documentation for any purpose and without fee is hereby granted,
-##  provided that the above copyright notice appears in all copies and that
-##  both that copyright notice and this permission notice appear in
-##  supporting documentation.
-##
-##  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-##  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
-##  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
-##  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-##  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-##  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-##  SOFTWARE.
+#  Permission to use, copy, modify, and distribute this software and its
+#  documentation for any purpose and without fee is hereby granted,
+#  provided that the above copyright notice appears in all copies and that
+#  both that copyright notice and this permission notice appear in
+#  supporting documentation.
+#
+#  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
+#  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+#  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+#  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+#  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+#  SOFTWARE.
 
 import httplib
 import urllib
@@ -34,15 +34,16 @@ import webbrowser
 
 from exceptions import (
     NoNetwork,
-    )
+)
 
 from __init__ import VERSION_NUMBER
 
-UA_STR = 'reportbug/'+VERSION_NUMBER+' (Debian)'
+UA_STR = 'reportbug/' + VERSION_NUMBER + ' (Debian)'
+
 
-def decode (page):
+def decode(page):
     "gunzip or deflate a compressed page"
-    #print page.info().headers
+    # print page.info().headers
     encoding = page.info().get("Content-Encoding")
     if encoding in ('gzip', 'x-gzip', 'deflate'):
         from cStringIO import StringIO
@@ -69,17 +70,22 @@ def decode (page):
         return newpage
     return page
 
-class HttpWithGzipHandler (urllib2.HTTPHandler):
+
+class HttpWithGzipHandler(urllib2.HTTPHandler):
     "support gzip encoding"
-    def http_open (self, req):
+
+    def http_open(self, req):
         return decode(urllib2.HTTPHandler.http_open(self, req))
 
+
 if hasattr(httplib, 'HTTPS'):
-    class HttpsWithGzipHandler (urllib2.HTTPSHandler):
+    class HttpsWithGzipHandler(urllib2.HTTPSHandler):
         "support gzip encoding"
-        def https_open (self, req):
+
+        def https_open(self, req):
             return decode(urllib2.HTTPSHandler.https_open(self, req))
 
+
 class handlepasswd(urllib2.HTTPPasswordMgrWithDefaultRealm):
     def find_user_password(self, realm, authurl):
         user, password = urllib2.HTTPPasswordMgrWithDefaultRealm.find_user_password(self, realm, authurl)
@@ -92,7 +98,10 @@ class handlepasswd(urllib2.HTTPPasswordMgrWithDefaultRealm):
         self.add_password(realm, authurl, user, password)
         return user, password
 
+
 _opener = None
+
+
 def urlopen(url, proxies=None, data=None):
     global _opener
 
@@ -100,7 +109,7 @@ def urlopen(url, proxies=None, data=None):
         proxies = urllib.getproxies()
 
     headers = {'User-Agent': UA_STR,
-               'Accept-Encoding' : 'gzip;q=1.0, deflate;q=0.9, identity;q=0.5'}
+               'Accept-Encoding': 'gzip;q=1.0, deflate;q=0.9, identity;q=0.5'}
 
     req = urllib2.Request(url, data, headers)
 
@@ -108,13 +117,13 @@ def urlopen(url, proxies=None, data=None):
     if _opener is None:
         pwd_manager = handlepasswd()
         handlers = [proxy_support,
-            urllib2.UnknownHandler, HttpWithGzipHandler,
-            urllib2.HTTPBasicAuthHandler(pwd_manager),
-            urllib2.ProxyBasicAuthHandler(pwd_manager),
-            urllib2.HTTPDigestAuthHandler(pwd_manager),
-            urllib2.ProxyDigestAuthHandler(pwd_manager),
-            urllib2.HTTPDefaultErrorHandler, urllib2.HTTPRedirectHandler,
-        ]
+                    urllib2.UnknownHandler, HttpWithGzipHandler,
+                    urllib2.HTTPBasicAuthHandler(pwd_manager),
+                    urllib2.ProxyBasicAuthHandler(pwd_manager),
+                    urllib2.HTTPDigestAuthHandler(pwd_manager),
+                    urllib2.ProxyDigestAuthHandler(pwd_manager),
+                    urllib2.HTTPDefaultErrorHandler, urllib2.HTTPRedirectHandler,
+                    ]
         if hasattr(httplib, 'HTTPS'):
             handlers.append(HttpsWithGzipHandler)
         _opener = urllib2.build_opener(*handlers)
@@ -123,6 +132,7 @@ def urlopen(url, proxies=None, data=None):
 
     return _opener.open(req)
 
+
 # Global useful URL opener; returns None if the page is absent, otherwise
 # like urlopen
 def open_url(url, http_proxy=None, timeout=60):
@@ -153,13 +163,11 @@ def open_url(url, http_proxy=None, timeout=60):
         raise NoNetwork
     except httplib.HTTPException, exc:
         exc_name = exc.__class__.__name__
-        message = (
-            "Failed to open %(url)r"
-            " (%(exc_name)s: %(exc)s)"
-            ) % vars()
+        message = "Failed to open %(url)r (%(exc_name)s: %(exc)s)" % vars()
         raise NoNetwork(message)
     return page
 
+
 def launch_browser(url):
     if not os.system('command -v xdg-open >/dev/null 2>&1'):
         cmd = 'xdg-open' + commands.mkarg(url)
@@ -173,8 +181,8 @@ def launch_browser(url):
     X11BROWSER = os.environ.get('X11BROWSER', 'mozilla-firefox')
     CONSOLEBROWSER = os.environ.get('CONSOLEBROWSER', 'lynx')
 
-    if (os.environ.has_key('DISPLAY') and
-        not os.system('command -v '+X11BROWSER+' &> /dev/null')):
+    if ('DISPLAY' in os.environ and
+            not os.system('command -v ' + X11BROWSER + ' &> /dev/null')):
         cmd = "%s %s &" % (X11BROWSER, commands.mkarg(url))
     else:
         cmd = "%s %s" % (CONSOLEBROWSER, commands.mkarg(url))
diff --git a/reportbug/utils.py b/reportbug/utils.py
index d50ad09..46476b5 100644
--- a/reportbug/utils.py
+++ b/reportbug/utils.py
@@ -6,24 +6,25 @@
 #
 # This program is freely distributable per the following license:
 #
-##  Permission to use, copy, modify, and distribute this software and its
-##  documentation for any purpose and without fee is hereby granted,
-##  provided that the above copyright notice appears in all copies and that
-##  both that copyright notice and this permission notice appear in
-##  supporting documentation.
-##
-##  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
-##  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
-##  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
-##  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
-##  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
-##  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
-##  SOFTWARE.
+#  Permission to use, copy, modify, and distribute this software and its
+#  documentation for any purpose and without fee is hereby granted,
+#  provided that the above copyright notice appears in all copies and that
+#  both that copyright notice and this permission notice appear in
+#  supporting documentation.
+#
+#  I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+#  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
+#  BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+#  DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+#  WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+#  ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+#  SOFTWARE.
 
 import sys
 import os
 import re
 import platform
+
 try:
     import pwd
     from tempfiles import TempFile, tempfile_prefix, cleanup_temp_file
@@ -54,13 +55,13 @@ PSEUDOHEADERS = ('Package', 'Source', 'Version', 'Severity', 'File', 'Tags',
 
 MODES = {'novice': 'Offer simple prompts, bypassing technical questions.',
          'standard': 'Offer more extensive prompts, including asking about '
-         'things that a moderately sophisticated user would be expected to '
-         'know about Debian.',
-         'advanced' : 'Like standard, but assumes you know a bit more about '
-         'Debian, including "incoming".',
+                     'things that a moderately sophisticated user would be expected to '
+                     'know about Debian.',
+         'advanced': 'Like standard, but assumes you know a bit more about '
+                     'Debian, including "incoming".',
          'expert': 'Bypass most handholding measures and preliminary triage '
-         'routines.  This mode should not be used by people unfamiliar with '
-         'Debian\'s policies and operating procedures.'}
+                   'routines.  This mode should not be used by people unfamiliar with '
+                   'Debian\'s policies and operating procedures.'}
 MODELIST = ['novice', 'standard', 'advanced', 'expert']
 for mode in MODELIST:
     exec 'MODE_%s=%d' % (mode.upper(), MODELIST.index(mode))
@@ -95,11 +96,12 @@ SUITES2DISTS = {'squeeze': 'oldstable',
                 'sid': 'unstable',
                 'experimental': 'experimental'}
 
+
 def realpath(filename):
     filename = os.path.abspath(filename)
 
     bits = filename.split('/')
-    for i in range(2, len(bits)+1):
+    for i in range(2, len(bits) + 1):
         component = '/'.join(bits[0:i])
         if component in fhs_directories:
             continue
@@ -113,16 +115,19 @@ def realpath(filename):
 
     return filename
 
+
 pathdirs = ['/usr/sbin', '/usr/bin', '/sbin', '/bin', '/usr/X11R6/bin',
             '/usr/games']
 
+
 def search_path_for(filename):
     d, f = os.path.split(filename)
-    if d: return realpath(filename)
+    if d:
+        return realpath(filename)
 
     path = os.environ.get("PATH", os.defpath).split('/')
     for d in pathdirs:
-        if not d in path:
+        if d not in path:
             path.append(d)
 
     for d in path:
@@ -131,6 +136,7 @@ def search_path_for(filename):
             return realpath(fullname)
     return None
 
+
 def which_editor(specified_editor=None):
     """ Determine which editor program to use.
 
@@ -144,20 +150,21 @@ def which_editor(specified_editor=None):
 
         """
     debian_default_editor = "/usr/bin/sensible-editor"
-    for editor in [
-        specified_editor,
-        os.environ.get("VISUAL"),
-        os.environ.get("EDITOR"),
-        debian_default_editor]:
+    for editor in [specified_editor,
+                   os.environ.get("VISUAL"),
+                   os.environ.get("EDITOR"),
+                   debian_default_editor]:
         if editor:
             break
 
     return editor
 
+
 def glob_escape(filename):
     filename = re.sub(r'([*?\[\]])', r'\\\1', filename)
     return filename
 
+
 def search_pipe(searchfile, use_dlocate=True):
     arg = commands.mkarg(searchfile)
     if use_dlocate and os.path.exists('/usr/bin/dlocate'):
@@ -167,6 +174,7 @@ def search_pipe(searchfile, use_dlocate=True):
         pipe = os.popen('COLUMNS=79 dpkg --search %s 2>/dev/null' % arg)
     return (pipe, use_dlocate)
 
+
 def query_dpkg_for(filename, use_dlocate=True):
     try:
         x = os.getcwd()
@@ -179,13 +187,14 @@ def query_dpkg_for(filename, use_dlocate=True):
     for line in pipe:
         line = line.strip()
         # Ignore diversions
-        if 'diversion by' in line: continue
+        if 'diversion by' in line:
+            continue
 
         (package, path) = line.split(': ', 1)
         path = path.strip()
         packlist = package.split(', ')
         for package in packlist:
-            if packages.has_key(package):
+            if package in packages:
                 packages[package].append(path)
             else:
                 packages[package] = [path]
@@ -196,6 +205,7 @@ def query_dpkg_for(filename, use_dlocate=True):
 
     return filename, packages
 
+
 def find_package_for(filename, pathonly=False):
     """Find the package(s) containing this file."""
 
@@ -206,18 +216,20 @@ def find_package_for(filename, pathonly=False):
         dpkg_info = re.compile('/var/lib/dpkg/info/(.+)\.[^.]+')
         m = dpkg_info.match(filename)
         # callee want a dict as second pair element...
-        packages[m.group(1)]=''
+        packages[m.group(1)] = ''
         return (filename, packages)
 
     if filename[0] == '/':
         fn, pkglist = query_dpkg_for(filename)
-        if pkglist: return fn, pkglist
+        if pkglist:
+            return fn, pkglist
 
     newfilename = search_path_for(filename)
     if pathonly and not newfilename:
         return (filename, None)
     return query_dpkg_for(newfilename or filename)
 
+
 def find_rewritten(username):
     for filename in ['/etc/email-addresses']:
         if os.path.exists(filename):
@@ -237,6 +249,7 @@ def find_rewritten(username):
                     print 'Invalid entry in %s' % filename
                     return None
 
+
 def check_email_addr(addr):
     """Simple check for email validity"""
     if '@' not in addr:
@@ -252,13 +265,16 @@ def check_email_addr(addr):
         return False
     return True
 
+
 def get_email_addr(addr):
     addr = rfc822.AddressList(addr)
     return addr.addresslist[0]
 
+
 def get_email(email='', realname=''):
     return get_email_addr(get_user_id(email, realname))
 
+
 def get_user_id(email='', realname='', charset='utf-8'):
     uid = os.getuid()
     info = pwd.getpwuid(uid)
@@ -273,7 +289,7 @@ def get_user_id(email='', realname='', charset='utf-8'):
         else:
             domainname = socket.getfqdn()
 
-        email = email+'@'+domainname
+        email = email + '@' + domainname
 
     # Handle EMAIL if it's formatted as 'Bob <bob at host>'.
     if '<' in email or '(' in email:
@@ -298,12 +314,15 @@ def get_user_id(email='', realname='', charset='utf-8'):
     if re.match(r'[\w\s]+$', realname):
         return u'%s <%s>' % (realname, email)
 
-    addr = rfc822.dump_address_pair( (realname, email) )
+    addr = rfc822.dump_address_pair((realname, email))
     if isinstance(addr, str):
         addr = addr.decode('utf-8', 'replace')
     return addr
 
+
 statuscache = {}
+
+
 def get_package_status(package, avail=False):
     if not avail and package in statuscache:
         return statuscache[package]
@@ -352,7 +371,8 @@ def get_package_status(package, avail=False):
 
     for line in output.split(os.linesep):
         line = line.rstrip()
-        if not line: continue
+        if not line:
+            continue
 
         if confmode:
             if line[:2] != ' /':
@@ -402,7 +422,7 @@ def get_package_status(package, avail=False):
             src_name = src_name.split()[0]
         elif sectionre.match(line):
             crud, section = line.split(": ", 1)
-        elif desc and line[0]==' ':
+        elif desc and line[0] == ' ':
             fulldesc.append(line)
 
     installed = False
@@ -414,7 +434,7 @@ def get_package_status(package, avail=False):
     if bugs:
         reportinfo = debbugs.parse_bts_url(bugs)
     elif origin:
-        if debbugs.SYSTEMS.has_key(origin):
+        if origin in debbugs.SYSTEMS:
             vendor = debbugs.SYSTEMS[origin]['name']
             reportinfo = (debbugs.SYSTEMS[origin].get('type', 'debbugs'),
                           debbugs.SYSTEMS[origin]['btsroot'])
@@ -433,8 +453,9 @@ def get_package_status(package, avail=False):
         statuscache[package] = info
     return info
 
-#dbase = []
-#avail = []
+
+# dbase = []
+# avail = []
 
 # Object that essentially chunkifies the output of apt-cache dumpavail
 class AvailDB(object):
@@ -469,7 +490,7 @@ class AvailDB(object):
         raise StopIteration
 
     def __del__(self):
-        #print >> sys.stderr, 'availdb cleanup', repr(self.popenob), repr(self.fp)
+        # print >> sys.stderr, 'availdb cleanup', repr(self.popenob), repr(self.fp)
         if self.popenob:
             # Clear the pipe before shutting it down
             while True:
@@ -482,6 +503,7 @@ class AvailDB(object):
         if self.fp:
             self.fp.close()
 
+
 def get_dpkg_database():
     try:
         fp = open(STATUSDB)
@@ -491,13 +513,15 @@ def get_dpkg_database():
         print >> sys.stderr, 'Unable to open', STATUSDB
         sys.exit(1)
 
+
 def get_avail_database():
-    #print >> sys.stderr, 'Searching available database'
+    # print >> sys.stderr, 'Searching available database'
     subp = subprocess.Popen(('apt-cache', 'dumpavail'), stdout=subprocess.PIPE)
     return AvailDB(popenob=subp)
 
+
 def available_package_description(package):
-    data = commands.getoutput('apt-cache show'+commands.mkarg(package))
+    data = commands.getoutput('apt-cache show' + commands.mkarg(package))
     data = data.decode('utf-8', 'replace')
     descre = re.compile('^Description(?:-.*)?: (.*)$')
     for line in data.split('\n'):
@@ -506,10 +530,11 @@ def available_package_description(package):
             return m.group(1)
     return None
 
+
 def get_source_name(package):
     packages = []
 
-    data = commands.getoutput('apt-cache showsrc'+commands.mkarg(package))
+    data = commands.getoutput('apt-cache showsrc' + commands.mkarg(package))
     data = data.decode('utf-8', 'replace')
     packre = re.compile(r'^Package: (.*)$')
     for line in data.split('\n'):
@@ -518,12 +543,13 @@ def get_source_name(package):
             return m.group(1)
     return None
 
+
 def get_source_package(package):
     packages = []
     retlist = []
     found = {}
 
-    data = commands.getoutput('apt-cache showsrc'+commands.mkarg(package))
+    data = commands.getoutput('apt-cache showsrc' + commands.mkarg(package))
     data = data.decode('utf-8', 'replace')
     binre = re.compile(r'^Binary: (.*)$')
     for line in data.split('\n'):
@@ -542,6 +568,7 @@ def get_source_package(package):
     retlist.sort()
     return retlist
 
+
 def get_package_info(packages, skip_notfound=False):
     if not packages:
         return []
@@ -559,11 +586,11 @@ def get_package_info(packages, skip_notfound=False):
 
     searchbits = [
         # Package regular expression
-        r'^(?P<hdr>Package):\s+('+'|'.join(searchpkgs)+')$',
+        r'^(?P<hdr>Package):\s+(' + '|'.join(searchpkgs) + ')$',
         # Provides regular expression
-        r'^(?P<hdr>Provides):\s+'+pkgname+r'*(?P<pkg>'+'|'.join(searchpkgs)+
-        r')(?:$|,\s+)'+pkgname+'*$'
-        ]
+        r'^(?P<hdr>Provides):\s+' + pkgname + r'*(?P<pkg>' + '|'.join(searchpkgs) +
+        r')(?:$|,\s+)' + pkgname + '*$'
+    ]
 
     groups = groupfor.values()
     found = {}
@@ -597,7 +624,7 @@ def get_package_info(packages, skip_notfound=False):
                 vers = versob.search(p).group('vers')
                 desc = descob.search(p).group('desc')
 
-                info = (pack,stat,vers,desc,provides)
+                info = (pack, stat, vers, desc, provides)
                 ret.append(info)
                 group = groupfor.get(pack)
                 if group:
@@ -613,19 +640,21 @@ def get_package_info(packages, skip_notfound=False):
         notfound = [x for x in group if x not in found]
         if len(notfound) == len(group):
             if group not in found:
-                ret.append( (' | '.join(group), 'pn', '<none>',
-                             '(no description available)', None) )
+                ret.append((' | '.join(group), 'pn', '<none>',
+                            '(no description available)', None))
 
     return ret
 
+
 def packages_providing(package):
     aret = get_package_info([((package,), package)], skip_notfound=True)
     ret = []
     for pkg in aret:
-        ret.append( (pkg[0], pkg[3]) )
+        ret.append((pkg[0], pkg[3]))
 
     return ret
 
+
 def get_dependency_info(package, depends, rel="depends on"):
     if not depends:
         return ('\n%s %s no packages.\n' % (package, rel))
@@ -633,7 +662,7 @@ def get_dependency_info(package, depends, rel="depends on"):
     dependencies = []
     for dep in depends:
         for bit in dep:
-            dependencies.append( (tuple(dep), bit) )
+            dependencies.append((tuple(dep), bit))
 
     depinfo = "\nVersions of packages %s %s:\n" % (package, rel)
 
@@ -663,8 +692,8 @@ def get_dependency_info(package, depends, rel="depends on"):
     # columns)
     maxp = max([len(x[0]) for x in deplist])
     maxv = max([len(x[1]) for x in deplist])
-    widthp = min(maxp, 73-maxv)
-    widthv = min(maxv, 73-widthp)
+    widthp = min(maxp, 73 - maxv)
+    widthv = min(maxv, 73 - widthp)
 
     for (pack, vers, status) in deplist:
         # we format the string specifying to align it in a field of a given
@@ -677,6 +706,7 @@ def get_dependency_info(package, depends, rel="depends on"):
 
     return depinfo
 
+
 def get_changed_config_files(conffiles, nocompress=False):
     confinfo = {}
     changed = []
@@ -688,15 +718,19 @@ def get_changed_config_files(conffiles, nocompress=False):
             continue
 
         filemd5 = commands.getoutput('md5sum ' + commands.mkarg(filename)).split()[0]
-        if filemd5 == md5sum: continue
+        if filemd5 == md5sum:
+            continue
 
         changed.append(filename)
         thisinfo = 'changed:\n'
         for line in fp:
-            if not line: continue
+            if not line:
+                continue
 
-            if line == '\n' and not nocompress: continue
-            if line[0] == '#' and not nocompress: continue
+            if line == '\n' and not nocompress:
+                continue
+            if line[0] == '#' and not nocompress:
+                continue
 
             thisinfo += line
 
@@ -704,8 +738,10 @@ def get_changed_config_files(conffiles, nocompress=False):
 
     return confinfo, changed
 
+
 DISTORDER = ['oldstable', 'stable', 'testing', 'unstable', 'experimental']
 
+
 def get_debian_release_info():
     debvers = debinfo = verfile = warn = ''
     dists = []
@@ -713,7 +749,7 @@ def get_debian_release_info():
     if output:
         mre = re.compile('\s+(\d+)\s+.*$\s+release\s.*o=(Ubuntu|Debian|Debian Ports),a=([^,]+),', re.MULTILINE)
         found = {}
-        ## XXX: When Python 2.4 rolls around, rewrite this
+        # XXX: When Python 2.4 rolls around, rewrite this
         for match in mre.finditer(output):
             pword, distname = match.group(1, 3)
             if distname in DISTORDER:
@@ -738,12 +774,12 @@ def get_debian_release_info():
         print >> sys.stderr, 'Unable to open /etc/debian_version'
 
     if verfile:
-        debinfo += 'Debian Release: '+verfile+'\n'
+        debinfo += 'Debian Release: ' + verfile + '\n'
     if debvers:
-        debinfo += '  APT prefers '+debvers+'\n'
+        debinfo += '  APT prefers ' + debvers + '\n'
     if dists:
         # Should wrap this eventually...
-        #policystr = pprint.pformat(dists)
+        # policystr = pprint.pformat(dists)
         policystr = ', '.join([str(x) for x in dists])
         debinfo += '  APT policy: %s\n' % policystr
     if warn:
@@ -751,9 +787,11 @@ def get_debian_release_info():
 
     return debinfo
 
+
 def lsb_release_info():
     return commands.getoutput('lsb_release -a 2>/dev/null') + '\n'
 
+
 def get_arch():
     arch = commands.getoutput('COLUMNS=79 dpkg --print-architecture 2>/dev/null')
     if not arch:
@@ -764,10 +802,12 @@ def get_arch():
         arch = re.sub(r'ppc', 'powerpc', arch)
     return arch
 
+
 def get_multiarch():
     out = commands.getoutput('COLUMNS=79 dpkg --print-foreign-architectures 2>/dev/null')
     return ', '.join(out.splitlines())
 
+
 def generate_blank_report(package, pkgversion, severity, justification,
                           depinfo, confinfo, foundfile='', incfiles='',
                           system='debian', exinfo=None, type=None, klass='',
@@ -789,6 +829,7 @@ def generate_blank_report(package, pkgversion, severity, justification,
                               debsumsoutput=debsumsoutput, issource=issource)
     return unicode(rep)
 
+
 def get_cpu_cores():
     cpucount = 0
     try:
@@ -800,21 +841,24 @@ def get_cpu_cores():
     for line in fob:
         if line.startswith('processor'):
             cpucount += 1
-	#Alpha platform
-	if line.startswith('cpus detected'):
-	    cpucount = int(line.split()[-1])
+        # Alpha platform
+        if line.startswith('cpus detected'):
+            cpucount = int(line.split()[-1])
     fob.close()
 
     return max(cpucount, 1)
 
+
 class our_lex(shlex.shlex):
     def get_token(self):
         token = shlex.shlex.get_token(self)
-        if token is None or not len(token): return token
+        if token is None or not len(token):
+            return token
         if (token[0] == token[-1]) and token[0] in self.quotes:
             token = token[1:-1]
         return token
 
+
 USERFILE = os.path.expanduser('~/.reportbugrc')
 FILES = ('/etc/reportbug.conf', USERFILE)
 
@@ -826,6 +870,7 @@ CONFIG_ARGS = (
     'printonly', 'offline', 'check_uid', 'smtptls', 'smtpuser', 'smtppasswd',
     'paranoid', 'mbox_reader_cmd', 'max_attachment_size')
 
+
 class Mua:
     command = ""
     name = ""
@@ -843,6 +888,7 @@ class Mua:
     def get_name(self):
         return self.name
 
+
 class Gnus(Mua):
     name = "gnus"
 
@@ -858,21 +904,23 @@ class Gnus(Mua):
         return ui.system("emacsclient --no-wait --eval %s 2>/dev/null"
                          " || emacs --eval %s" % (elisp, elisp))
 
+
 MUA = {
-    'mutt' : Mua('mutt -H'),
-    'mh' : Mua('/usr/bin/mh/comp -use -file'),
-    'gnus' : Gnus(),
-    'claws-mail' : Mua('claws-mail --compose-from-file'),
-    }
+    'mutt': Mua('mutt -H'),
+    'mh': Mua('/usr/bin/mh/comp -use -file'),
+    'gnus': Gnus(),
+    'claws-mail': Mua('claws-mail --compose-from-file'),
+}
 MUA['nmh'] = MUA['mh']
 
 # TODO: convert them to class methods
 MUAVERSION = {
-    MUA['mutt'] : 'mutt -v',
-    MUA['mh'] : '/usr/bin/mh/comp -use -file',
-    MUA['gnus'] : 'emacs --version',
-    MUA['claws-mail'] : 'claws-mail --version',
-    }
+    MUA['mutt']: 'mutt -v',
+    MUA['mh']: '/usr/bin/mh/comp -use -file',
+    MUA['gnus']: 'emacs --version',
+    MUA['claws-mail']: 'claws-mail --version',
+}
+
 
 def mua_is_supported(mua):
     # check if the mua is supported by reportbug
@@ -893,6 +941,7 @@ def mua_is_supported(mua):
     else:
         return True
 
+
 def mua_exists(mua):
     # check if the mua is available on the system
     if mua == 'mh' or mua == MUA['mh']:
@@ -910,7 +959,8 @@ def mua_exists(mua):
     output = '/dev/null'
     if os.path.exists(output):
         try:
-            returnvalue = subprocess.call(MUAVERSION[mua_tmp], stdout=open(output, 'w'), stderr=subprocess.STDOUT, shell=True)
+            returnvalue = subprocess.call(MUAVERSION[mua_tmp], stdout=open(output, 'w'), stderr=subprocess.STDOUT,
+                                          shell=True)
         except (IOError, OSError):
             returnvalue = subprocess.call(MUAVERSION[mua_tmp], shell=True)
     else:
@@ -921,6 +971,7 @@ def mua_exists(mua):
     else:
         return True
 
+
 def mua_name(mua):
     # in case the user specifies only the mua name in --mua, returns the default options
     if mua in MUA:
@@ -928,9 +979,11 @@ def mua_name(mua):
     else:
         return mua
 
+
 def first_run():
     return not os.path.exists(USERFILE)
 
+
 def parse_config_files():
     args = {}
     for filename in FILES:
@@ -952,8 +1005,7 @@ def parse_config_files():
                     if token in debbugs.SEVERITIES.keys():
                         args['severity'] = token
                 elif token == 'header':
-                    args['headers'] = args.get('headers', []) + \
-                                      [lex.get_token()]
+                    args['headers'] = args.get('headers', []) + [lex.get_token()]
                 elif token in ('no-cc', 'cc'):
                     args['nocc'] = (token == 'no-cc')
                 elif token in ('no-compress', 'compress'):
@@ -993,8 +1045,7 @@ def parse_config_files():
                     if token in debbugs.SYSTEMS.keys():
                         args['bts'] = token
                 elif token == 'mirror':
-                    args['mirrors'] = args.get('mirrors', []) + \
-                                      [lex.get_token()]
+                    args['mirrors'] = args.get('mirrors', []) + [lex.get_token()]
                 elif token in ('no-check-available', 'check-available'):
                     args['check_available'] = (token == 'check-available')
                 elif token == 'reportbug_version':
@@ -1026,6 +1077,7 @@ def parse_config_files():
 
     return args
 
+
 def parse_bug_control_file(filename):
     submitas = submitto = None
     reportwith = []
@@ -1049,6 +1101,7 @@ def parse_bug_control_file(filename):
 
     return submitas, submitto, reportwith, supplemental
 
+
 def cleanup_msg(dmessage, headers, pseudos, type):
     pseudoheaders = []
     # Handle non-pseduo-headers
@@ -1078,8 +1131,8 @@ def cleanup_msg(dmessage, headers, pseudos, type):
             # GNATS and debbugs have different ideas of what a pseudoheader
             # is...
             if mob and ((type == 'debbugs' and
-                         mob.group(1) not in PSEUDOHEADERS and
-                         mob.group(1) not in PSEUDOS) or
+                                 mob.group(1) not in PSEUDOHEADERS and
+                                 mob.group(1) not in PSEUDOS) or
                         (type == 'gnats' and mob.group(1)[0] != '>')):
                 newheaders.append(mob.groups())
                 lastpseudo = False
@@ -1126,7 +1179,7 @@ def cleanup_msg(dmessage, headers, pseudos, type):
             if header in pseudo_list:
                 ph2[header] = content
             else:
-                newheaders.append( (header, content) )
+                newheaders.append((header, content))
 
         for header in pseudo_list:
             if header in ph2:
@@ -1134,6 +1187,7 @@ def cleanup_msg(dmessage, headers, pseudos, type):
 
     return message, newheaders, ph
 
+
 def launch_mbox_reader(cmd, url, http_proxy, timeout):
     """Runs the command specified by cmd passing the mbox file
     downloaded from url as a parameter. If cmd is None or fails, then
@@ -1154,11 +1208,12 @@ def launch_mbox_reader(cmd, url, http_proxy, timeout):
             error = os.system(cmd)
             if not error:
                 return
-        #fallback
+        # fallback
         os.system('mail -f ' + fname)
     finally:
         os.unlink(fname)
 
+
 def get_running_kernel_pkg():
     """Return the package of the currently running kernel, needed to force
     assignment for 'kernel' package to a real one"""
@@ -1173,6 +1228,7 @@ def get_running_kernel_pkg():
     else:
         return None
 
+
 def exec_and_parse_bugscript(handler, bugscript):
     """Execute and parse the output of the package bugscript, in particular
     identifying the headers and pseudo-headers blocks, if present"""
@@ -1217,6 +1273,7 @@ def exec_and_parse_bugscript(handler, bugscript):
     text = text.decode('utf-8', 'replace')
     return (rc, headers, pseudoheaders, text, attachments)
 
+
 def check_package_name(pkg):
     """Check the package name against Debian Policy:
     https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Source
@@ -1227,6 +1284,7 @@ def check_package_name(pkg):
 
     return True if pkg_re.match(pkg) else False
 
+
 def get_init_system():
     """Determines the init system on the current machine"""
 
diff --git a/setup.py b/setup.py
index 8cb4eaf..eca0948 100755
--- a/setup.py
+++ b/setup.py
@@ -24,5 +24,5 @@ setup(name='reportbug', version=reportbug.VERSION_NUMBER,
                   ('share/bug/reportbug', ['share/presubj', 'share/script',
                                            'share/control'])],
       license='MIT',
-      packages=['reportbug','reportbug.ui'],
+      packages=['reportbug', 'reportbug.ui'],
       scripts=['bin/reportbug', 'bin/querybts'])
diff --git a/test/test_bugreport.py b/test/test_bugreport.py
index 71de583..8f7714e 100644
--- a/test/test_bugreport.py
+++ b/test/test_bugreport.py
@@ -6,9 +6,9 @@ from reportbug.bugreport import bugreport
 from nose.plugins.attrib import attr
 import debianbts
 
-class TestBugreport(unittest2.TestCase):
 
-# TODO: differentiate for all possible cases? f.e. sysinfo True/False and then change if 'System Information' in self.text?
+class TestBugreport(unittest2.TestCase):
+    # TODO: differentiate for all possible cases? f.e. sysinfo True/False and then change if 'System Information' in self.text?
 
     def test_bugreport(self):
         self.body = 'test'
@@ -27,7 +27,7 @@ class TestBugreport(unittest2.TestCase):
             self.text = self.report.__unicode__()
             self.assertNotIn(utils.NEWBIELINE, self.text)
 
-    @attr('network') #marking the test as using network
+    @attr('network')  # marking the test as using network
     def test_followup(self):
         self.body = 'test'
         self.package = 'reportbug'
diff --git a/test/test_checkbuildd.py b/test/test_checkbuildd.py
index 1068fb1..994af54 100644
--- a/test/test_checkbuildd.py
+++ b/test/test_checkbuildd.py
@@ -3,9 +3,9 @@ import unittest2
 from reportbug import checkbuildd
 from nose.plugins.attrib import attr
 
-class TestCheckbuildd(unittest2.TestCase):
 
-    @attr('network') #marking the test as using network
+class TestCheckbuildd(unittest2.TestCase):
+    @attr('network')  # marking the test as using network
     def test_check_built(self):
         built = checkbuildd.check_built('gkrellm', 60)
         self.assertTrue(built)
diff --git a/test/test_checkversions.py b/test/test_checkversions.py
index 359b89b..57b23ef 100644
--- a/test/test_checkversions.py
+++ b/test/test_checkversions.py
@@ -5,8 +5,8 @@ from nose.plugins.attrib import attr
 
 import mock
 
-class TestCheckversions(unittest2.TestCase):
 
+class TestCheckversions(unittest2.TestCase):
     def test_compare_versions(self):
         # <current, upstream>
         # 1 upstream newer than current
@@ -33,10 +33,9 @@ class TestCheckversions(unittest2.TestCase):
 
         self.assertEqual(checkversions.later_version('1.2.4', '1.2.3'), '1.2.4')
 
-class TestNewQueue(unittest2.TestCase):
 
+class TestNewQueue(unittest2.TestCase):
     def test_bts704040(self):
-
         # return an iterable object, so that Deb822 (what parses the result)
         # will work
         pkg_in_new = """Source: procps
@@ -59,7 +58,7 @@ Source: aaa
         # save the original checkversions.open_url() method
         save_open_url = checkversions.open_url
 
-        checkversions.open_url = mock.MagicMock(return_value = pkg_in_new)
+        checkversions.open_url = mock.MagicMock(return_value=pkg_in_new)
 
         res = checkversions.get_newqueue_available('procps', 60)
 
@@ -69,22 +68,22 @@ Source: aaa
         # restore the original checkversions.open_url() method
         checkversions.open_url = save_open_url
 
-class TestVersionAvailable(unittest2.TestCase):
 
-    @attr('network') #marking the test as using network
+class TestVersionAvailable(unittest2.TestCase):
+    @attr('network')  # marking the test as using network
     def test_bts642032(self):
         vers = checkversions.get_versions_available('reportbug', 60)
         # check stable version is lower than unstable
         chk = checkversions.compare_versions(vers['stable'], vers['unstable'])
         self.assertGreaterEqual(chk, 0)
 
-    @attr('network') #marking the test as using network
+    @attr('network')  # marking the test as using network
     def test_bts649649(self):
         # checking for non-existing package should not generate a traceback
         vers = checkversions.get_versions_available('blablabla', 60)
         self.assertEqual(vers, {})
 
-    @attr('network') #marking the test as using network
+    @attr('network')  # marking the test as using network
     def test_673204(self):
         vers = checkversions.get_versions_available('texlive-xetex', 60)
         # squeeze (stable at this time) is the first suite where texlive-xetex
@@ -94,5 +93,5 @@ class TestVersionAvailable(unittest2.TestCase):
     @attr('network')
     def test_codenames(self):
         vers = checkversions.get_versions_available('reportbug', 60, ['sid'])
-	self.assertEqual(1, len(vers))
-	self.assertEqual(vers.keys()[0], 'unstable')
+        self.assertEqual(1, len(vers))
+        self.assertEqual(vers.keys()[0], 'unstable')
diff --git a/test/test_debbugs.py b/test/test_debbugs.py
index 9d0f3e1..ce2e9d8 100644
--- a/test/test_debbugs.py
+++ b/test/test_debbugs.py
@@ -8,54 +8,88 @@ from reportbug import debbugs
 import urllib
 import re
 
-class TestDebianbts(unittest2.TestCase):
 
+class TestDebianbts(unittest2.TestCase):
     def test_get_tags(self):
-
         # for each severity, for each mode
-        self.assertItemsEqual(debbugs.get_tags('critical', utils.MODE_NOVICE).keys(), ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'security', 'patch', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('grave', utils.MODE_NOVICE).keys(), ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'security', 'patch', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('serious', utils.MODE_NOVICE).keys(), ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'security', 'patch', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('important', utils.MODE_NOVICE).keys(), ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('does-not-build', utils.MODE_NOVICE).keys(), ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('normal', utils.MODE_NOVICE).keys(), ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('non-critical', utils.MODE_NOVICE).keys(), ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('minor', utils.MODE_NOVICE).keys(), ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('wishlist', utils.MODE_NOVICE).keys(), ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
-
-        self.assertItemsEqual(debbugs.get_tags('critical', utils.MODE_STANDARD).keys(), ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'security', 'patch', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('grave', utils.MODE_STANDARD).keys(), ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'security', 'patch', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('serious', utils.MODE_STANDARD).keys(), ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'security', 'patch', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('important', utils.MODE_STANDARD).keys(), ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('does-not-build', utils.MODE_STANDARD).keys(), ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('normal', utils.MODE_STANDARD).keys(), ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('non-critical', utils.MODE_STANDARD).keys(), ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('minor', utils.MODE_STANDARD).keys(), ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('wishlist', utils.MODE_STANDARD).keys(), ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
-
-        self.assertItemsEqual(debbugs.get_tags('critical', utils.MODE_ADVANCED).keys(), ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('grave', utils.MODE_ADVANCED).keys(), ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('serious', utils.MODE_ADVANCED).keys(), ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('important', utils.MODE_ADVANCED).keys(), ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('does-not-build', utils.MODE_ADVANCED).keys(), ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('normal', utils.MODE_ADVANCED).keys(), ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('non-critical', utils.MODE_ADVANCED).keys(), ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('minor', utils.MODE_ADVANCED).keys(), ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('wishlist', utils.MODE_ADVANCED).keys(), ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
-
-        self.assertItemsEqual(debbugs.get_tags('critical', utils.MODE_EXPERT).keys(), ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('grave', utils.MODE_EXPERT).keys(), ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('serious', utils.MODE_EXPERT).keys(), ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('important', utils.MODE_EXPERT).keys(), ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('does-not-build', utils.MODE_EXPERT).keys(), ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('normal', utils.MODE_EXPERT).keys(), ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('non-critical', utils.MODE_EXPERT).keys(), ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('minor', utils.MODE_EXPERT).keys(), ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
-        self.assertItemsEqual(debbugs.get_tags('wishlist', utils.MODE_EXPERT).keys(), ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('critical', utils.MODE_NOVICE).keys(),
+                              ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'security', 'patch', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('grave', utils.MODE_NOVICE).keys(),
+                              ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'security', 'patch', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('serious', utils.MODE_NOVICE).keys(),
+                              ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'security', 'patch', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('important', utils.MODE_NOVICE).keys(),
+                              ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('does-not-build', utils.MODE_NOVICE).keys(),
+                              ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('normal', utils.MODE_NOVICE).keys(),
+                              ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('non-critical', utils.MODE_NOVICE).keys(),
+                              ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('minor', utils.MODE_NOVICE).keys(),
+                              ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('wishlist', utils.MODE_NOVICE).keys(),
+                              ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
+
+        self.assertItemsEqual(debbugs.get_tags('critical', utils.MODE_STANDARD).keys(),
+                              ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'security', 'patch', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('grave', utils.MODE_STANDARD).keys(),
+                              ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'security', 'patch', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('serious', utils.MODE_STANDARD).keys(),
+                              ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'security', 'patch', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('important', utils.MODE_STANDARD).keys(),
+                              ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('does-not-build', utils.MODE_STANDARD).keys(),
+                              ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('normal', utils.MODE_STANDARD).keys(),
+                              ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('non-critical', utils.MODE_STANDARD).keys(),
+                              ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('minor', utils.MODE_STANDARD).keys(),
+                              ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('wishlist', utils.MODE_STANDARD).keys(),
+                              ['lfs', 'l10n', 'd-i', 'upstream', 'ipv6', 'patch', 'newcomer'])
+
+        self.assertItemsEqual(debbugs.get_tags('critical', utils.MODE_ADVANCED).keys(),
+                              ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('grave', utils.MODE_ADVANCED).keys(),
+                              ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('serious', utils.MODE_ADVANCED).keys(),
+                              ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('important', utils.MODE_ADVANCED).keys(),
+                              ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('does-not-build', utils.MODE_ADVANCED).keys(),
+                              ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('normal', utils.MODE_ADVANCED).keys(),
+                              ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('non-critical', utils.MODE_ADVANCED).keys(),
+                              ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('minor', utils.MODE_ADVANCED).keys(),
+                              ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('wishlist', utils.MODE_ADVANCED).keys(),
+                              ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
+
+        self.assertItemsEqual(debbugs.get_tags('critical', utils.MODE_EXPERT).keys(),
+                              ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('grave', utils.MODE_EXPERT).keys(),
+                              ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('serious', utils.MODE_EXPERT).keys(),
+                              ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('important', utils.MODE_EXPERT).keys(),
+                              ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('does-not-build', utils.MODE_EXPERT).keys(),
+                              ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('normal', utils.MODE_EXPERT).keys(),
+                              ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('non-critical', utils.MODE_EXPERT).keys(),
+                              ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('minor', utils.MODE_EXPERT).keys(),
+                              ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
+        self.assertItemsEqual(debbugs.get_tags('wishlist', utils.MODE_EXPERT).keys(),
+                              ['l10n', 'd-i', 'ipv6', 'patch', 'lfs', 'upstream', 'security', 'newcomer'])
 
 
 class TestInfofunc(unittest2.TestCase):
-
     def test_dpkg_infofunc(self):
         info = debbugs.dpkg_infofunc()
         arch = utils.get_arch()
@@ -68,19 +102,19 @@ class TestInfofunc(unittest2.TestCase):
         __save1 = utils.get_arch
         __save2 = utils.get_multiarch
 
-        utils.get_arch = mock.MagicMock(return_value = 'non-existing-arch')
+        utils.get_arch = mock.MagicMock(return_value='non-existing-arch')
         info = debbugs.dpkg_infofunc()
         self.assertIn('non-existing-arch', info)
         self.assertTrue(info.endswith('\n\n'))
 
         # test with get_arch() returning None
-        utils.get_arch = mock.MagicMock(return_value = None)
+        utils.get_arch = mock.MagicMock(return_value=None)
         info = debbugs.dpkg_infofunc()
         self.assertIn('Architecture: ?', info)
         self.assertTrue(info.endswith('\n\n'))
 
         # test with a dummy m-a setup
-        utils.get_multiarch = mock.MagicMock(return_value = 'multi-arch-ified')
+        utils.get_multiarch = mock.MagicMock(return_value='multi-arch-ified')
         info = debbugs.dpkg_infofunc()
         self.assertIn('Foreign Architectures:', info)
         self.assertIn('multi-arch-ified', info)
@@ -103,8 +137,8 @@ class TestInfofunc(unittest2.TestCase):
         info = debbugs.generic_infofunc()
         self.assertIn('Architecture:', info)
 
-class TestMiscFunctions(unittest2.TestCase):
 
+class TestMiscFunctions(unittest2.TestCase):
     def test_yn_bool(self):
         self.assertEqual(debbugs.yn_bool(None), 'no')
         self.assertEqual(debbugs.yn_bool('no'), 'no')
@@ -123,11 +157,11 @@ class TestMiscFunctions(unittest2.TestCase):
         for type, severity, value in sevs:
             self.assertEqual(debbugs.convert_severity(severity, type), value)
 
-    @attr('network') #marking the test as using network
+    @attr('network')  # marking the test as using network
     @unittest2.skip("Need to talk with dondelelcaro about make them sync")
     def test_pseudopackages_in_sync(self):
 
-        dictparse = re.compile(r'([^\s]+)\s+(.+)',re.IGNORECASE)
+        dictparse = re.compile(r'([^\s]+)\s+(.+)', re.IGNORECASE)
 
         bdo_list = {}
         pseudo = urllib.urlopen('https://bugs.debian.org/pseudopackages/pseudo-packages.description')
@@ -140,23 +174,18 @@ class TestMiscFunctions(unittest2.TestCase):
 
 
 class TestGetReports(unittest2.TestCase):
-
-    @attr('network') #marking the test as using network
+    @attr('network')  # marking the test as using network
     def test_get_cgi_reports(self):
-
         data = debbugs.get_cgi_reports('reportbug', timeout=60)
         self.assertGreater(data[0], 0)
 
-
-    @attr('network') #marking the test as using network
+    @attr('network')  # marking the test as using network
     def test_get_reports(self):
-
         data = debbugs.get_reports('reportbug', timeout=60)
         self.assertGreater(data[0], 0)
 
-    @attr('network') #marking the test as using network
+    @attr('network')  # marking the test as using network
     def test_get_report(self):
-
         buginfo, bodies = debbugs.get_report(415801, 120)
         self.assertEqual(buginfo.bug_num, 415801)
         self.assertEqual(buginfo.subject,
@@ -166,46 +195,40 @@ class TestGetReports(unittest2.TestCase):
         buginfo, bodies = debbugs.get_report(503300, 120)
         self.assertGreater(len(bodies), 0)
 
-    @attr('network') #marking the test as using network
+    @attr('network')  # marking the test as using network
     def test_bts796759(self):
-
         # verify accessing WNPP happens correctly, now that BTS
         # access has to be done in batches
         data = debbugs.get_reports('wnpp', 120, source=True)
         self.assertGreater(data[0], 0)
 
-class TestUrlFunctions(unittest2.TestCase):
 
+class TestUrlFunctions(unittest2.TestCase):
     def test_cgi_report_url(self):
-
         self.assertEqual(debbugs.cgi_report_url('debian', 123),
                          'https://bugs.debian.org/cgi-bin/bugreport.cgi?' +
-                             'bug=123&archived=False&mbox=no')
+                         'bug=123&archived=False&mbox=no')
         self.assertIsNone(debbugs.cgi_report_url('default', 123))
 
     def test_cgi_package_url(self):
-
         self.assertEqual(debbugs.cgi_package_url('debian', 'reportbug'),
                          'https://bugs.debian.org/cgi-bin/pkgreport.cgi?' +
-                             'archived=no&pkg=reportbug&repeatmerged=yes')
+                         'archived=no&pkg=reportbug&repeatmerged=yes')
         self.assertEqual(debbugs.cgi_package_url
                          ('debian', 'reportbug', source=True),
                          'https://bugs.debian.org/cgi-bin/pkgreport.cgi?src=' +
-                             'reportbug&archived=no&repeatmerged=yes')
+                         'reportbug&archived=no&repeatmerged=yes')
         self.assertEqual(debbugs.cgi_package_url
                          ('debian', 'reportbug', version='5.0'),
                          'https://bugs.debian.org/cgi-bin/pkgreport.cgi?archi' +
                          'ved=no&version=5.0&pkg=reportbug&repeatmerged=yes')
 
-
     def test_get_package_url(self):
-
         self.assertEqual(debbugs.get_package_url('debian', 'reportbug'),
                          'https://bugs.debian.org/cgi-bin/pkgreport.cgi?archi' +
                          'ved=no&pkg=reportbug&repeatmerged=yes')
 
     def test_get_report_url(self):
-
         self.assertEqual(debbugs.get_report_url('debian', 123),
                          'https://bugs.debian.org/cgi-bin/bugreport.cgi?' +
                          'bug=123&archived=False&mbox=no')
diff --git a/test/test_exception.py b/test/test_exception.py
index 02a5219..91fff7f 100644
--- a/test/test_exception.py
+++ b/test/test_exception.py
@@ -4,6 +4,7 @@ import unittest2
 
 from reportbug import exceptions
 
+
 class TestExceptions(unittest2.TestCase):
 
     def test_raises_reportbug_exception(self):
diff --git a/test/test_hiermatch.py b/test/test_hiermatch.py
index aceb377..934afec 100644
--- a/test/test_hiermatch.py
+++ b/test/test_hiermatch.py
@@ -9,6 +9,7 @@ test_strings_list = ['Beautiful is better than ugly.',
                      'Flat is better than nested.',
                      'Sparse is better than dense.']
 
+
 class TestHiermatch(unittest2.TestCase):
 
     def test_egrep_list(self):
diff --git a/test/test_tempfiles.py b/test/test_tempfiles.py
index 6b693b2..ab9862e 100644
--- a/test/test_tempfiles.py
+++ b/test/test_tempfiles.py
@@ -3,10 +3,9 @@ import unittest2
 from reportbug import tempfiles
 import os.path
 
-class TestTempfiles(unittest2.TestCase):
 
+class TestTempfiles(unittest2.TestCase):
     def test_tempfile_prefix(self):
-
         extra = 'dummystring'
 
         prefix = tempfiles.tempfile_prefix()
@@ -23,7 +22,6 @@ class TestTempfiles(unittest2.TestCase):
         self.assertIn(extra, prefix)
 
     def test_open_write_safe(self):
-
         filename = os.path.dirname(__file__) + '/tempfiletest'
         # binary file
         fd = tempfiles.open_write_safe(filename)
@@ -46,7 +44,6 @@ class TestTempfiles(unittest2.TestCase):
         tempfiles.cleanup_temp_file(filename)
 
     def test_TempFile(self):
-
         fd, filename = tempfiles.TempFile()
 
         self.assertIsNotNone(filename)
diff --git a/test/test_ui.py b/test/test_ui.py
index 6af84fb..6bf614b 100644
--- a/test/test_ui.py
+++ b/test/test_ui.py
@@ -6,6 +6,7 @@ from reportbug import utils
 from reportbug import ui
 from reportbug.ui import __LOADED_UIS as LOADED_UIS
 
+
 class TestUI(unittest2.TestCase):
 
     def test_ui(self):
diff --git a/test/test_ui_gtk2.py b/test/test_ui_gtk2.py
index 8649b51..a19a596 100644
--- a/test/test_ui_gtk2.py
+++ b/test/test_ui_gtk2.py
@@ -8,9 +8,9 @@ from reportbug import utils
 from reportbug.ui import gtk2_ui as ui
 import debianbts
 
-class TestUIGTK2(unittest2.TestCase):
 
-    @attr('network') #marking the test as using network
+class TestUIGTK2(unittest2.TestCase):
+    @attr('network')  # marking the test as using network
     def test_bug_class(self):
         bug = debianbts.get_status(415801)[0]
 
@@ -32,7 +32,7 @@ class TestUIGTK2(unittest2.TestCase):
 # moved here to see if they can be interested somehow,
 # but to use them, we'd need to find a way to interact
 # programmatically with the GTK+ widgets
-#def test ():
+# def test ():
 #    # Write some tests here
 #    print get_password ("test")
 #    print select_options ('test', 'A', {'a': 'A test'})
diff --git a/test/test_urlutils.py b/test/test_urlutils.py
index ed13839..0fd32d6 100644
--- a/test/test_urlutils.py
+++ b/test/test_urlutils.py
@@ -4,9 +4,10 @@ from nose.plugins.attrib import attr
 
 from reportbug import urlutils
 
+
 class TestNetwork(unittest2.TestCase):
 
-    @attr('network') #mark the test as using network
+    @attr('network')  # mark the test as using network
     def test_open_url(self):
 
         page = urlutils.open_url('https://bugs.debian.org/reportbug')
diff --git a/test/test_utils.py b/test/test_utils.py
index f9d8b57..1232f1a 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -9,17 +9,16 @@ import mock
 import commands
 import subprocess
 
-class TestUtils(unittest2.TestCase):
 
+class TestUtils(unittest2.TestCase):
     def test_modes_and_modelist(self):
         """Check MODES items and MODELIST are in sync"""
 
         self.assertItemsEqual(utils.MODES.keys(), utils.MODELIST)
 
-class TestEmail(unittest2.TestCase):
 
+class TestEmail(unittest2.TestCase):
     def test_check_email_addr(self):
-        
         real_addr = 'reportbug-maint at lists.alioth.debian.org'
 
         self.assertTrue(utils.check_email_addr(real_addr))
@@ -32,7 +31,6 @@ class TestEmail(unittest2.TestCase):
         self.assertFalse(utils.check_email_addr('too at many@at at signs'))
 
     def test_get_email_addr(self):
-
         email = 'Reportbug Maintainers <reportbug-maint at lists.alioth.debian.org>'
         name, email_addr = utils.get_email_addr(email)
 
@@ -40,7 +38,6 @@ class TestEmail(unittest2.TestCase):
         self.assertEqual(email_addr, 'reportbug-maint at lists.alioth.debian.org')
 
     def test_get_email(self):
-
         name = 'Reportbug Maintainers'
         mail = 'reportbug-maint at lists.alioth.debian.org'
 
@@ -50,7 +47,6 @@ class TestEmail(unittest2.TestCase):
         self.assertEqual(mail, m)
 
     def test_get_user_id(self):
-
         name = 'Reportbug Maintainers'
         mail = 'reportbug-maint at lists.alioth.debian.org'
         addr = utils.get_user_id(mail, name)
@@ -59,7 +55,7 @@ class TestEmail(unittest2.TestCase):
         name = 'test'
         mail = 'faked'
         addr = utils.get_user_id(mail, name)
-        self.assertIn(mail+'@', addr)
+        self.assertIn(mail + '@', addr)
 
         mail = 'Reportbug Maintainers <reportbug-maint at lists.alioth.debian.org>'
         addr = utils.get_user_id(mail)
@@ -69,14 +65,12 @@ class TestEmail(unittest2.TestCase):
         addr = utils.get_user_id(mail)
         self.assertIn(mail, addr)
 
-
     def test_find_rewritten(self):
         unittest2.skip("Is utils.find_rewritten actually useful to someone? deprecate it?")
 
-class TestPackages(unittest2.TestCase):
 
+class TestPackages(unittest2.TestCase):
     def test_get_package_status(self):
-
         status = utils.get_package_status('non-existing-package')
 
         (pkgversion, pkgavail, depends, recommends, conffiles, maintainer,
@@ -175,7 +169,6 @@ class TestPackages(unittest2.TestCase):
         self.assertListEqual(conffile, expected_conffiles)
 
     def test_get_changed_config_files(self):
-
         status = utils.get_package_status('dpkg')
 
         (pkgversion, pkgavail, depends, recommends, conffiles, maintainer,
@@ -204,7 +197,6 @@ class TestPackages(unittest2.TestCase):
         self.assertNotEqual(result[1], {})
 
     def test_get_package_info(self):
-
         result = utils.get_package_info([])
         self.assertEqual(result, [])
 
@@ -215,7 +207,7 @@ class TestPackages(unittest2.TestCase):
         self.assertEqual(result[0][0], pkg)
 
         # open package surely not available on my client systems
-        #to cover line 568
+        # to cover line 568
         pkg = 'slapd'
         result = utils.get_package_info([((pkg,), pkg)])
 
@@ -227,10 +219,10 @@ class TestPackages(unittest2.TestCase):
         self.assertEqual(result, [])
 
         # package with a Provides
-        #pkg = 'emacs'
-        #result = utils.get_package_info([((pkg,), pkg)])
+        # pkg = 'emacs'
+        # result = utils.get_package_info([((pkg,), pkg)])
 
-        #self.assertEqual(result[0][0], pkg)
+        # self.assertEqual(result[0][0], pkg)
 
     def test_bts683116(self):
         """Check Description and Description-LANG are recognized"""
@@ -263,10 +255,10 @@ Version: 6.6.3
         del __save
 
         __save = utils.get_dpkg_database
-        utils.get_dpkg_database = mock.MagicMock(return_value=[pkginfo % 'Description',])
+        utils.get_dpkg_database = mock.MagicMock(return_value=[pkginfo % 'Description', ])
         result = utils.get_package_info([((pkg,), pkg)])
         self.assertEqual(u'reports bugs in the Debian distribution', result[0][3])
-        utils.get_dpkg_database = mock.MagicMock(return_value=[pkginfo % 'Description-en',])
+        utils.get_dpkg_database = mock.MagicMock(return_value=[pkginfo % 'Description-en', ])
         result = utils.get_package_info([((pkg,), pkg)])
         self.assertEqual(u'reports bugs in the Debian distribution', result[0][3])
         utils.get_dpkg_database = __save
@@ -279,22 +271,20 @@ Version: 6.6.3
         self.assertGreater(len(result), 0)
 
     def test_get_avail_database(self):
-        
         avail_db = utils.get_avail_database()
         entry = avail_db.next()
         self.assertIsNotNone(entry)
 
     def test_available_package_description(self):
-
         descr = utils.available_package_description('reportbug')
         self.assertEquals(descr, 'reports bugs in the Debian distribution')
 
         descr = utils.available_package_description('reportbug-bugfree')
         self.assertIsNone(descr)
 
-class TestSourcePackages(unittest2.TestCase):
 
-    #@unittest2.skip("Too slow")
+class TestSourcePackages(unittest2.TestCase):
+    # @unittest2.skip("Too slow")
     def test_get_source_name(self):
         binpkg = 'python-reportbug'
         src = utils.get_source_name(binpkg)
@@ -303,7 +293,7 @@ class TestSourcePackages(unittest2.TestCase):
         src = utils.get_source_name('reportbug-bugfree')
         self.assertIsNone(src)
 
-    #@unittest2.skip("Too slow")
+    # @unittest2.skip("Too slow")
     def test_get_source_package(self):
         src = 'reportbug'
         binpkgs = utils.get_source_package(src)
@@ -313,54 +303,48 @@ class TestSourcePackages(unittest2.TestCase):
         binpkgs_frombin = utils.get_source_package(bin)
         self.assertEqual(binpkgs, binpkgs_frombin)
 
-class TestSystemInformation(unittest2.TestCase):
 
+class TestSystemInformation(unittest2.TestCase):
     def test_get_cpu_cores(self):
-
         cores = utils.get_cpu_cores()
         self.assertGreaterEqual(cores, 1)
 
-
     def test_lsb_release_info(self):
-
         res = utils.lsb_release_info()
         self.assertIn('Debian', res)
 
     def test_get_running_kernel_pkg(self):
-
         package = utils.get_running_kernel_pkg()
 
         self.assertIn(platform.release(), package)
 
     def test_get_multiarch(self):
-
         orig = commands.getoutput
 
-        commands.getoutput = mock.MagicMock(return_value = '')
+        commands.getoutput = mock.MagicMock(return_value='')
         multiarch = utils.get_multiarch()
         self.assertEqual(multiarch, '')
 
-        commands.getoutput = mock.MagicMock(return_value = 'i386')
+        commands.getoutput = mock.MagicMock(return_value='i386')
         multiarch = utils.get_multiarch()
         self.assertEqual(multiarch, 'i386')
 
-        commands.getoutput = mock.MagicMock(return_value = 'i386\namd64')
+        commands.getoutput = mock.MagicMock(return_value='i386\namd64')
         multiarch = utils.get_multiarch()
         self.assertItemsEqual(multiarch.split(', '), ['i386', 'amd64'])
 
         commands.getoutput = orig
 
     def test_get_init_system(self):
-
         __save = os.path.isdir
-        os.path.isdir = mock.MagicMock(return_value = True)
+        os.path.isdir = mock.MagicMock(return_value=True)
         init = utils.get_init_system()
         self.assertTrue(init.startswith('systemd'))
         os.path.isdir = __save
         del __save
 
         __save = subprocess.call
-        subprocess.call = mock.MagicMock(return_value = 0)
+        subprocess.call = mock.MagicMock(return_value=0)
         init = utils.get_init_system()
         self.assertTrue(init.startswith('upstart'))
         subprocess.call = __save
@@ -368,8 +352,8 @@ class TestSystemInformation(unittest2.TestCase):
 
         __save1 = os.path.isfile
         __save2 = os.path.islink
-        os.path.isfile = mock.MagicMock(return_value = True)
-        os.path.islink = mock.MagicMock(return_value = False)
+        os.path.isfile = mock.MagicMock(return_value=True)
+        os.path.islink = mock.MagicMock(return_value=False)
         init = utils.get_init_system()
         self.assertTrue(init.startswith('sysvinit'))
         os.path.isfile = __save1
@@ -377,8 +361,8 @@ class TestSystemInformation(unittest2.TestCase):
         del __save1
         del __save2
 
-class TestMua(unittest2.TestCase):
 
+class TestMua(unittest2.TestCase):
     def test_mua_is_supported(self):
 
         for mua in ('mh', 'nmh', 'gnus', 'mutt', 'claws-mail'):
@@ -401,7 +385,6 @@ class TestMua(unittest2.TestCase):
 
 
 class TestBugreportBody(unittest2.TestCase):
-
     def test_get_dependency_info(self):
 
         pkg = 'reportbug'
@@ -416,7 +399,6 @@ class TestBugreportBody(unittest2.TestCase):
         result = utils.get_dependency_info('reportbug', [['awk']])
         self.assertIn('awk', result)
 
-
     def test_bts657753(self):
         # check that non-existing deps gets a correct installation info
         # and not just the last one applied to anyone
@@ -488,8 +470,7 @@ Shell: /bin/sh linked to /bin/bash"""
         self.assertIn('Usertags', p)
         self.assertIn('Morph', p)
 
-
-    @attr('network') #marking the test as using network
+    @attr('network')  # marking the test as using network
     def test_generate_blank_report(self):
 
         report = utils.generate_blank_report('reportbug', '1.2.3', 'normal',
@@ -522,8 +503,8 @@ Shell: /bin/sh linked to /bin/bash"""
                                                  '', '', '', type='debbugs',
                                                  exinfo={'123456': ''})
 
-class TestConfig(unittest2.TestCase):
 
+class TestConfig(unittest2.TestCase):
     # Use an "internal" file for testing
     def setUp(self):
         self._FILES = utils.FILES
@@ -533,7 +514,6 @@ class TestConfig(unittest2.TestCase):
         utils.FILES = self._FILES
 
     def test_parse_config_files(self):
-
         desired_conf = {
             'bts': 'debian',
             'check_available': True,
@@ -588,9 +568,7 @@ class TestConfig(unittest2.TestCase):
 
 
 class TestControl(unittest2.TestCase):
-
     def test_parse_bug_control_file(self):
-
         ctrl_file = os.path.dirname(__file__) + '/data/control'
 
         submitas, submitto, reportwith, supplemental = \
@@ -603,10 +581,9 @@ class TestControl(unittest2.TestCase):
         self.assertIn('python', supplemental)
         self.assertIn('perl', supplemental)
 
-class TestPaths(unittest2.TestCase):
 
+class TestPaths(unittest2.TestCase):
     def test_search_path_for(self):
-
         p = 'not-existing'
         res = utils.search_path_for(p)
         self.assertIsNone(res)
@@ -619,21 +596,19 @@ class TestPaths(unittest2.TestCase):
         res = utils.search_path_for(p)
         self.assertEquals(res, '/usr/bin/dpkg')
 
-class TestEditor(unittest2.TestCase):
 
+class TestEditor(unittest2.TestCase):
     def test_which_editor(self):
-
         res = utils.which_editor()
         self.assertIsNotNone(res)
 
         e = 'reportbug-editor'
         res = utils.which_editor(e)
         self.assertEquals(e, res)
-        
-class TestSearch(unittest2.TestCase):
 
-    def test_search_pipe(self):
 
+class TestSearch(unittest2.TestCase):
+    def test_search_pipe(self):
         f = 'reportbug'
 
         dlocate = True
@@ -652,10 +627,9 @@ class TestSearch(unittest2.TestCase):
         self.assertEquals(dloc, dlocate)
         self.assertGreater(len(res), 0)
 
-class TestDpkg(unittest2.TestCase):
 
+class TestDpkg(unittest2.TestCase):
     def test_query_dpkg_for(self):
-
         p = 'reportbug'
         dlocate = True
         res = utils.query_dpkg_for(p, dlocate)
@@ -677,15 +651,13 @@ class TestDpkg(unittest2.TestCase):
         self.assertEquals(res[0], p)
         self.assertEquals(res[1], {})
 
-class TestMisc(unittest2.TestCase):
 
+class TestMisc(unittest2.TestCase):
     def test_first_run(self):
-
         isfirstrun = utils.first_run()
         self.assertIsNotNone(isfirstrun)
 
     def test_exec_and_parse_bugscript(self):
-
         handler = os.path.dirname(__file__) + '/../share/handle_bugscript'
         bugscript_file = os.path.dirname(__file__) + '/data/bugscript'
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reportbug/reportbug.git



More information about the Reportbug-commits mailing list