From 06bef562e837c2bf6e5c0b003262b2af8bc8b1d2 Mon Sep 17 00:00:00 2001 From: volpino Date: Tue, 27 Mar 2012 18:58:19 +0200 Subject: [PATCH] cleaning up, pep8 fix and changing tabs to spaces --- bin/euscan | 5 +-- setup.py | 112 ++++++++++++++++++++++++++--------------------------- 2 files changed, 58 insertions(+), 59 deletions(-) diff --git a/bin/euscan b/bin/euscan index 6f6463f..19c9ee5 100755 --- a/bin/euscan +++ b/bin/euscan @@ -16,7 +16,6 @@ __version__ = "git" """ Imports """ -import os import sys import getopt import errno @@ -208,7 +207,7 @@ def main(): try: ret = scan_upstream(package) - except AmbiguousPackageName as e: + except AmbiguousPackageName as e: pkgs = e.args[0] for candidate in pkgs: print(candidate) @@ -219,7 +218,7 @@ def main(): print(pp.error("The short ebuild name '%s' is ambiguous. Please specify" % basename(pkgs[0])), file=sys.stderr, end="") pp.die(1, "one of the above fully-qualified ebuild names instead.") - except GentoolkitException as err: + except GentoolkitException as err: pp.die(1, '%s: %s' % (package, str(err))) except Exception as err: pp.die(1, '%s: %s' % (package, str(err))) diff --git a/setup.py b/setup.py index 3b4eed5..f466c1f 100755 --- a/setup.py +++ b/setup.py @@ -6,9 +6,9 @@ import re import sys from distutils import log try: - from setuptools import setup, Command + from setuptools import setup, Command except ImportError: - from distutils.core import setup, Command + from distutils.core import setup, Command from glob import glob import os @@ -22,75 +22,75 @@ cwd = os.getcwd() # Load EPREFIX from Portage, fall back to the empty string if it fails try: - from portage.const import EPREFIX + from portage.const import EPREFIX except ImportError: - EPREFIX = '' + EPREFIX = '' # Python files that need `__version__ = ""` subbed, relative to this dir: python_scripts = [os.path.join(cwd, path) for path in ( - 'bin/euscan', + 'bin/euscan', )] class set_version(Command): - """Set python __version__ to our __version__.""" - description = "hardcode scripts' version using VERSION from environment" - user_options = [] # [(long_name, short_name, desc),] + """Set python __version__ to our __version__.""" + description = "hardcode scripts' version using VERSION from environment" + user_options = [] # [(long_name, short_name, desc),] - def initialize_options(self): - pass + def initialize_options(self): + pass - def finalize_options(self): - pass + def finalize_options(self): + pass - def run(self): - ver = 'git' if __version__ == '9999' else __version__ - print("Settings version to %s" % ver) + def run(self): + ver = 'git' if __version__ == '9999' else __version__ + print("Settings version to %s" % ver) - def sub(files, pattern): - for f in files: - updated_file = [] - with io.open(f, 'r', 1, 'utf_8') as s: - for line in s: - newline = re.sub(pattern, '"%s"' % ver, line, 1) - if newline != line: - log.info("%s: %s" % (f, newline)) - updated_file.append(newline) - with io.open(f, 'w', 1, 'utf_8') as s: - s.writelines(updated_file) - quote = r'[\'"]{1}' - python_re = r'(?<=^__version__ = )' + quote + '[^\'"]*' + quote - sub(python_scripts, python_re) + def sub(files, pattern): + for f in files: + updated_file = [] + with io.open(f, 'r', 1, 'utf_8') as s: + for line in s: + newline = re.sub(pattern, '"%s"' % ver, line, 1) + if newline != line: + log.info("%s: %s" % (f, newline)) + updated_file.append(newline) + with io.open(f, 'w', 1, 'utf_8') as s: + s.writelines(updated_file) + quote = r'[\'"]{1}' + python_re = r'(?<=^__version__ = )' + quote + '[^\'"]*' + quote + sub(python_scripts, python_re) packages = [ - str('.'.join(root.split(os.sep)[1:])) - for root, dirs, files in os.walk('pym/euscan') - if '__init__.py' in files + str('.'.join(root.split(os.sep)[1:])) + for root, dirs, files in os.walk('pym/euscan') + if '__init__.py' in files ] setup( - name='euscan', - version=__version__, - description='Ebuild upstream scan utility.', - author='Corentin Chary', - author_email='corentin.chary@gmail.com', - maintainer='Corentin Chary', - maintainer_email='corentin.chary@gmail.com', - url='http://euscan.iksaif.net', - download_url=( - 'https://github.com/iksaif/euscan/tarball/' + - ('master' if __version__ == '9999' else ('euscan-%s' % __version__)) - ), - install_requires=['django-annoying'], - package_dir={'': 'pym'}, - packages=packages, - package_data={}, - scripts=python_scripts, - data_files=( - (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'usr/share/man/man1'), - glob('man/*')), - ), - cmdclass={ - 'set_version': set_version, - }, + name='euscan', + version=__version__, + description='Ebuild upstream scan utility.', + author='Corentin Chary', + author_email='corentin.chary@gmail.com', + maintainer='Corentin Chary', + maintainer_email='corentin.chary@gmail.com', + url='http://euscan.iksaif.net', + download_url=( + 'https://github.com/iksaif/euscan/tarball/' + + ('master' if __version__ == '9999' else ('euscan-%s' % __version__)) + ), + install_requires=['django-annoying'], + package_dir={'': 'pym'}, + packages=packages, + package_data={}, + scripts=python_scripts, + data_files=( + (os.path.join(os.sep, EPREFIX.lstrip(os.sep), 'usr/share/man/man1'), + glob('man/*')), + ), + cmdclass={ + 'set_version': set_version, + }, )