From 0032ccbd60f202ec76d9b738cddc8bdbf9f54133 Mon Sep 17 00:00:00 2001 From: Richard Maw Date: Tue, 31 Jul 2012 12:52:12 +0000 Subject: python scripts: pep8ize codebase This was done with the aid of the pep8 script, available by running `easy_install pep8`. It may be worth making this part of ./check, but that will require putting pep8 into the development tools stratum. This should be easy, given pep8 has no external dependencies. --- morphlib/buildsystem.py | 67 ++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 34 deletions(-) (limited to 'morphlib/buildsystem.py') diff --git a/morphlib/buildsystem.py b/morphlib/buildsystem.py index c9f04054..0efd8e73 100644 --- a/morphlib/buildsystem.py +++ b/morphlib/buildsystem.py @@ -1,14 +1,14 @@ # Copyright (C) 2012 Codethink Limited -# +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. @@ -20,30 +20,30 @@ import os class BuildSystem(object): '''An abstraction of an upstream build system. - + Some build systems are well known: autotools, for example. Others are purely manual: there's a set of commands to run that are specific for that project, and (almost) no other project uses them. The Linux kernel would be an example of that. - + This class provides an abstraction for these, including a method to autodetect well known build systems. - + ''' - + def __init__(self): self.configure_commands = [] self.build_commands = [] self.test_commands = [] self.install_commands = [] - + def __getitem__(self, key): key = '_'.join(key.split('-')) return getattr(self, key) - + def get_morphology_text(self, name): '''Return the text of an autodetected chunk morphology.''' - + return ''' { "name": "%(name)s", @@ -54,23 +54,23 @@ class BuildSystem(object): 'name': name, 'bs': self.name, } - + def used_by_project(self, exists): '''Does a project use this build system? - + ``exists`` is a function that returns a boolean telling if a filename, relative to the project source directory, exists or not. - + ''' - raise NotImplementedError() # pragma: no cover - + raise NotImplementedError() # pragma: no cover + class ManualBuildSystem(BuildSystem): '''A manual build system where the morphology must specify all commands.''' name = 'manual' - + def used_by_project(self, exists): return False @@ -80,7 +80,7 @@ class DummyBuildSystem(BuildSystem): '''A dummy build system, useful for debugging morphologies.''' name = 'dummy' - + def __init__(self): self.configure_commands = ['echo dummy configure'] self.build_commands = ['echo dummy build'] @@ -96,7 +96,7 @@ class AutotoolsBuildSystem(BuildSystem): '''The automake/autoconf/libtool holy trinity.''' name = 'autotools' - + def __init__(self): self.configure_commands = [ 'export NOCONFIGURE=1; ' + @@ -121,7 +121,7 @@ class AutotoolsBuildSystem(BuildSystem): 'configure.in', 'configure.in.in', ] - + return any(exists(x) for x in indicators) @@ -130,7 +130,7 @@ class PythonDistutilsBuildSystem(BuildSystem): '''The Python distutils build systems.''' name = 'python-distutils' - + def __init__(self): self.configure_commands = [ ] @@ -147,7 +147,7 @@ class PythonDistutilsBuildSystem(BuildSystem): indicators = [ 'setup.py', ] - + return any(exists(x) for x in indicators) @@ -159,12 +159,12 @@ class CPANBuildSystem(BuildSystem): def __init__(self): self.configure_commands = [ - 'perl Makefile.PL INSTALLDIRS=perl '\ - 'INSTALLARCHLIB="$PREFIX/lib/perl" '\ - 'INSTALLPRIVLIB="$PREFIX/lib/perl" '\ - 'INSTALLBIN="$PREFIX/bin" '\ - 'INSTALLSCRIPT="$PREFIX/bin" '\ - 'INSTALLMAN1DIR="$PREFIX/share/man/man1" '\ + 'perl Makefile.PL INSTALLDIRS=perl ' + 'INSTALLARCHLIB="$PREFIX/lib/perl" ' + 'INSTALLPRIVLIB="$PREFIX/lib/perl" ' + 'INSTALLBIN="$PREFIX/bin" ' + 'INSTALLSCRIPT="$PREFIX/bin" ' + 'INSTALLMAN1DIR="$PREFIX/share/man/man1" ' 'INSTALLMAN3DIR="$PREFIX/share/man/man3"', ] self.build_commands = [ @@ -195,12 +195,12 @@ build_systems = [ def detect_build_system(exists): '''Automatically detect the build system, if possible. - + If the build system cannot be detected automatically, return None. For ``exists`` see the ``BuildSystem.exists`` method. - + ''' - + for bs in build_systems: if bs.used_by_project(exists): return bs @@ -209,13 +209,12 @@ def detect_build_system(exists): def lookup_build_system(name): '''Return build system that corresponds to the name. - + If the name does not match any build system, raise ``KeyError``. - + ''' - + for bs in build_systems: if bs.name == name: return bs raise KeyError('Unknown build system: %s' % name) - -- cgit v1.2.1