[jhbuild/py2-flake8] CI: run python2-flake8



commit 6cb1cf12e42101b2c41f94acb3a13c3b5797068e
Author: Christoph Reiter <reiter christoph gmail com>
Date:   Tue Sep 10 20:42:11 2019 +0200

    CI: run python2-flake8
    
    With lots of warnings/errors disabled for now. This catches basic things at
    least like undefined variables, typos etc and should make sure we don't
    introduce any syntax errors.

 .flake8                             |  5 ++++
 .gitlab-ci.yml                      |  1 +
 .gitlab-ci/Dockerfile               |  1 +
 jhbuild/commands/autobuild.py       |  2 +-
 jhbuild/commands/base.py            |  6 ++---
 jhbuild/commands/checkbranches.py   |  2 +-
 jhbuild/commands/checkmodulesets.py |  4 +--
 jhbuild/commands/extdeps.py         |  7 +++---
 jhbuild/commands/goalreport.py      | 43 ++++++++++++++++++--------------
 jhbuild/commands/make.py            |  2 +-
 jhbuild/commands/sanitycheck.py     |  6 ++---
 jhbuild/commands/sysdeps.py         |  6 ++---
 jhbuild/commands/tinderbox.py       |  4 +--
 jhbuild/commands/twoninetynine.py   |  2 +-
 jhbuild/config.py                   | 49 ++++++++++++++++++-------------------
 jhbuild/environment.py              | 12 ++++-----
 jhbuild/frontends/autobuild.py      | 14 ++++++-----
 jhbuild/frontends/buildscript.py    |  5 ++--
 jhbuild/frontends/gtkui.py          |  8 +++---
 jhbuild/frontends/terminal.py       | 30 +++++++++++++++--------
 jhbuild/frontends/tinderbox.py      | 18 ++++++++------
 jhbuild/main.py                     | 11 ++++++---
 jhbuild/modtypes/__init__.py        | 38 ++++++++++++++--------------
 jhbuild/modtypes/autotools.py       |  8 +++---
 jhbuild/modtypes/cmake.py           |  3 ---
 jhbuild/modtypes/meson.py           |  1 -
 jhbuild/modtypes/perl.py            |  2 +-
 jhbuild/modtypes/tarball.py         |  9 ++++---
 jhbuild/modtypes/testmodule.py      | 18 ++++++--------
 jhbuild/modtypes/waf.py             |  2 +-
 jhbuild/moduleset.py                | 27 ++++++++++----------
 jhbuild/utils/cmds.py               |  3 +--
 jhbuild/utils/fileutils.py          |  4 +--
 jhbuild/utils/httpcache.py          | 12 ++++++---
 jhbuild/utils/packagedb.py          |  5 ++--
 jhbuild/utils/subprocess_win32.py   |  6 +++--
 jhbuild/utils/sxml.py               |  1 +
 jhbuild/utils/sysid.py              |  2 +-
 jhbuild/utils/systeminstall.py      | 13 +++++-----
 jhbuild/utils/trayicon.py           |  5 ++--
 jhbuild/utils/trigger.py            | 28 ++++++++++-----------
 jhbuild/versioncontrol/__init__.py  | 16 ++++++------
 jhbuild/versioncontrol/bzr.py       |  4 +--
 jhbuild/versioncontrol/cvs.py       | 11 +++++----
 jhbuild/versioncontrol/darcs.py     |  6 ++---
 jhbuild/versioncontrol/fossil.py    |  4 +--
 jhbuild/versioncontrol/git.py       | 12 ++++-----
 jhbuild/versioncontrol/hg.py        |  4 +--
 jhbuild/versioncontrol/mtn.py       |  4 +--
 jhbuild/versioncontrol/svn.py       | 15 +++++++-----
 jhbuild/versioncontrol/tarball.py   |  9 ++++---
 scripts/hg-update.py                |  2 +-
 scripts/mk-tarball-moduleset.py     |  5 ++--
 tests/tests.py                      |  9 ++++---
 54 files changed, 282 insertions(+), 244 deletions(-)
---
diff --git a/.flake8 b/.flake8
new file mode 100644
index 00000000..a8bfd02c
--- /dev/null
+++ b/.flake8
@@ -0,0 +1,5 @@
+[flake8]
+ignore=E122,E402,E126,E128,F401,E401,W504,W503,E201,E302,E305,E251,E203,E124,E231,W293,E261,E221,E211,E502,E722,W391,E301,E202,E225,E227,W291,E303,E226,E131,E123,E241
+max-line-length=160
+builtins=SRCDIR,_,N_,uencode,uprint,PKGDATADIR,DATADIR,udecode
+exclude=jhbuild/modtypes/linux.py
\ No newline at end of file
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 31a34886..560f04ac 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -11,6 +11,7 @@ test:
     - make install
     - make distcheck
     - cd ..
+    - python2 -m flake8 .
     - mkdir public
     - cd public
     - yelp-build html ../doc/C/index.docbook
diff --git a/.gitlab-ci/Dockerfile b/.gitlab-ci/Dockerfile
index 268522ed..9b440f87 100644
--- a/.gitlab-ci/Dockerfile
+++ b/.gitlab-ci/Dockerfile
@@ -14,6 +14,7 @@ RUN apt update && apt install -y \
     patch \
     pkg-config \
     python \
+    python-flake8 \
     sudo \
     trang \
     yelp-tools
diff --git a/jhbuild/commands/autobuild.py b/jhbuild/commands/autobuild.py
index 9ccd87e3..fdebc943 100644
--- a/jhbuild/commands/autobuild.py
+++ b/jhbuild/commands/autobuild.py
@@ -19,7 +19,7 @@
 
 from optparse import make_option
 
-from jhbuild.errors import UsageError
+from jhbuild.errors import UsageError, FatalError
 from jhbuild.commands.base import Command, register_command
 import jhbuild.frontends
 import optparse
diff --git a/jhbuild/commands/base.py b/jhbuild/commands/base.py
index 447a3ab5..3f00b144 100644
--- a/jhbuild/commands/base.py
+++ b/jhbuild/commands/base.py
@@ -234,8 +234,8 @@ class cmd_build(BuildCommand):
 
         module_set = jhbuild.moduleset.load(config)
         modules = args or config.modules
-        full_module_list = module_set.get_full_module_list \
-                               (modules, config.skip,
+        full_module_list = module_set.get_full_module_list(
+                                modules, config.skip,
                                 include_suggests=not config.ignore_suggests,
                                 include_afters=options.build_optional_modules)
         full_module_list = module_set.remove_tag_modules(full_module_list,
@@ -325,7 +325,7 @@ class cmd_buildone(BuildCommand):
             modname = modname.rstrip(os.sep)
             try:
                 module = module_set.get_module(modname, ignore_case=True)
-            except KeyError as e:
+            except KeyError:
                 default_repo = jhbuild.moduleset.get_default_repo()
                 if not default_repo:
                     continue
diff --git a/jhbuild/commands/checkbranches.py b/jhbuild/commands/checkbranches.py
index c91ec80a..7920434e 100644
--- a/jhbuild/commands/checkbranches.py
+++ b/jhbuild/commands/checkbranches.py
@@ -52,7 +52,7 @@ class cmd_checkbranches(Command):
                 continue
             if not mod.branch or not mod.branch.repository.__class__.__name__ == 'GitRepository':
                 continue
-            if not 'git.gnome.org' in mod.branch.repository.href:
+            if 'git.gnome.org' not in mod.branch.repository.href:
                 continue
             if mod.branch.branch:
                 # there is already a branch defined
diff --git a/jhbuild/commands/checkmodulesets.py b/jhbuild/commands/checkmodulesets.py
index 216a386a..c7d451dd 100644
--- a/jhbuild/commands/checkmodulesets.py
+++ b/jhbuild/commands/checkmodulesets.py
@@ -32,8 +32,8 @@ class cmd_checkmodulesets(Command):
 
     def run(self, config, options, args, help=None):
         module_set = jhbuild.moduleset.load(config)
-        module_list = module_set.get_full_module_list \
-                          (warn_about_circular_dependencies = True)
+        module_list = module_set.get_full_module_list(
+            warn_about_circular_dependencies = True)
         for mod in module_list:
             if mod.type in ('meta', 'tarball'):
                 continue
diff --git a/jhbuild/commands/extdeps.py b/jhbuild/commands/extdeps.py
index fa3fa26d..8bf2d16a 100644
--- a/jhbuild/commands/extdeps.py
+++ b/jhbuild/commands/extdeps.py
@@ -98,7 +98,7 @@ class cmd_extdeps(Command):
         title = _('External deps for GNOME')
         for ms in moduleset:
             try:
-                gnome_ver = re.findall('\d+\.\d+', ms)[0]
+                gnome_ver = re.findall('\\d+\\.\\d+', ms)[0]
             except IndexError:
                 continue
             title = _('External deps for GNOME %s') % gnome_ver
@@ -110,7 +110,7 @@ class cmd_extdeps(Command):
 
         module_list.sort(lambda x,y: cmp(x.name.lower(), y.name.lower()))
         for mod in module_list:
-            #if not mod.moduleset_name.startswith('gnome-suites-core-deps-base'):
+            # if not mod.moduleset_name.startswith('gnome-suites-core-deps-base'):
             #    continue
 
             if not hasattr(mod.branch, 'version'):
@@ -161,7 +161,8 @@ class cmd_extdeps(Command):
     def compute_rdeps(self, module):
         rdeps = []
         for mod in self.module_set.modules.values():
-            if mod.type == 'meta': continue
+            if mod.type == 'meta':
+                continue
             if module.name in mod.dependencies:
                 rdeps.append(mod.name)
         rdeps.sort(lambda x,y: cmp(x.lower(), y.lower()))
diff --git a/jhbuild/commands/goalreport.py b/jhbuild/commands/goalreport.py
index 8867a1c1..59f59792 100644
--- a/jhbuild/commands/goalreport.py
+++ b/jhbuild/commands/goalreport.py
@@ -45,18 +45,24 @@ except ImportError:
 from jhbuild.errors import FatalError
 import jhbuild.moduleset
 from jhbuild.commands import Command, register_command
-from jhbuild.utils import httpcache
+from jhbuild.utils import httpcache, cmds
 from jhbuild.modtypes import MetaModule
 
-try: t_bold = cmds.get_output(['tput', 'bold'])
+try:
+    t_bold = cmds.get_output(['tput', 'bold'])
 except:
-    try: t_bold = cmds.get_output(['tput', 'md'])
-    except: t_bold = ''
+    try:
+        t_bold = cmds.get_output(['tput', 'md'])
+    except:
+        t_bold = ''
 
-try: t_reset = cmds.get_output(['tput', 'sgr0'])
+try:
+    t_reset = cmds.get_output(['tput', 'sgr0'])
 except:
-    try: t_reset = cmds.get_output(['tput', 'me'])
-    except: t_reset = ''
+    try:
+        t_reset = cmds.get_output(['tput', 'me'])
+    except:
+        t_reset = ''
 
 HTML_AT_TOP = '''<html>
 <head>
@@ -141,7 +147,7 @@ class Check:
     def fix_false_positive(self, false_positive):
         if not false_positive:
             return
-        if false_positive ==  'n/a':
+        if false_positive == 'n/a':
             raise ExcludedModuleException()
         self.status = 'ok'
 
@@ -319,7 +325,7 @@ class DeprecatedSymbolsCheck(SymbolsCheck):
             except:
                 raise CouldNotPerformCheckException()
             for keyword in tree.findall('//{http://www.devhelp.net/book}keyword'):
-                if not keyword.attrib.has_key('deprecated'):
+                if 'deprecated' not in keyword.attrib:
                     continue
                 name = keyword.attrib.get('name').replace('enum ', '').replace('()', '').strip()
                 symbols.append(name)
@@ -410,7 +416,7 @@ class cmd_goalreport(Command):
         for module_num, mod in enumerate(self.module_list):
             if mod.type in ('meta', 'tarball'):
                 continue
-            if not mod.branch or not mod.branch.repository.__class__.__name__ in (
+            if not mod.branch or mod.branch.repository.__class__.__name__ not in (
                     'SubversionRepository', 'GitRepository'):
                 if not mod.moduleset_name.startswith('gnome-external-deps'):
                     continue
@@ -421,7 +427,7 @@ class cmd_goalreport(Command):
             tree_id = mod.branch.tree_id()
             valid_cache = (tree_id and results.get(mod.name, {}).get('tree-id') == tree_id)
 
-            if not mod.name in results:
+            if mod.name not in results:
                 results[mod.name] = {
                     'results': {}
                 }
@@ -476,6 +482,7 @@ class cmd_goalreport(Command):
         print >> output, '</thead>'
         print >> output, '<tbody>'
 
+        processed_modules = {'gnome-common': True}
         suites = []
         for module_key, module in module_set.modules.items():
             if not isinstance(module_set.get_module(module_key), MetaModule):
@@ -483,7 +490,7 @@ class cmd_goalreport(Command):
             if module_key.endswith('upcoming-deprecations'):
                 # mark deprecated modules as processed, so they don't show in "Others"
                 try:
-                    metamodule = module_set.get_module(meta_key)
+                    metamodule = module_set.get_module(module_key)
                 except KeyError:
                     continue
                 for module_name in metamodule.dependencies:
@@ -491,8 +498,6 @@ class cmd_goalreport(Command):
             else:
                 suites.append([module_key, module_key.replace('meta-', '')])
 
-        processed_modules = {'gnome-common': True}
-
         not_other_module_names = []
         for suite_key, suite_label in suites:
             metamodule = module_set.get_module(suite_key)
@@ -511,13 +516,13 @@ class cmd_goalreport(Command):
 
         external_deps = [x for x in results.keys() if \
                          x in [y.name for y in self.module_list] and \
-                         not x in processed_modules and \
+                         x not in processed_modules and \
                          module_set.get_module(x).moduleset_name.startswith('gnome-external-deps')]
         if external_deps:
             print >> output, '<tr><td class="heading" colspan="%d">%s</td></tr>' % (
                     1+len(self.checks)+self.repeat_row_header, 'External Dependencies')
             for module_name in sorted(external_deps):
-                if not module_name in results:
+                if module_name not in results:
                     continue
                 r = results[module_name].get('results')
                 try:
@@ -527,12 +532,12 @@ class cmd_goalreport(Command):
                 print >> output, self.get_mod_line(module_name, r, version_number=version)
 
         other_module_names = [x for x in results.keys() if \
-                              not x in processed_modules and not x in external_deps]
+                              x not in processed_modules and x not in external_deps]
         if other_module_names:
             print >> output, '<tr><td class="heading" colspan="%d">%s</td></tr>' % (
                     1+len(self.checks)+self.repeat_row_header, 'Others')
             for module_name in sorted(other_module_names):
-                if not module_name in results:
+                if module_name not in results:
                     continue
                 r = results[module_name].get('results')
                 print >> output, self.get_mod_line(module_name, r)
@@ -648,7 +653,7 @@ class cmd_goalreport(Command):
             nb_with_bugs_done = 0
             for module_name in module_names:
                 k = (module_name, check.__name__)
-                if not k in self.bugs or not check.__name__ in results[module_name]['results']:
+                if k not in self.bugs or check.__name__ not in results[module_name]['results']:
                     continue
                 nb_with_bugs += 1
                 if results[module_name]['results'][check.__name__][0] == 'ok':
diff --git a/jhbuild/commands/make.py b/jhbuild/commands/make.py
index aa55d396..e49d0169 100644
--- a/jhbuild/commands/make.py
+++ b/jhbuild/commands/make.py
@@ -84,7 +84,7 @@ class cmd_make(Command):
 
         try:
             module = module_set.get_module(modname, ignore_case=True)
-        except KeyError as e:
+        except KeyError:
             default_repo = jhbuild.moduleset.get_default_repo()
             if not default_repo:
                 logging.error(_('No module matching current directory %r in the moduleset') % (modname, ))
diff --git a/jhbuild/commands/sanitycheck.py b/jhbuild/commands/sanitycheck.py
index 7d4b8e31..0242ab31 100644
--- a/jhbuild/commands/sanitycheck.py
+++ b/jhbuild/commands/sanitycheck.py
@@ -104,7 +104,7 @@ class cmd_sanitycheck(Command):
                                  ('http://docbook.sourceforge.net/release/xsl/current/html/chunk.xsl',
                                   'DocBook XSL Stylesheets')]:
                 try:
-                    data = get_output(['xmlcatalog', '/etc/xml/catalog', item])
+                    get_output(['xmlcatalog', '/etc/xml/catalog', item])
                 except:
                     uprint(_('Could not find %s in XML catalog (usually part of package \'docbook-xsl\')') % 
name)
 
@@ -126,12 +126,12 @@ class cmd_sanitycheck(Command):
         else:
             try:
                 git_help = os.popen('git --help', 'r').read()
-                if not 'clone' in git_help:
+                if 'clone' not in git_help:
                     uprint(_('Installed git program is not the right git'))
                 else:
                     if not check_version(['git', '--version'],
                                  r'git version ([\d.]+)', '1.5.6'):
-                         uprint(_('%s not found') % 'git >= 1.5.6')
+                        uprint(_('%s not found') % 'git >= 1.5.6')
             except:
                 uprint(_('Could not check git program'))
 
diff --git a/jhbuild/commands/sysdeps.py b/jhbuild/commands/sysdeps.py
index 735c3970..0abdf81d 100644
--- a/jhbuild/commands/sysdeps.py
+++ b/jhbuild/commands/sysdeps.py
@@ -51,7 +51,7 @@ class cmd_sysdeps(cmd_build):
                         action="store_true", default = False,
                         dest="assume_yes",
                         help=_('assume yes/the default answer to interactive questions during installation 
of system '
-                                + 'dependencies"'))])
+                               + 'dependencies"'))])
 
     def run(self, config, options, args, help=None):
 
@@ -79,7 +79,7 @@ class cmd_sysdeps(cmd_build):
         if options.dump_all:
             for module in module_list:
                 if (isinstance(module, SystemModule) or isinstance(module.branch, TarballBranch) and
-                                                        module.pkg_config is not None):
+                        module.pkg_config is not None):
                     if module.pkg_config is not None:
                         print 'pkgconfig:{0}'.format(module.pkg_config[:-3]) # remove .pc
 
@@ -215,7 +215,7 @@ class cmd_sysdeps(cmd_build):
                 logging.info(_("No uninstalled system dependencies to install for modules: %r") % (modules, 
))
             else:
                 logging.info(_("Installing dependencies on system: %s") % \
-                               ' '.join(pkg[0] for pkg in uninstalled))
+                             ' '.join(pkg[0] for pkg in uninstalled))
                 installer.install(uninstalled, assume_yes=options.assume_yes)
 
 register_command(cmd_sysdeps)
diff --git a/jhbuild/commands/tinderbox.py b/jhbuild/commands/tinderbox.py
index 672ae33d..2526af0c 100644
--- a/jhbuild/commands/tinderbox.py
+++ b/jhbuild/commands/tinderbox.py
@@ -82,8 +82,8 @@ class cmd_tinderbox(BuildCommand):
             raise UsageError(_('output directory for tinderbox build not specified'))
 
         module_set = jhbuild.moduleset.load(config)
-        full_module_list = module_set.get_full_module_list \
-                               (args or config.modules, config.skip)
+        full_module_list = module_set.get_full_module_list(
+            args or config.modules, config.skip)
         module_list = module_set.remove_system_modules(full_module_list)
 
         # remove modules up to startat
diff --git a/jhbuild/commands/twoninetynine.py b/jhbuild/commands/twoninetynine.py
index 4ed1e0ea..4fbeb5b8 100644
--- a/jhbuild/commands/twoninetynine.py
+++ b/jhbuild/commands/twoninetynine.py
@@ -54,7 +54,7 @@ class LibGnomeUi(ShellCheck):
                     "gnome-desktop-thumbnail.h|"\
                     "gnome-bg-crossfade.h|"\
                     "gnome-bg.h'", # gnome-desktop installs stuff under libgnomeui/
-        "find -name '*.py' | xargs grep 'import .*gnome\.ui'",
+        "find -name '*.py' | xargs grep 'import .*gnome\\.ui'",
     )
 
 class LibGnomeCanvas(ShellCheck):
diff --git a/jhbuild/config.py b/jhbuild/config.py
index d911c92d..3c31ee2b 100644
--- a/jhbuild/config.py
+++ b/jhbuild/config.py
@@ -113,20 +113,18 @@ class Config:
             raise FatalError(_('could not load config defaults'))
 
         old_config = os.path.join(os.path.expanduser('~'), '.jhbuildrc')
-        new_config = os.path.join \
-                         (os.environ.get \
-                             ('XDG_CONFIG_HOME',
-                              os.path.join(os.path.expanduser('~'), '.config')),
-                          'jhbuildrc')
+        new_config = os.path.join(os.environ.get('XDG_CONFIG_HOME',
+            os.path.join(os.path.expanduser('~'), '.config')),
+            'jhbuildrc')
 
         if filename:
             if not os.path.exists(filename):
                 raise FatalError(_('could not load config file, %s is missing') % filename)
         else:
             if os.path.isfile(old_config) \
-                and not os.path.islink(old_config) \
-                and os.path.isfile(new_config) \
-                and not os.path.islink(new_config):
+                    and not os.path.islink(old_config) \
+                    and os.path.isfile(new_config) \
+                    and not os.path.islink(new_config):
                 raise FatalError(_('The default location of the configuration '
                                    'file has changed. Please move %(old_path)s'
                                    ' to %(new_path)s.' \
@@ -236,7 +234,7 @@ class Config:
             config['repos'].update(config['svnroots'])
 
         # environment variables
-        if config.has_key('cflags') and config['cflags']:
+        if 'cflags' in config and config['cflags']:
             os.environ['CFLAGS'] = config['cflags']
         if config.get('installprog') and os.path.exists(config['installprog']):
             os.environ['INSTALL'] = config['installprog']
@@ -254,7 +252,8 @@ class Config:
             setattr(self, name, config[name])
 
         # default tarballdir to checkoutroot
-        if not self.tarballdir: self.tarballdir = self.checkoutroot
+        if not self.tarballdir:
+            self.tarballdir = self.checkoutroot
 
         # Ensure top_builddir is absolute
         if not os.path.isabs(self.top_builddir):
@@ -289,7 +288,7 @@ class Config:
         if not os.path.isabs(self.tarballdir):
             raise FatalError(_('%s must be an absolute path') % 'tarballdir')
         if (self.tinderbox_outputdir and
-            not os.path.isabs(self.tinderbox_outputdir)):
+                not os.path.isabs(self.tinderbox_outputdir)):
             raise FatalError(_('%s must be an absolute path') %
                              'tinderbox_outputdir')
 
@@ -324,11 +323,11 @@ class Config:
 
     def update_build_targets(self):
         # update build targets according to old flags
-        if self.makecheck and not 'check' in self.build_targets:
+        if self.makecheck and 'check' not in self.build_targets:
             self.build_targets.insert(0, 'check')
-        if self.makeclean and not 'clean' in self.build_targets:
+        if self.makeclean and 'clean' not in self.build_targets:
             self.build_targets.insert(0, 'clean')
-        if self.makedistclean and not 'distclean' in self.build_targets:
+        if self.makedistclean and 'distclean' not in self.build_targets:
             self.build_targets.insert(0, 'distclean')
         if self.nobuild:
             # nobuild actually means "checkout"
@@ -336,9 +335,9 @@ class Config:
                 if phase in self.build_targets:
                     self.build_targets.remove(phase)
             self.build_targets.append('checkout')
-        if self.makedist and not 'dist' in self.build_targets:
+        if self.makedist and 'dist' not in self.build_targets:
             self.build_targets.append('dist')
-        if self.makedistcheck and not 'distcheck' in self.build_targets:
+        if self.makedistcheck and 'distcheck' not in self.build_targets:
             self.build_targets.append('distcheck')
 
     def set_from_cmdline_options(self, options=None):
@@ -349,19 +348,19 @@ class Config:
         if hasattr(options, 'autogen') and options.autogen:
             self.alwaysautogen = True
         if hasattr(options, 'check') and (
-                options.check and not 'check' in self.build_targets):
+                options.check and 'check' not in self.build_targets):
             self.build_targets.insert(0, 'check')
         if hasattr(options, 'clean') and (
-                options.clean and not 'clean' in self.build_targets):
+                options.clean and 'clean' not in self.build_targets):
             self.build_targets.insert(0, 'clean')
         if hasattr(options, 'distclean') and (
-                options.distclean and not 'distclean' in self.build_targets):
+                options.distclean and 'distclean' not in self.build_targets):
             self.build_targets.insert(0, 'distclean')
         if hasattr(options, 'dist') and (
-                options.dist and not 'dist' in self.build_targets):
+                options.dist and 'dist' not in self.build_targets):
             self.build_targets.append('dist')
         if hasattr(options, 'distcheck') and (
-                options.distcheck and not 'distcheck' in self.build_targets):
+                options.distcheck and 'distcheck' not in self.build_targets):
             self.build_targets.append('distcheck')
         if hasattr(options, 'ignore_suggests') and options.ignore_suggests:
             self.ignore_suggests = True
@@ -374,10 +373,10 @@ class Config:
             for item in options.tags:
                 self.tags += item.split(',')
         if hasattr(options, 'sticky_date') and options.sticky_date is not None:
-                self.sticky_date = options.sticky_date
+            self.sticky_date = options.sticky_date
         if hasattr(options, 'xvfb') and options.noxvfb is not None:
-                self.noxvfb = options.noxvfb
-        if hasattr(options, 'trycheckout') and  options.trycheckout:
+            self.noxvfb = options.noxvfb
+        if hasattr(options, 'trycheckout') and options.trycheckout:
             self.trycheckout = True
         if hasattr(options, 'nopoison') and options.nopoison:
             self.nopoison = True
@@ -392,7 +391,7 @@ class Config:
                 raise FatalError(_('Failed to parse \'min_age\' relative '
                                    'time'))
         if (hasattr(options, 'check_sysdeps') and
-            options.check_sysdeps is not None):
+                options.check_sysdeps is not None):
             self.check_sysdeps = options.check_sysdeps
 
     def __setattr__(self, k, v):
diff --git a/jhbuild/environment.py b/jhbuild/environment.py
index dfd29119..6cda0997 100644
--- a/jhbuild/environment.py
+++ b/jhbuild/environment.py
@@ -91,33 +91,33 @@ def setup_env_defaults(system_libdirs):
                 addpath('PKG_CONFIG_PATH', full_name)
 
     # GI_TYPELIB_PATH
-    if not 'GI_TYPELIB_PATH' in os.environ:
+    if 'GI_TYPELIB_PATH' not in os.environ:
         for dirname in reversed(system_libdirs):
             full_name = os.path.join(dirname, 'girepository-1.0')
             if os.path.exists(full_name):
                 addpath('GI_TYPELIB_PATH', full_name)
 
     # XDG_DATA_DIRS
-    if not 'XDG_DATA_DIRS' in os.environ:
+    if 'XDG_DATA_DIRS' not in os.environ:
         os.environ['XDG_DATA_DIRS'] = '/usr/local/share:/usr/share'
 
     # XDG_CONFIG_DIRS
-    if not 'XDG_CONFIG_DIRS' in os.environ:
+    if 'XDG_CONFIG_DIRS' not in os.environ:
         os.environ['XDG_CONFIG_DIRS']='/etc/xdg'
 
     # ACLOCAL_PATH
-    if not 'ACLOCAL_PATH' in os.environ:
+    if 'ACLOCAL_PATH' not in os.environ:
         os.environ['ACLOCAL_PATH']='/usr/share/aclocal'
 
     # get rid of gdkxft from the env -- it will cause problems.
-    if os.environ.has_key('LD_PRELOAD'):
+    if 'LD_PRELOAD' in os.environ:
         valarr = os.environ['LD_PRELOAD'].split(' ')
         for x in valarr[:]:
             if x.find('libgdkxft.so') >= 0:
                 valarr.remove(x)
         os.environ['LD_PRELOAD'] = ' '.join(valarr)
 
-    if os.environ.has_key('CONFIG_SITE'):
+    if 'CONFIG_SITE' in os.environ:
         del os.environ['CONFIG_SITE']
 
 def setup_env(prefix):
diff --git a/jhbuild/frontends/autobuild.py b/jhbuild/frontends/autobuild.py
index 28af2410..e44af9a2 100644
--- a/jhbuild/frontends/autobuild.py
+++ b/jhbuild/frontends/autobuild.py
@@ -142,18 +142,20 @@ class AutobuildBuildScript(buildscript.BuildScript, TerminalBuildScript):
         kws['stderr'] = subprocess.PIPE
         if hint in ('cvs', 'svn', 'hg-update.py'):
             def format_line(line, error_output, fp=self.phasefp):
-                if line[-1] == '\n': line = line[:-1]
+                if line[-1] == '\n':
+                    line = line[:-1]
                 if self.verbose:
                     print line
                 if line.startswith('C '):
                     fp.write('<span class="conflict">%s</span>\n'
-                                        % escape(line))
+                             % escape(line))
                 else:
                     fp.write('%s\n' % escape(line))
             kws['stderr'] = subprocess.STDOUT
         else:
             def format_line(line, error_output, fp=self.phasefp):
-                if line[-1] == '\n': line = line[:-1]
+                if line[-1] == '\n':
+                    line = line[:-1]
                 if self.verbose:
                     if error_output:
                         print >> sys.stderr, line
@@ -161,7 +163,7 @@ class AutobuildBuildScript(buildscript.BuildScript, TerminalBuildScript):
                         print line
                 if error_output:
                     fp.write('<span class="error">%s</span>\n'
-                                        % escape(line))
+                             % escape(line))
                 else:
                     fp.write('%s\n' % escape(line))
 
@@ -256,7 +258,7 @@ class AutobuildBuildScript(buildscript.BuildScript, TerminalBuildScript):
                 self.modules = jhbuild.moduleset.load_tests(self.config)
 
             if module in self.modules.modules.keys() \
-                   and self.modules.modules[module].test_type == 'ldtp':
+                    and self.modules.modules[module].test_type == 'ldtp':
                 self._upload_logfile(module)
 
         if isinstance(error, Exception):
@@ -270,7 +272,7 @@ class AutobuildBuildScript(buildscript.BuildScript, TerminalBuildScript):
 
     def _upload_ldtp_logfile (self, module):
         test_module = self.modules.modules[module]
-        src_dir =  test_module.get_srcdir()
+        src_dir = test_module.get_srcdir()
         if not os.path.exists (os.path.join(src_dir,'run.xml')):
             return
         logfile = test_module.get_ldtp_log_file (os.path.join(src_dir,'run.xml'))
diff --git a/jhbuild/frontends/buildscript.py b/jhbuild/frontends/buildscript.py
index ee1ff017..747b92b2 100644
--- a/jhbuild/frontends/buildscript.py
+++ b/jhbuild/frontends/buildscript.py
@@ -74,7 +74,7 @@ class BuildScript:
             chrt_args = ['chrt', '--idle', '0']
             devnull = open(os.devnull, 'w')
             if (cmds.has_command('chrt') and
-                subprocess.call(chrt_args + ['true'], stdout=devnull, stderr=devnull) == 0):
+                    subprocess.call(chrt_args + ['true'], stdout=devnull, stderr=devnull) == 0):
                 self.subprocess_nice_args.extend(chrt_args)
 
             elif cmds.has_command('nice'):
@@ -109,7 +109,6 @@ class BuildScript:
         self.start_build()
         
         failures = [] # list of modules that couldn't be built
-        successes = []
         self.module_num = 0
         for module in self.modulelist:
             self.module_num = self.module_num + 1
@@ -307,7 +306,7 @@ class BuildScript:
         # remove duplicates
         phases = []
         for phase in tmp_phases:
-            if not phase in phases:
+            if phase not in phases:
                 phases.append(phase)
 
         return phases
diff --git a/jhbuild/frontends/gtkui.py b/jhbuild/frontends/gtkui.py
index 347d7e7b..9dbf11d2 100644
--- a/jhbuild/frontends/gtkui.py
+++ b/jhbuild/frontends/gtkui.py
@@ -282,10 +282,10 @@ class AppWindow(gtk.Window, buildscript.BuildScript):
             modules = [self.modules_list_model.get(
                     self.module_combo.get_active_iter(), 0)[0]]
 
-            self.modulelist = self.module_set.get_module_list \
-                                  (modules, self.config.skip,
-                                   tags = self.config.tags,
-                                   include_suggests=not self.config.ignore_suggests)
+            self.modulelist = self.module_set.get_module_list(
+                                    modules, self.config.skip,
+                                    tags = self.config.tags,
+                                    include_suggests=not self.config.ignore_suggests)
         else:
             self.orig_modulelist = None
 
diff --git a/jhbuild/frontends/terminal.py b/jhbuild/frontends/terminal.py
index 9b7552d6..15a291f5 100644
--- a/jhbuild/frontends/terminal.py
+++ b/jhbuild/frontends/terminal.py
@@ -35,15 +35,21 @@ term = os.environ.get('TERM', '')
 is_xterm = term.find('xterm') >= 0 or term == 'rxvt'
 del term
 
-try: t_bold = cmds.get_output(['tput', 'bold'])
+try:
+    t_bold = cmds.get_output(['tput', 'bold'])
 except:
-    try: t_bold = cmds.get_output(['tput', 'md'])
-    except: t_bold = ''
+    try:
+        t_bold = cmds.get_output(['tput', 'md'])
+    except:
+        t_bold = ''
 
-try: t_reset = cmds.get_output(['tput', 'sgr0'])
+try:
+    t_reset = cmds.get_output(['tput', 'sgr0'])
 except:
-    try: t_reset = cmds.get_output(['tput', 'me'])
-    except: t_reset = ''
+    try:
+        t_reset = cmds.get_output(['tput', 'me'])
+    except:
+        t_reset = ''
 
 t_colour = [''] * 16
 try:
@@ -88,7 +94,7 @@ phase_map = {
     'unpack':         'checkout.png',
     'patch':          'checkout.png',
     'configure':      'configure.png',
-    #'clean':          'clean.png',
+    # 'clean':          'clean.png',
     'build':          'build.png',
     'check':          'check.png',
     'install':        'install.png',
@@ -198,7 +204,7 @@ class TerminalBuildScript(buildscript.BuildScript):
                     raise FatalError(_('%(configuration_variable)s invalid key'
                                        ' %(key)s' % \
                                        {'configuration_variable' :
-                                            '\'print_command_pattern\'',
+                                        '\'print_command_pattern\'',
                                         'key' : e}))
 
         kws['stdin'] = subprocess.PIPE
@@ -230,6 +236,7 @@ class TerminalBuildScript(buildscript.BuildScript):
         output = []
         if hint in ('cvs', 'svn', 'hg-update.py'):
             conflicts = []
+
             def format_line(line, error_output, conflicts = conflicts, output = output):
                 if line.startswith('C '):
                     conflicts.append(line)
@@ -238,7 +245,8 @@ class TerminalBuildScript(buildscript.BuildScript):
                     output.append(line)
                     return
 
-                if line[-1] == '\n': line = line[:-1]
+                if line[-1] == '\n':
+                    line = line[:-1]
 
                 if line.startswith('C '):
                     print '%s%s%s' % (t_colour[12], line, t_reset)
@@ -256,7 +264,8 @@ class TerminalBuildScript(buildscript.BuildScript):
                     sys.stdout.write('%s  %s%s\n'
                                      % (t_colour[12], line, t_reset))
                 # make sure conflicts fail
-                if p.returncode == 0 and hint == 'cvs': p.returncode = 1
+                if p.returncode == 0 and hint == 'cvs':
+                    p.returncode = 1
         elif self.config.quiet_mode:
             def format_line(line, error_output, output = output):
                 output.append(line)
@@ -394,6 +403,7 @@ class TerminalBuildScript(buildscript.BuildScript):
                     val = raw_input(uencode(_('Type "yes" to confirm the action: ')))
                     val = udecode(val)
                     val = val.strip()
+
                     def normalize(s):
                         return unicodedata.normalize('NFKD', s).encode('ascii', 'ignore').lower()
                     if normalize(val) in ('yes', normalize(_('yes')), _('yes').lower()):
diff --git a/jhbuild/frontends/tinderbox.py b/jhbuild/frontends/tinderbox.py
index f268290d..071d5356 100644
--- a/jhbuild/frontends/tinderbox.py
+++ b/jhbuild/frontends/tinderbox.py
@@ -219,7 +219,7 @@ class TinderboxBuildScript(buildscript.BuildScript):
                 raise FatalError(_('%(configuration_variable)s invalid key'
                                    ' %(key)s' % \
                                    {'configuration_variable' :
-                                        '\'print_command_pattern\'',
+                                    '\'print_command_pattern\'',
                                     'key' : e}))
 
         kws['stdin'] = subprocess.PIPE
@@ -227,19 +227,21 @@ class TinderboxBuildScript(buildscript.BuildScript):
         kws['stderr'] = subprocess.PIPE
         if hint == 'cvs':
             def format_line(line, error_output, fp=self.modulefp):
-                if line[-1] == '\n': line = line[:-1]
+                if line[-1] == '\n':
+                    line = line[:-1]
                 if line.startswith('C '):
                     fp.write('<span class="conflict">%s</span>\n'
-                                        % escape(line))
+                             % escape(line))
                 else:
                     fp.write('%s\n' % escape(line))
             kws['stderr'] = subprocess.STDOUT
         else:
             def format_line(line, error_output, fp=self.modulefp):
-                if line[-1] == '\n': line = line[:-1]
+                if line[-1] == '\n':
+                    line = line[:-1]
                 if error_output:
                     fp.write('<span class="error">%s</span>\n'
-                                        % escape(line))
+                             % escape(line))
                 else:
                     fp.write('%s\n' % escape(line))
 
@@ -348,7 +350,7 @@ class TinderboxBuildScript(buildscript.BuildScript):
                     raise FatalError(_('%(configuration_variable)s invalid key'
                                        ' %(key)s' % \
                                        {'configuration_variable' :
-                                            '\'help_website\'',
+                                        '\'help_website\'',
                                         'key' : e}))
 
             self.indexfp.write('<td class="failure">failed%s</td>\n' %
@@ -386,7 +388,7 @@ class TinderboxBuildScript(buildscript.BuildScript):
         self.triedcheckout = None
 
         if (self.modulefp and self.config.help_website and
-            self.config.help_website[0] and self.config.help_website[1]):
+                self.config.help_website[0] and self.config.help_website[1]):
             try:
                 help_url = self.config.help_website[1] % \
                                {'module' : module.name}
@@ -403,7 +405,7 @@ class TinderboxBuildScript(buildscript.BuildScript):
                 raise FatalError(_('%(configuration_variable)s invalid key'
                                    ' %(key)s' % \
                                    {'configuration_variable' :
-                                        '\'help_website\'',
+                                    '\'help_website\'',
                                     'key' : e}))
         return 'fail'
 
diff --git a/jhbuild/main.py b/jhbuild/main.py
index dd722592..c266f99b 100644
--- a/jhbuild/main.py
+++ b/jhbuild/main.py
@@ -94,7 +94,7 @@ def main(args):
         localedir = None
     gettext.install('jhbuild', localedir=localedir, unicode=True)
 
-    if not 'JHBUILD_RUN_AS_ROOT' in os.environ and hasattr(os, 'getuid') and os.getuid() == 0:
+    if 'JHBUILD_RUN_AS_ROOT' not in os.environ and hasattr(os, 'getuid') and os.getuid() == 0:
         sys.stderr.write(_('You should not run jhbuild as root.\n').encode(_encoding, 'replace'))
         sys.exit(1)
 
@@ -139,9 +139,12 @@ def main(args):
         sys.stderr.write('jhbuild: %s\n' % exc.args[0].encode(_encoding, 'replace'))
         sys.exit(1)
 
-    if options.moduleset: config.moduleset = options.moduleset
-    if options.nointeract: config.interact = False
-    if options.exit_on_error: config.exit_on_error = True
+    if options.moduleset:
+        config.moduleset = options.moduleset
+    if options.nointeract:
+        config.interact = False
+    if options.exit_on_error:
+        config.exit_on_error = True
 
     if not args or args[0][0] == '-':
         command = 'build' # default to cvs update + compile
diff --git a/jhbuild/modtypes/__init__.py b/jhbuild/modtypes/__init__.py
index f33307a2..f8a8b473 100644
--- a/jhbuild/modtypes/__init__.py
+++ b/jhbuild/modtypes/__init__.py
@@ -45,19 +45,19 @@ def register_module_type(name, parse_func):
 def register_lazy_module_type(name, module):
     def parse_func(node, config, uri, repositories, default_repo):
         old_func = _module_types[name]
-        mod = __import__(module)
+        __import__(module)
         assert _module_types[name] != old_func, (
             'module did not register new parser_func for %s' % name)
         return _module_types[name](node, config, uri, repositories, default_repo)
     _module_types[name] = parse_func
 
 def parse_xml_node(node, config, uri, repositories, default_repo):
-    if not _module_types.has_key(node.nodeName):
+    if node.nodeName not in _module_types:
         try:
             __import__('jhbuild.modtypes.%s' % node.nodeName)
         except ImportError:
             pass
-    if not _module_types.has_key(node.nodeName):
+    if node.nodeName not in _module_types:
         raise FatalError(_('unknown module type %s') % node.nodeName)
 
     parser = _module_types[node.nodeName]
@@ -102,7 +102,8 @@ def get_dependencies(node):
                 lst.append((typ, name, altdeps))
 
     for childnode in node.childNodes:
-        if childnode.nodeType != childnode.ELEMENT_NODE: continue
+        if childnode.nodeType != childnode.ELEMENT_NODE:
+            continue
         if childnode.nodeName == 'dependencies':
             add_to_list(dependencies, childnode)
         elif childnode.nodeName == 'suggests':
@@ -125,7 +126,7 @@ def get_node_content(node):
 def find_first_child_node(node, name):
     for childnode in node.childNodes:
         if (childnode.nodeType == childnode.ELEMENT_NODE and
-            childnode.nodeName == name):
+                childnode.nodeName == name):
             return childnode
     return None
 
@@ -174,7 +175,7 @@ class Package:
     PHASE_START = 'start'
     PHASE_DONE  = 'done'
     def __init__(self, name, branch=None, dependencies = [], after = [],
-                  suggests = [], systemdependencies = [], pkg_config=None):
+                 suggests = [], systemdependencies = [], pkg_config=None):
         self.name = name
         self.branch = branch
         self.dependencies = dependencies
@@ -224,11 +225,11 @@ class Package:
             if os.path.isdir(subpath):
                 self._clean_la_files_in_dir(buildscript, subpath)
             elif name.endswith('.la'):
-                    try:
-                        logging.info(_('Deleting .la file: %r') % (subpath, ))
-                        os.unlink(subpath)
-                    except OSError:
-                        pass
+                try:
+                    logging.info(_('Deleting .la file: %r') % (subpath, ))
+                    os.unlink(subpath)
+                except OSError:
+                    pass
 
     def _clean_la_files(self, buildscript, installroot):
         """This method removes all .la files. See bug 654013."""
@@ -317,7 +318,6 @@ them into the prefix."""
         new_contents = fileutils.accumulate_dirtree_contents(destdir_prefix)
         errors = []
         if os.path.isdir(destdir_prefix):
-            destdir_install = True
             logging.info(_('Moving temporary DESTDIR %r into build prefix') % (destdir, ))
             num_copied = self._process_install_files(destdir, destdir_prefix,
                                                      buildscript.config.prefix,
@@ -335,7 +335,7 @@ them into the prefix."""
                 assert target.startswith(buildscript.config.prefix)
                 try:
                     os.rmdir(target)
-                except OSError as e:
+                except OSError:
                     pass
 
             remaining_files = os.listdir(destdir)
@@ -431,7 +431,7 @@ them into the prefix."""
         return hasattr(self, 'do_' + phase)
 
     def check_build_policy(self, buildscript):
-        if not buildscript.config.build_policy in ('updated', 'updated-deps'):
+        if buildscript.config.build_policy not in ('updated', 'updated-deps'):
             return
 
         # Always trigger a build for dirty branches if supported by the version
@@ -530,7 +530,7 @@ class NinjaModule(Package):
     def get_ninjaargs(self, buildscript):
         ninjaargs = ' %s %s' % (self.ninjaargs,
                                 self.config.module_ninjaargs.get(
-                                  self.name, self.config.ninjaargs))
+                                    self.name, self.config.ninjaargs))
         if not self.supports_parallel_build:
             ninjaargs = re.sub(r'-j\w*\d+', '', ninjaargs) + ' -j 1'
         return self.eval_args(ninjaargs).strip()
@@ -565,7 +565,7 @@ class MakeModule(Package):
     '''A base class for modules that use the command 'make' within the build
     process.'''
     def __init__(self, name, branch=None, makeargs='', makeinstallargs='',
-                  makefile='Makefile', needs_gmake=False):
+                 makefile='Makefile', needs_gmake=False):
         Package.__init__(self, name, branch=branch)
         self.makeargs = makeargs
         self.makeinstallargs = makeinstallargs
@@ -598,9 +598,9 @@ class MakeModule(Package):
             makeargs = self.get_makeargs(buildscript)
 
         cmd = '{pre}{make} {makeargs} {target}'.format(pre=pre,
-                                                        make=makecmd,
-                                                        makeargs=makeargs,
-                                                        target=target)
+                                                       make=makecmd,
+                                                       makeargs=makeargs,
+                                                       target=target)
         buildscript.execute(cmd, cwd = self.get_builddir(buildscript), extra_env = self.extra_env)
 
 class DownloadableModule:
diff --git a/jhbuild/modtypes/autotools.py b/jhbuild/modtypes/autotools.py
index d010d08a..92f14e57 100644
--- a/jhbuild/modtypes/autotools.py
+++ b/jhbuild/modtypes/autotools.py
@@ -83,7 +83,7 @@ class AutogenModule(MakeModule, DownloadableModule):
         return self.branch.srcdir
 
     def get_builddir(self, buildscript):
-        builddir = self.get_srcdir(buildscript);
+        builddir = self.get_srcdir(buildscript)
         if buildscript.config.buildroot and self.supports_non_srcdir_builds:
             d = buildscript.config.builddir_pattern % (
                 self.branch.checkoutdir or self.branch.get_module_basename())
@@ -96,7 +96,7 @@ class AutogenModule(MakeModule, DownloadableModule):
         try:
             other_stbuf = os.stat(other)
             potential_stbuf = os.stat(potential)
-        except OSError as e:
+        except OSError:
             return False
         return potential_stbuf.st_mtime > other_stbuf.st_mtime
 
@@ -151,7 +151,7 @@ class AutogenModule(MakeModule, DownloadableModule):
         # can safely assume it will be the same as {prefix} and substitute it
         # right now, so the printed command can be copy/pasted afterwards.
         # (GNOME #580272)
-        if not '--exec-prefix' in template:
+        if '--exec-prefix' not in template:
             cmd = cmd.replace('${exec_prefix}', vars['prefix'])
 
         self.configure_cmd = cmd
@@ -311,7 +311,7 @@ class AutogenModule(MakeModule, DownloadableModule):
 
     def do_install(self, buildscript):
         if self.uninstall_before_install:
-            packagedb =  buildscript.moduleset.packagedb
+            packagedb = buildscript.moduleset.packagedb
             if packagedb.check(self.name):
                 buildscript.set_action(_('Uninstalling old installed version'), self)
                 packagedb.uninstall(self.name)
diff --git a/jhbuild/modtypes/cmake.py b/jhbuild/modtypes/cmake.py
index 1df76bc9..222a9f4f 100644
--- a/jhbuild/modtypes/cmake.py
+++ b/jhbuild/modtypes/cmake.py
@@ -111,7 +111,6 @@ class CMakeModule(MakeModule, NinjaModule, DownloadableModule):
 
     def do_clean(self, buildscript):
         buildscript.set_action(_('Cleaning'), self)
-        builddir = self.get_builddir(buildscript)
         if self.use_ninja:
             self.ninja(buildscript, 'clean')
         else:
@@ -121,7 +120,6 @@ class CMakeModule(MakeModule, NinjaModule, DownloadableModule):
 
     def do_build(self, buildscript):
         buildscript.set_action(_('Building'), self)
-        builddir = self.get_builddir(buildscript)
         if self.use_ninja:
             self.ninja(buildscript)
         else:
@@ -143,7 +141,6 @@ class CMakeModule(MakeModule, NinjaModule, DownloadableModule):
 
     def do_install(self, buildscript):
         buildscript.set_action(_('Installing'), self)
-        builddir = self.get_builddir(buildscript)
         destdir = self.prepare_installroot(buildscript)
         if self.use_ninja:
             self.ninja(buildscript, 'install', env={'DESTDIR': destdir})
diff --git a/jhbuild/modtypes/meson.py b/jhbuild/modtypes/meson.py
index 59fedfbb..e4912f65 100644
--- a/jhbuild/modtypes/meson.py
+++ b/jhbuild/modtypes/meson.py
@@ -112,7 +112,6 @@ class MesonModule(NinjaModule, DownloadableModule):
         if buildscript.config.alwaysautogen:
             return False
 
-        srcdir = self.get_srcdir(buildscript)
         builddir = self.get_builddir(buildscript)
         meson_marker_path = os.path.join(builddir, 'meson-private', 'coredata.dat')
         if not os.path.exists(meson_marker_path):
diff --git a/jhbuild/modtypes/perl.py b/jhbuild/modtypes/perl.py
index bde229e4..0a6b8771 100644
--- a/jhbuild/modtypes/perl.py
+++ b/jhbuild/modtypes/perl.py
@@ -76,7 +76,7 @@ class PerlModule(Package, DownloadableModule):
 
     def xml_tag_and_attrs(self):
         return 'perl', [('id', 'name', None),
-                         ('makeargs', 'makeargs', '')]
+                        ('makeargs', 'makeargs', '')]
 
 
 def parse_perl(node, config, uri, repositories, default_repo):
diff --git a/jhbuild/modtypes/tarball.py b/jhbuild/modtypes/tarball.py
index 8097a94d..81e8e089 100644
--- a/jhbuild/modtypes/tarball.py
+++ b/jhbuild/modtypes/tarball.py
@@ -57,7 +57,8 @@ def parse_tarball(node, config, uri, repositories, default_repo):
         makefile = node.getAttribute('makefile')
 
     for childnode in node.childNodes:
-        if childnode.nodeType != childnode.ELEMENT_NODE: continue
+        if childnode.nodeType != childnode.ELEMENT_NODE:
+            continue
         if childnode.nodeName == 'source':
             source_url = childnode.getAttribute('href')
             if childnode.hasAttribute('size'):
@@ -73,8 +74,10 @@ def parse_tarball(node, config, uri, repositories, default_repo):
                 source_hash = childnode.getAttribute('hash')
         elif childnode.nodeName == 'patches':
             for patch in childnode.childNodes:
-                if patch.nodeType != patch.ELEMENT_NODE: continue
-                if patch.nodeName != 'patch': continue
+                if patch.nodeType != patch.ELEMENT_NODE:
+                    continue
+                if patch.nodeName != 'patch':
+                    continue
                 patchfile = patch.getAttribute('file')
                 if patch.hasAttribute('strip'):
                     patchstrip = int(patch.getAttribute('strip'))
diff --git a/jhbuild/modtypes/testmodule.py b/jhbuild/modtypes/testmodule.py
index da8f482a..605472cf 100644
--- a/jhbuild/modtypes/testmodule.py
+++ b/jhbuild/modtypes/testmodule.py
@@ -48,10 +48,10 @@ class TestModule(Package, DownloadableModule):
         self.test_type    = test_type
         self.tested_pkgs  = tested_pkgs
 
-        ### modify environ for tests to be working
-        if os.environ.has_key('LDTP_DEBUG'):
+        # modify environ for tests to be working
+        if 'LDTP_DEBUG' in os.environ:
             del os.environ['LDTP_DEBUG'] # get rid of verbose LDTP output
-        if not os.environ.has_key('GNOME_ACCESSIBILITY') or os.environ['GNOME_ACCESSIBILITY'] != 1:
+        if 'GNOME_ACCESSIBILITY' not in os.environ or os.environ['GNOME_ACCESSIBILITY'] != 1:
             os.environ['GNOME_ACCESSIBILITY'] = '1'
 
     def get_srcdir(self, buildscript):
@@ -241,8 +241,8 @@ class TestModule(Package, DownloadableModule):
         except OSError:
             return -1
         
-        time.sleep(2) #allow Xvfb to start
-        if xvfb.poll() != None:
+        time.sleep(2) # allow Xvfb to start
+        if xvfb.poll() is not None:
             return -1
         return xvfb.pid
 
@@ -257,14 +257,14 @@ class TestModule(Package, DownloadableModule):
         except OSError:
             return -1
         time.sleep(1)
-        if ldtp.poll() != None:
+        if ldtp.poll() is not None:
             return -1
         return ldtp.pid
     
     def do_ldtp_test(self, buildscript):
         src_dir = self.get_srcdir(buildscript)
         old_debug = os.getenv('LDTP_DEBUG')
-        if old_debug != None:
+        if old_debug is not None:
             del os.environ['LDTP_DEBUG']
 
         ldtp_pid = self._start_ldtp()
@@ -284,7 +284,7 @@ class TestModule(Package, DownloadableModule):
             raise BuildStateError('error %s during test' % e.returncode)
         os.kill(ldtp_pid, signal.SIGINT)
         
-        if old_debug != None:
+        if old_debug is not None:
             os.environ['LDTP_DEBUG'] = old_debug
         
         log_file = self.get_ldtp_log_file(os.path.join (src_dir,'run.xml'))
@@ -301,13 +301,11 @@ class TestModule(Package, DownloadableModule):
     def do_dogtail_test(self, buildscript):
         src_dir = self.get_srcdir(buildscript)
         test_cases = []
-        failed = False
         all_files = os.listdir(src_dir)
         for file in all_files:
             if file[-3:] == '.py':
                 test_cases.append(file)
 
-        status = ''
         if buildscript.config.noxvfb:
             extra_env = {}
         else:
diff --git a/jhbuild/modtypes/waf.py b/jhbuild/modtypes/waf.py
index 2d6eab34..9bd09b8b 100644
--- a/jhbuild/modtypes/waf.py
+++ b/jhbuild/modtypes/waf.py
@@ -126,7 +126,7 @@ class WafModule(Package, DownloadableModule):
         else:
             cmd = [self.waf_cmd, 'dist']
         buildscript.execute(cmd, cwd=self.get_builddir(buildscript),
-                                extra_env={'PYTHON': self.python_cmd})
+                            extra_env={'PYTHON': self.python_cmd})
     do_dist.depends = [PHASE_BUILD]
     do_dist.error_phases = [PHASE_FORCE_CHECKOUT, PHASE_CONFIGURE]
 
diff --git a/jhbuild/moduleset.py b/jhbuild/moduleset.py
index ded1885a..e8e2ab7b 100644
--- a/jhbuild/moduleset.py
+++ b/jhbuild/moduleset.py
@@ -87,7 +87,7 @@ class ModuleSet:
 
     def get_module(self, module_name, ignore_case = False):
         module_name = module_name.rstrip(os.sep)
-        if self.modules.has_key(module_name) or not ignore_case:
+        if module_name in self.modules or not ignore_case:
             return self.modules[module_name]
         module_name_lower = module_name.lower()
         for module in self.modules.keys():
@@ -108,8 +108,8 @@ class ModuleSet:
         return module_list
 
     def get_full_module_list(self, module_names='all', skip=[],
-                                include_suggests=True, include_afters=False,
-                                warn_about_circular_dependencies=True):
+                             include_suggests=True, include_afters=False,
+                             warn_about_circular_dependencies=True):
 
         def dep_resolve(node, resolved, seen, after):
             ''' Recursive depth-first search of the dependency tree. Creates
@@ -129,12 +129,12 @@ class ModuleSet:
                              if not after_module]
             for edge_name in edges:
                 edge = self.modules.get(edge_name)
-                if edge == None:
+                if edge is None:
                     if node not in [i[0] for i in resolved]:
                         self._warn(_('%(module)s has a dependency on unknown'
                                      ' "%(invalid)s" module') % \
-                                         {'module'  : node.name,
-                                          'invalid' : edge_name})
+                                   {'module'  : node.name,
+                                    'invalid' : edge_name})
                 elif edge_name not in skip and edge not in resolved_deps:
                     if edge in seen:
                         # circular dependency detected
@@ -168,7 +168,7 @@ class ModuleSet:
                 elif not after:
                     # a dependency exists for an after, flag to keep
                     for index, item in enumerate(resolved):
-                        if item[1] == True and item[0] == node:
+                        if item[1] is True and item[0] == node:
                             resolved[index] = (node, False)
 
         if module_names == 'all':
@@ -246,8 +246,7 @@ class ModuleSet:
 
         return_list = []
 
-        installed_pkgconfig = systeminstall.get_installed_pkgconfigs \
-                                (self.config)
+        installed_pkgconfig = systeminstall.get_installed_pkgconfigs(self.config)
 
         for module in modules:
             if isinstance(module, SystemModule):
@@ -319,15 +318,15 @@ class ModuleSet:
             
             for dep in self.modules[modname].dependencies:
                 fp.write('  "%s" -> "%s";\n' % (modname, dep))
-                if not inlist.has_key(dep):
+                if dep not in inlist:
                     modules.append(dep)
                 inlist[dep] = None
 
             if suggests:
                 for dep in self.modules[modname].after + self.modules[modname].suggests:
-                    if self.modules.has_key(dep):
+                    if dep in self.modules:
                         fp.write('  "%s" -> "%s" [style=dotted];\n' % (modname, dep))
-                        if not inlist.has_key(dep):
+                        if dep not in inlist:
                             modules.append(dep)
                         inlist[dep] = None
 
@@ -507,7 +506,7 @@ def _parse_module_set(config, uri):
                     if mirror.hasAttribute(attr):
                         kws[attr.replace('-','_')] = mirror.getAttribute(attr)
                 mirrors[mirror_type] = mirror_class(config, name, **kws)
-                #mirrors[mirror_type].moduleset_uri = uri
+                # mirrors[mirror_type].moduleset_uri = uri
             setattr(repositories[name], "mirrors", mirrors)
         if node.nodeName == 'cvsroot':
             cvsroot = node.getAttribute('root')
@@ -577,7 +576,7 @@ def warn_local_modulesets(config):
         # checkout was not done via git
         return
 
-    if type(config.moduleset) == type([]):
+    if isinstance(config.moduleset, list):
         modulesets = config.moduleset
     else:
         modulesets = [ config.moduleset ]
diff --git a/jhbuild/utils/cmds.py b/jhbuild/utils/cmds.py
index d9d9d7cf..d8dba51a 100644
--- a/jhbuild/utils/cmds.py
+++ b/jhbuild/utils/cmds.py
@@ -102,7 +102,6 @@ class Pipeline(subprocess.Popen):
         self.children = []
         close_stdin = False
         for index, cmd in enumerate(commands):
-            first_command = (index == 0)
             more_commands = index + 1 < len(commands)
 
             if more_commands:
@@ -235,7 +234,7 @@ def has_command(cmd):
 
         # also check for cmd.exe on Windows
         if sys.platform.startswith('win') and os.path.exists(prog + ".exe"):
-             return True
+            return True
     return False
 
 def compare_version(version, minver):
diff --git a/jhbuild/utils/fileutils.py b/jhbuild/utils/fileutils.py
index 46d17167..dc1128e6 100644
--- a/jhbuild/utils/fileutils.py
+++ b/jhbuild/utils/fileutils.py
@@ -71,8 +71,8 @@ Returns a list, where each item is a 2-tuple:
             results.append((path, True, ''))
         except OSError as e:
             if (isdir
-                and allow_nonempty_dirs
-                and len(os.listdir(path)) > 0):
+                    and allow_nonempty_dirs
+                    and len(os.listdir(path)) > 0):
                 results.append((path, False, None))
             else:
                 results.append((path, False, e.strerror))
diff --git a/jhbuild/utils/httpcache.py b/jhbuild/utils/httpcache.py
index b5c6b297..8904fd4d 100644
--- a/jhbuild/utils/httpcache.py
+++ b/jhbuild/utils/httpcache.py
@@ -96,8 +96,10 @@ class Cache:
             return # doesn't look like a cache
 
         for node in document.documentElement.childNodes:
-            if node.nodeType != node.ELEMENT_NODE: continue
-            if node.nodeName != 'entry': continue
+            if node.nodeType != node.ELEMENT_NODE:
+                continue
+            if node.nodeName != 'entry':
+                continue
             uri = node.getAttribute('uri')
             local = str(node.getAttribute('local'))
             if node.hasAttribute('modified'):
@@ -148,7 +150,8 @@ class Cache:
         # get the basename from the URI
         parts = urlparse.urlparse(uri, allow_fragments=False)
         base = parts[2].split('/')[-1]
-        if not base: base = 'index.html'
+        if not base:
+            base = 'index.html'
 
         is_unique = False
         while not is_unique:
@@ -238,5 +241,6 @@ def load(uri, nonetwork=False, age=None):
     '''Downloads the file associated with the URI, and returns a local
     file name for contents.'''
     global _cache
-    if not _cache: _cache = Cache()
+    if not _cache:
+        _cache = Cache()
     return _cache.load(uri, nonetwork=nonetwork, age=age)
diff --git a/jhbuild/utils/packagedb.py b/jhbuild/utils/packagedb.py
index 2131d6d4..54637633 100644
--- a/jhbuild/utils/packagedb.py
+++ b/jhbuild/utils/packagedb.py
@@ -68,7 +68,7 @@ class PackageEntry:
         if value is None:
             self._manifest = value
             return
-        self._manifest = [x.strip() for x in value if not '\n' in value]
+        self._manifest = [x.strip() for x in value if '\n' not in value]
         if len(self._manifest) != len(value):
             logging.error(_('package %s has files with embedded new lines') % self.package)
 
@@ -190,7 +190,8 @@ class PackageDB:
         if entry is None:
             return False
         if version is not None:
-            if entry.version != version: return False
+            if entry.version != version:
+                return False
         return True
 
     def installdate(self, package, version=None):
diff --git a/jhbuild/utils/subprocess_win32.py b/jhbuild/utils/subprocess_win32.py
index 4261d2d3..852097a7 100644
--- a/jhbuild/utils/subprocess_win32.py
+++ b/jhbuild/utils/subprocess_win32.py
@@ -70,8 +70,10 @@ def cmdline2list(cmd_string):
             if character=='\\':
                 escape = True
             elif character=='"':
-                if in_quotes: in_quotes = False
-                else:         in_quotes = True
+                if in_quotes:
+                    in_quotes = False
+                else:
+                    in_quotes = True
             elif (character==' ' or character==9) and not in_quotes:
                 result.append(current_element)
                 current_element = ""
diff --git a/jhbuild/utils/sxml.py b/jhbuild/utils/sxml.py
index 98df4cc4..3a8da072 100644
--- a/jhbuild/utils/sxml.py
+++ b/jhbuild/utils/sxml.py
@@ -72,6 +72,7 @@ class sxml:
         def _trans(k):
             table = {'klass': 'class'}
             return table.get(k, k)
+
         def tag(*targs, **kw):
             def render(args):
                 return ('<%s%s>%s</%s>'
diff --git a/jhbuild/utils/sysid.py b/jhbuild/utils/sysid.py
index eafdb98d..88b94152 100644
--- a/jhbuild/utils/sysid.py
+++ b/jhbuild/utils/sysid.py
@@ -137,7 +137,7 @@ def ensure_loaded():
 
             # this must be left here so that at least one will be found
             ('', ['x11'])
-        ]
+    ]
 
     for prefix, flags in conditions_sets:
         if sys.platform.startswith(prefix):
diff --git a/jhbuild/utils/systeminstall.py b/jhbuild/utils/systeminstall.py
index a3cf0988..8d81fde7 100644
--- a/jhbuild/utils/systeminstall.py
+++ b/jhbuild/utils/systeminstall.py
@@ -139,10 +139,10 @@ def systemdependencies_met(module_name, sysdeps, config):
         paths += extract_path_from_cflags(os.environ.get('CXXFLAGS', ''))
         # check include paths incorrectly configured in makeargs
         paths += extract_path_from_cflags(config.makeargs)
-        paths += extract_path_from_cflags(config.module_autogenargs.get
-                                             (module_name, ''))
-        paths += extract_path_from_cflags(config.module_makeargs.get
-                                             (module_name, ''))
+        paths += extract_path_from_cflags(config.module_autogenargs.get(
+            module_name, ''))
+        paths += extract_path_from_cflags(config.module_makeargs.get(
+            module_name, ''))
         paths += os.environ.get('C_INCLUDE_PATH', '').split(':')
         paths += os.environ.get('CPLUS_INCLUDE_PATH', '').split(':')
         paths = list(set(paths)) # remove duplicates
@@ -287,7 +287,6 @@ class PKSystemInstall(SystemInstall):
             self._pkdbus = dbus.Interface(self._sysbus.get_object('org.freedesktop.PackageKit',
                                                                   '/org/freedesktop/PackageKit'),
                                           'org.freedesktop.PackageKit')
-            properties = dbus.Interface(self._pkdbus, 'org.freedesktop.DBus.Properties')
         txn_path = self._pkdbus.CreateTransaction()
         txn = self._sysbus.get_object('org.freedesktop.PackageKit', txn_path)
         txn_tx = self._dbus.Interface(txn, 'org.freedesktop.PackageKit.Transaction')
@@ -413,7 +412,7 @@ class AptSystemInstall(SystemInstall):
         SystemInstall.__init__(self)
 
     def _apt_file_result(self, regexp):
-        if regexp is None or regexp is "":
+        if regexp is None or regexp == "":
             raise RuntimeError("regexp mustn't be None or empty")
         apt_file_result = subprocess.check_output(["apt-file", "search", "--regexp", regexp])
         ret_value = []
@@ -494,7 +493,7 @@ class AptSystemInstall(SystemInstall):
         apt_file_result = self._apt_file_result(c_includes_regexp)
         for modname, filename in c_includes:
             # Try multiarch first, so we print the non-multiarch location on failure.
-            if (multiarch == None or
+            if (multiarch is None or
                     not self._name_match_exact('/usr/include/%s/%s' % (multiarch, filename), 
apt_file_result, native_packages)):
                 if not self._name_match_exact('/usr/include/%s' % filename, apt_file_result, 
native_packages):
                     logging.info(_('No native package found for %(id)s '
diff --git a/jhbuild/utils/trayicon.py b/jhbuild/utils/trayicon.py
index 16c6fba5..cf52a540 100644
--- a/jhbuild/utils/trayicon.py
+++ b/jhbuild/utils/trayicon.py
@@ -91,11 +91,12 @@ class TrayIcon:
         return status
 
     def _send_cmd(self, cmd):
-        if not self.proc: return
+        if not self.proc:
+            return
         try:
             self.proc.stdin.write(cmd)
             self.proc.stdin.flush()
-        except (IOError, OSError) as err:
+        except (IOError, OSError):
             self.close()
     def set_icon(self, icon):
         self._send_cmd('icon: %s\n' % icon)
diff --git a/jhbuild/utils/trigger.py b/jhbuild/utils/trigger.py
index dbc74ebb..c720383d 100644
--- a/jhbuild/utils/trigger.py
+++ b/jhbuild/utils/trigger.py
@@ -57,20 +57,20 @@ class Trigger(object):
             raise ValueError(_("No keys specified in trigger script %r") % (filepath, ))
         
     def matches(self, files_list):
-       """@files_list should be a list of absolute file paths.  Return True if this trigger script
-should be run."""
-       if self._executable is not None:
-           if not cmds.has_command(self._executable):
-               return False
-       for path in files_list:
-           for r in self._rematches:
-               match = r.search(path)
-               if match:
-                   return True
-           for literal in self._literal_matches:
-               if path.find(literal) >= 0:
-                   return True
-       return False
+        """@files_list should be a list of absolute file paths.  Return True if this trigger script
+        should be run."""
+        if self._executable is not None:
+            if not cmds.has_command(self._executable):
+                return False
+        for path in files_list:
+            for r in self._rematches:
+                match = r.search(path)
+                if match:
+                    return True
+            for literal in self._literal_matches:
+                if path.find(literal) >= 0:
+                    return True
+        return False
 
     def command(self):
         """Returns the command required to execute the trigger script."""
diff --git a/jhbuild/versioncontrol/__init__.py b/jhbuild/versioncontrol/__init__.py
index b6e80fb3..5b10f7dd 100644
--- a/jhbuild/versioncontrol/__init__.py
+++ b/jhbuild/versioncontrol/__init__.py
@@ -172,14 +172,14 @@ class Branch:
         raise NotImplementedError
 
     def _copy(self, buildscript, copydir):
-         module = self.module
-         if self.checkoutdir:
-             module = self.checkoutdir
-         fromdir = os.path.join(copydir, os.path.basename(module))
-         todir = os.path.join(self.config.checkoutroot, os.path.basename(module))
-         if os.path.exists(todir):
-             self._wipedir(buildscript, self.srcdir)
-         buildscript.execute(['cp', '-R', fromdir, todir])
+        module = self.module
+        if self.checkoutdir:
+            module = self.checkoutdir
+        fromdir = os.path.join(copydir, os.path.basename(module))
+        todir = os.path.join(self.config.checkoutroot, os.path.basename(module))
+        if os.path.exists(todir):
+            self._wipedir(buildscript, self.srcdir)
+        buildscript.execute(['cp', '-R', fromdir, todir])
 
     def to_sxml(self):
         """Return an sxml representation of this checkout."""
diff --git a/jhbuild/versioncontrol/bzr.py b/jhbuild/versioncontrol/bzr.py
index a13916bc..ea19919a 100644
--- a/jhbuild/versioncontrol/bzr.py
+++ b/jhbuild/versioncontrol/bzr.py
@@ -72,8 +72,8 @@ class BzrRepository(Repository):
             module_href = self.config.branches[name]
             if not module_href:
                 raise FatalError(_('branch for %(name)s has wrong override, check your %(filename)s') % \
-                                   {'name'     : name,
-                                    'filename' : self.config.filename})
+                                 {'name'     : name,
+                                  'filename' : self.config.filename})
 
         if module is None:
             module = name
diff --git a/jhbuild/versioncontrol/cvs.py b/jhbuild/versioncontrol/cvs.py
index f8bab011..28fa2536 100644
--- a/jhbuild/versioncontrol/cvs.py
+++ b/jhbuild/versioncontrol/cvs.py
@@ -20,8 +20,7 @@
 __all__ = [
     'CVSRepository',
     'login',
-    'get_sticky_tag',
-    ]
+]
 __metaclass__ = type
 
 import sys
@@ -66,14 +65,16 @@ def descramble(password):
     return ''.join([chr(_shifts[ord(ch)]) for ch in password[1:]])
 
 def _canonicalise_cvsroot(cvsroot):
-    if not cvsroot.startswith(':pserver:'): return cvsroot
+    if not cvsroot.startswith(':pserver:'):
+        return cvsroot
     parts = cvsroot.split(':')
     if parts[3].startswith('/'):
         parts[3] = '2401' + parts[3]
     return ':'.join(parts)
 
 def login(cvsroot, password=None):
-    if not cvsroot.startswith(':pserver:'): return
+    if not cvsroot.startswith(':pserver:'):
+        return
     cvsroot = _canonicalise_cvsroot(cvsroot)
     cvspass = os.path.join(os.environ['HOME'], '.cvspass')
 
@@ -97,7 +98,7 @@ def login(cvsroot, password=None):
                 break
     except IOError:
         pass
-     # if we have a password, just write it directly to the .cvspass file
+    # if we have a password, just write it directly to the .cvspass file
     if password is not None:
         fp = open(cvspass, 'a')
         fp.write('/1 %s %s\n' % (cvsroot, scramble(password)))
diff --git a/jhbuild/versioncontrol/darcs.py b/jhbuild/versioncontrol/darcs.py
index 48758a9f..bc2cf88f 100644
--- a/jhbuild/versioncontrol/darcs.py
+++ b/jhbuild/versioncontrol/darcs.py
@@ -53,8 +53,8 @@ class DarcsRepository(Repository):
             module = self.config.branches[name]
             if not module:
                 raise FatalError(_('branch for %(name)s has wrong override, check your %(filename)s') % \
-                                   {'name'     : name,
-                                    'filename' : self.config.filename})
+                                 {'name'     : name,
+                                  'filename' : self.config.filename})
         else:
             if module is None:
                 module = name
@@ -101,7 +101,7 @@ class DarcsBranch(Branch):
             path = os.path.join(self.srcdir, filename)
             try:
                 stat = os.stat(path)
-            except OSError as e:
+            except OSError:
                 continue
             os.chmod(path, stat.st_mode | 0111)
 
diff --git a/jhbuild/versioncontrol/fossil.py b/jhbuild/versioncontrol/fossil.py
index cda89432..dd402334 100644
--- a/jhbuild/versioncontrol/fossil.py
+++ b/jhbuild/versioncontrol/fossil.py
@@ -47,8 +47,8 @@ class FossilRepository(Repository):
             module = self.config.branches[name]
             if not module:
                 raise FatalError(_('branch for %(name)s has wrong override, check your %(filename)s') % \
-                                   {'name'     : name,
-                                    'filename' : self.config.filename})
+                                 {'name'     : name,
+                                  'filename' : self.config.filename})
         else:
             if module is None:
                 module = name
diff --git a/jhbuild/versioncontrol/git.py b/jhbuild/versioncontrol/git.py
index 5e17f79a..24d8861c 100644
--- a/jhbuild/versioncontrol/git.py
+++ b/jhbuild/versioncontrol/git.py
@@ -286,7 +286,7 @@ class GitBranch(Branch):
 
     def rebase_current_branch(self, buildscript):
         """Pull the current branch if it is tracking a remote branch."""
-        branch = self.get_current_branch();
+        branch = self.get_current_branch()
         if not self.is_tracking_a_remote_branch(branch):
             return
 
@@ -340,18 +340,18 @@ class GitBranch(Branch):
 
     def exists(self):
         try:
-            refs = get_output(['git', 'ls-remote', self.module],
-                    extra_env=get_git_extra_env())
+            get_output(['git', 'ls-remote', self.module],
+                       extra_env=get_git_extra_env())
         except:
             return False
 
-        #FIXME: Parse output from ls-remote to work out if tag/branch is present
+        # FIXME: Parse output from ls-remote to work out if tag/branch is present
 
         return True
 
     def _get_commit_from_date(self):
         cmd = ['git', 'log', '--max-count=1', '--first-parent',
-                '--until=%s' % self.config.sticky_date, 'master']
+               '--until=%s' % self.config.sticky_date, 'master']
         cmd_desc = ' '.join(cmd)
         proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                                 cwd=self.get_checkoutdir(),
@@ -553,7 +553,7 @@ class GitSvnBranch(GitBranch):
                     if not comment_line.search(line):
                         ext += ' ' + line
 
-                match = re.compile("^(\.) (.+)").search(". " + ext)
+                match = re.compile("^(\\.) (.+)").search(". " + ext)
             except OSError:
                 raise FatalError(_("External handling failed\n If you are running git version < 1.5.6 it is 
recommended you update.\n"))
 
diff --git a/jhbuild/versioncontrol/hg.py b/jhbuild/versioncontrol/hg.py
index b84e7adb..cef7d7a3 100644
--- a/jhbuild/versioncontrol/hg.py
+++ b/jhbuild/versioncontrol/hg.py
@@ -51,8 +51,8 @@ class HgRepository(Repository):
             module = self.config.branches[name]
             if not module:
                 raise FatalError(_('branch for %(name)s has wrong override, check your %(filename)s') % \
-                                   {'name'     : name,
-                                    'filename' : self.config.filename})
+                                 {'name'     : name,
+                                  'filename' : self.config.filename})
         else:
             if module is None:
                 module = name
diff --git a/jhbuild/versioncontrol/mtn.py b/jhbuild/versioncontrol/mtn.py
index 9126bfa9..5f9becb2 100644
--- a/jhbuild/versioncontrol/mtn.py
+++ b/jhbuild/versioncontrol/mtn.py
@@ -50,8 +50,8 @@ class MonotoneRepository(Repository):
             module = self.config.branches[module]
             if not module:
                 raise FatalError(_('branch for %(name)s has wrong override, check your %(filename)s') % \
-                                   {'name'     : name,
-                                    'filename' : self.config.filename})
+                                 {'name'     : name,
+                                  'filename' : self.config.filename})
 
         if not branch:
             branch = self.defbranch
diff --git a/jhbuild/versioncontrol/svn.py b/jhbuild/versioncontrol/svn.py
index 890a67ff..a656f98c 100644
--- a/jhbuild/versioncontrol/svn.py
+++ b/jhbuild/versioncontrol/svn.py
@@ -65,7 +65,8 @@ def get_info(filename):
         ['svn', 'info', filename], extra_env=get_svn_extra_env())
     ret = {}
     for line in output.splitlines():
-        if ':' not in line: continue
+        if ':' not in line:
+            continue
         key, value = line.split(':', 1)
         ret[key.lower().strip()] = value.strip()
     return ret
@@ -76,7 +77,8 @@ def get_subdirs(url):
         ['svn', 'ls', '-R', url], extra_env=get_svn_extra_env())
     ret = []
     for line in output.splitlines():
-        if not line[-1] == '/': continue
+        if not line[-1] == '/':
+            continue
         ret.append (line)
     return ret
 
@@ -85,7 +87,8 @@ def get_externals(url):
             extra_env=get_svn_extra_env())
     ret = {}
     for line in output.splitlines():
-        if ' ' not in line: continue
+        if ' ' not in line:
+            continue
         key, value = line.split(' ')
         ret[key.strip()] = value
     return ret
@@ -344,9 +347,9 @@ class SubversionBranch(Branch):
 
     def to_sxml(self):
         return (call_with_info(lambda rev:
-                                   [sxml.branch(repo=self.repository.name,
-                                                module=self.module,
-                                                revision=rev)],
+                    [sxml.branch(repo=self.repository.name,
+                                 module=self.module,
+                                 revision=rev)],
                                self.srcdir, 'last changed rev')
                 or [sxml.branch(repo=self.repository.name,
                                 module=self.module)])
diff --git a/jhbuild/versioncontrol/tarball.py b/jhbuild/versioncontrol/tarball.py
index 363669fa..9e3720fb 100644
--- a/jhbuild/versioncontrol/tarball.py
+++ b/jhbuild/versioncontrol/tarball.py
@@ -66,8 +66,8 @@ class TarballRepository(Repository):
             module = self.config.branches[name]
             if not module:
                 raise FatalError(_('branch for %(name)s has wrong override, check your %(filename)s') % \
-                                   {'name'     : name,
-                                    'filename' : self.config.filename})
+                                 {'name'     : name,
+                                  'filename' : self.config.filename})
         else:
             if module is None:
                 module = name
@@ -94,7 +94,8 @@ class TarballRepository(Repository):
             raise FatalError(_('branch for %s is not correct, check the moduleset file.') % name)
         # patches represented as children of the branch node
         for childnode in branchnode.childNodes:
-            if childnode.nodeType != childnode.ELEMENT_NODE: continue
+            if childnode.nodeType != childnode.ELEMENT_NODE:
+                continue
             if childnode.nodeName == 'patch':
                 patchfile = childnode.getAttribute('file')
                 if childnode.hasAttribute('strip'):
@@ -238,7 +239,7 @@ class TarballBranch(Branch):
             self._check_tarball()
         except BuildStateError:
             # don't have the tarball, try downloading it and check again
-            res = self._download_tarball(buildscript, localfile)
+            self._download_tarball(buildscript, localfile)
             self._check_tarball()
 
         # now to unpack it
diff --git a/scripts/hg-update.py b/scripts/hg-update.py
index 2ba03e90..f414495f 100755
--- a/scripts/hg-update.py
+++ b/scripts/hg-update.py
@@ -58,7 +58,7 @@ def undo_update(parent):
     print 'Update failed, updating to parent revision'
     env = dict(os.environ)
     env['HGMERGE'] = 'false'
-    hg = call(['hg', 'update', '--noninteractive', '-q', parent], env=env)
+    call(['hg', 'update', '--noninteractive', '-q', parent], env=env)
 
 def pull_and_update():
     parent = get_parent()
diff --git a/scripts/mk-tarball-moduleset.py b/scripts/mk-tarball-moduleset.py
index f50f3534..99df7325 100755
--- a/scripts/mk-tarball-moduleset.py
+++ b/scripts/mk-tarball-moduleset.py
@@ -28,7 +28,7 @@ def read_deps(filename):
     line = fp.readline()
     while line:
         pkg, dep_pkgs = line.split(':', 1)
-        assert not deps_dict.has_key(pkg), '%s repeated' % pkg
+        assert pkg not in deps_dict, '%s repeated' % pkg
         dep_pkgs = [ dep.strip() for dep in dep_pkgs.split() ]
         deps.append((pkg, dep_pkgs))
         deps_dict[pkg] = dep_pkgs
@@ -36,7 +36,7 @@ def read_deps(filename):
     # verify that all dependencies are listed
     for pkg in deps_dict.keys():
         for dep in deps_dict[pkg]:
-            assert deps_dict.has_key(dep), 'dependency %s not found' % dep
+            assert dep in deps_dict, 'dependency %s not found' % dep
     return deps
 
 class SourceRepo:
@@ -86,7 +86,6 @@ class SourceRepo:
             source_node.setAttribute('href',
                                      urlparse.urljoin(self.uribase, filename))
             info = os.stat(os.path.join(self.sourcedir, filename))
-            size = info[stat.ST_SIZE]
             source_node.setAttribute('size', str(info[stat.ST_SIZE]))
 
             sum = md5.new()
diff --git a/tests/tests.py b/tests/tests.py
index 1745db14..d7332674 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -52,6 +52,8 @@ import jhbuild.frontends.terminal
 import jhbuild.moduleset
 import jhbuild.utils.cmds
 import jhbuild.versioncontrol.tarball
+from jhbuild.main import _encoding
+
 
 def uencode(s):
     if type(s) is unicode:
@@ -151,9 +153,9 @@ class ModuleOrderingTestCase(JhbuildConfigTestCase):
 
     def get_module_list(self, seed, skip=[], tags=[], include_suggests=True,
                         include_afters=False):
-        return [x.name for x in self.moduleset.get_module_list \
-                                    (seed, skip, tags, include_suggests,
-                                     include_afters)]
+        return [x.name for x in self.moduleset.get_module_list(
+                    seed, skip, tags, include_suggests,
+                    include_afters)]
 
     def test_standalone_one(self):
         '''A standalone module'''
@@ -273,6 +275,7 @@ class ModuleOrderingTestCase(JhbuildConfigTestCase):
         '''deps ommitted because satisfied by system dependencies'''
         class TestBranch(jhbuild.versioncontrol.tarball.TarballBranch):
             version = None
+
             def __init__(self):
                 pass
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]