Author: johannes Date: 2007-11-22 04:16:02 -0600 (Thu, 22 Nov 2007) New Revision: 9828
Modified: trunk/gnue-common/src/setup/GSetup.py Log: Start changing for PEP8 and pylint Modified: trunk/gnue-common/src/setup/GSetup.py =================================================================== --- trunk/gnue-common/src/setup/GSetup.py 2007-11-22 10:00:10 UTC (rev 9827) +++ trunk/gnue-common/src/setup/GSetup.py 2007-11-22 10:16:02 UTC (rev 9828) @@ -20,18 +20,23 @@ # Copyright 2001-2007 Free Software Foundation # # $Id: GSetup.py,v 1.4 2003/10/06 18:33:16 reinhard Exp $ +""" +""" import sys -import string import time import os + from distutils import log from distutils.core import setup from distutils.filelist import FileList + import distutils.command.sdist import distutils.command.build import distutils.command.install + import gnue.paths + from gnue.common.utils import version from gnue.common.setup import ChangeLog @@ -53,9 +58,9 @@ installed, you may need to run: python2.3 setup.py - """ % string.split(sys.version)[0] + """ % sys.version.split()[0] print "-" * 70 - sys.exit (1) + sys.exit(1) # ----------------------------------------------------------------------------- # Global GSetup instance @@ -67,22 +72,22 @@ # sdist: build files to be distributed first # ============================================================================= -class sdist (distutils.command.sdist.sdist): +class sdist(distutils.command.sdist.sdist): - def run (self): + def run(self): global _setup - _setup.do_build_files ('sdist') - distutils.command.sdist.sdist.run (self) + _setup.do_build_files('sdist') + distutils.command.sdist.sdist.run(self) def prune_file_list(self): distutils.command.sdist.sdist.prune_file_list(self) self.filelist.exclude_pattern('*.dist_template', anchor=0) - def make_release_tree (self, base_dir, files): - distutils.command.sdist.sdist.make_release_tree (self, base_dir, files) + def make_release_tree(self, base_dir, files): + distutils.command.sdist.sdist.make_release_tree(self, base_dir, files) self.process_templates(base_dir) - _setup.do_build_svnrev (os.path.join(base_dir, 'src', 'svnrev.py')) + _setup.do_build_svnrev(os.path.join(base_dir, 'src', 'svnrev.py')) def process_templates(self, target): @@ -140,23 +145,23 @@ # build: if done from SVN, build files to be installed first # ============================================================================= -class build (distutils.command.build.build): +class build(distutils.command.build.build): - def run (self): + def run(self): global _setup - if not os.path.isfile ("PKG-INFO"): # downloaded from SVN? - _setup.do_build_files ('build') - distutils.command.build.build.run (self) - if not os.path.isfile ("PKG-INFO"): - _setup.do_build_svnrev (os.path.join(self.build_lib, 'gnue', + if not os.path.isfile("PKG-INFO"): # downloaded from SVN? + _setup.do_build_files('build') + distutils.command.build.build.run(self) + if not os.path.isfile("PKG-INFO"): + _setup.do_build_svnrev(os.path.join(self.build_lib, 'gnue', _setup.package[5:].lower(), 'svnrev.py')) # ============================================================================= # install: Some user_options are no longer allowed # ============================================================================= -class install (distutils.command.install.install): +class install(distutils.command.install.install): # Commented out because sometimes, to create packages, we want to install # other tools in a different target directory than common is installed @@ -171,8 +176,8 @@ i = 0 for option in user_options: i = i + 1 - if option [0] == "install-data=": - user_options.insert (i, ("install-config=", None, + if option[0] == "install-data=": + user_options.insert(i, ("install-config=", None, "installation directory for configuration files")) break @@ -180,15 +185,15 @@ # Initalize options # ------------------------------------------------------------------------- - def initialize_options (self): - distutils.command.install.install.initialize_options (self) + def initialize_options(self): + distutils.command.install.install.initialize_options(self) self.install_config = None # ------------------------------------------------------------------------- # Finalize options - set all install targets # ------------------------------------------------------------------------- - def finalize_options (self): + def finalize_options(self): if self.install_lib is None: self.install_lib = gnue.paths.lib @@ -199,40 +204,40 @@ if self.install_config is None: self.install_config = gnue.paths.config - distutils.command.install.install.finalize_options (self) + distutils.command.install.install.finalize_options(self) # ------------------------------------------------------------------------- # install.run: generate and install path dependent files afterwards # ------------------------------------------------------------------------- - def run (self): + def run(self): global _setup - _setup.check_dependencies () + _setup.check_dependencies() self.__outputs = [] # install translations - if os.path.isdir ('po'): + if os.path.isdir('po'): # copy files - for f in os.listdir ('po'): - if f [-4:] == '.gmo': - src = os.path.join ('po', f) - dst = os.path.join (self.install_data, 'share', 'locale', f + for f in os.listdir('po'): + if f[-4:] == '.gmo': + src = os.path.join('po', f) + dst = os.path.join(self.install_data, 'share', 'locale', f [:-4], 'LC_MESSAGES') - self.mkpath (dst) - dst = os.path.join (dst, _setup.package + '.mo') - self.copy_file (src, dst) - self.__outputs.append (dst) + self.mkpath(dst) + dst = os.path.join(dst, _setup.package + '.mo') + self.copy_file(src, dst) + self.__outputs.append(dst) - distutils.command.install.install.run (self) + distutils.command.install.install.run(self) # ------------------------------------------------------------------------- # install.get_outputs: list all installed files # ------------------------------------------------------------------------- - def get_outputs (self): - return distutils.command.install.install.get_outputs (self) \ + def get_outputs(self): + return distutils.command.install.install.get_outputs(self) \ + self.__outputs # ============================================================================= @@ -245,62 +250,62 @@ # Abstract methods: setup.py scripts generally override these # ------------------------------------------------------------------------- - def set_params (self, params): + def set_params(self, params): pass - def build_files (self, action): + def build_files(self, action): pass - def check_dependencies (self): + def check_dependencies(self): pass # ------------------------------------------------------------------------- # Build files if called from SVN # ------------------------------------------------------------------------- - def do_build_files (self, action): + def do_build_files(self, action): if os.name == 'posix': # First check if we have everything installed we need to build the # distribution - if os.path.isdir ('po'): + if os.path.isdir('po'): # xgettext - if os.system ("pygettext --version > /dev/null") != 0: + if os.system("pygettext --version > /dev/null") != 0: log.fatal("Could not find 'pygettext'. Strange.") log.fatal("It should be included in the Python " \ "distribution.") - sys.exit (1) + sys.exit(1) # msgmerge - if os.system ("msgmerge --version > /dev/null") != 0: + if os.system("msgmerge --version > /dev/null") != 0: log.fatal("Could not find 'msgmerge'. Please install " \ "Gettext.") - sys.exit (1) + sys.exit(1) # msgfmt - if os.system ("msgfmt --version > /dev/null") != 0: + if os.system("msgfmt --version > /dev/null") != 0: log.fatal("Could not find 'msgfmt'. Please install " \ "Gettext.") - sys.exit (1) + sys.exit(1) # ----------------------------------------------------------------- if action == 'sdist': # build ChangeLog file log.info("building ChangeLog") - ChangeLog.build () + ChangeLog.build() # build translations - if os.path.isdir ('po'): + if os.path.isdir('po'): log.info("building translations") - if os.system ("cd po && make gmo") != 0: - sys.exit (1) + if os.system("cd po && make gmo") != 0: + sys.exit(1) else: # on non posix systems just run msgfmt on existing .po files - if os.path.isdir ('po'): + if os.path.isdir('po'): # msgfmt.py argv0_path = os.path.dirname(os.path.abspath(sys.executable)) sys.path.append(argv0_path + "\\tools\\i18n") @@ -323,19 +328,19 @@ log.info("building translations") for f in os.listdir('po'): if f[-3:] == '.po': - msgfmt.make ('po/'+f, 'po/'+f[:-3]+'.gmo') + msgfmt.make('po/'+f, 'po/'+f[:-3]+'.gmo') msgfmt.MESSAGES = {} # --------------------------------------------------------------------- # do package specific stuff - self.build_files (action) + self.build_files(action) # ------------------------------------------------------------------------- # Build files if called from SVN # ------------------------------------------------------------------------- - def do_build_svnrev (self, filename): + def do_build_svnrev(self, filename): log.info("building svnrev.py") output = open(filename, 'w') @@ -346,26 +351,26 @@ # Helper methods for descendants # ------------------------------------------------------------------------- - def allfiles (self, directory): - directory = os.path.normpath (directory) + def allfiles(self, directory): + directory = os.path.normpath(directory) exclude = [".svn", "CVS", "README.cvs", ".cvsignore", "Makefile"] - return [directory + "/" + file for file in os.listdir (directory) \ + return [directory + "/" + file for file in os.listdir(directory) \ if not file in exclude and - not os.path.isdir (os.path.join (directory, file))] + not os.path.isdir(os.path.join(directory, file))] # ------------------------------------------------------------------------- # Get all packages in a directory # ------------------------------------------------------------------------- - def __get_packages (self, directory, package): - content = os.listdir (directory) + def __get_packages(self, directory, package): + content = os.listdir(directory) result = [] if "__init__.py" in content: result = [package] for name in content: - fullname = os.path.join (directory, name) - if os.path.isdir (fullname): - result = result + self.__get_packages (fullname, package + + fullname = os.path.join(directory, name) + if os.path.isdir(fullname): + result = result + self.__get_packages(fullname, package + "." + name) return result @@ -373,7 +378,7 @@ # Call the actual setup routine # ------------------------------------------------------------------------- - def run (self): + def run(self): global _setup # set global variable @@ -384,45 +389,45 @@ "cmdclass_install": install, } - _setup.set_params (setup_params) + _setup.set_params(setup_params) # make package available - self.package = setup_params ["name"] + self.package = setup_params["name"] # find out all packages - if not setup_params.has_key ("packages"): + if not setup_params.has_key("packages"): packages = [] - for module, directory in setup_params["package_dir"].items (): - packages = packages + self.__get_packages (directory, module) - setup_params ["packages"] = packages + for module, directory in setup_params["package_dir"].items(): + packages = packages + self.__get_packages(directory, module) + setup_params["packages"] = packages # remove data files that are not available - for target, files in setup_params ["data_files"]: + for target, files in setup_params["data_files"]: i = 0 - while i < len (files): - file = files [i] - if os.path.isfile (file): + while i < len(files): + file = files[i] + if os.path.isfile(file): i += 1 else: log.warn("warning: did not find file %s" % file) - files.remove (file) + files.remove(file) # now call setup - setup (name = setup_params ["name"], - version = setup_params ["version"], - description = setup_params ["description"], - long_description = setup_params ["long_description"], - author = setup_params ["author"], - author_email = setup_params ["author_email"], - url = setup_params ["url"], - license = setup_params ["license"], - packages = setup_params ["packages"], - package_dir = setup_params ["package_dir"], - scripts = setup_params ["scripts"], - data_files = setup_params ["data_files"], + setup(name = setup_params["name"], + version = setup_params["version"], + description = setup_params["description"], + long_description = setup_params["long_description"], + author = setup_params["author"], + author_email = setup_params["author_email"], + url = setup_params["url"], + license = setup_params["license"], + packages = setup_params["packages"], + package_dir = setup_params["package_dir"], + scripts = setup_params["scripts"], + data_files = setup_params["data_files"], - # Override certain command classes with our own ones - cmdclass = {"sdist": setup_params["cmdclass_sdist"], - "build": setup_params["cmdclass_build"], - "install": setup_params["cmdclass_install"]}) + # Override certain command classes with our own ones + cmdclass = {"sdist": setup_params["cmdclass_sdist"], + "build": setup_params["cmdclass_build"], + "install": setup_params["cmdclass_install"]}) _______________________________________________ commit-gnue mailing list commit-gnue@gnu.org http://lists.gnu.org/mailman/listinfo/commit-gnue