Commit 8bc66074 authored by Andoni Morales Alastruey's avatar Andoni Morales Alastruey
Browse files

pep8: start fixing several pep8 errors

parent 2baa43b4
......@@ -23,7 +23,7 @@ import copy
from cerbero import enums
from cerbero.errors import FatalError, ConfigurationError
from cerbero.utils import _, system_info, validate_packager, to_unixpath,\
shell, parse_file
shell, parse_file
from cerbero.utils import messages as m
......@@ -33,7 +33,8 @@ DEFAULT_HOME = os.path.expanduser('~/cerbero')
DEFAULT_CONFIG_FILENAME = 'cerbero.%s' % CONFIG_EXT
DEFAULT_CONFIG_FILE = os.path.join(CONFIG_DIR, DEFAULT_CONFIG_FILENAME)
DEFAULT_GIT_ROOT = 'git://anongit.freedesktop.org/gstreamer-sdk'
DEFAULT_WIX_PREFIX = 'C:/Program\ Files\ \(x86\)/Windows\ Installer\ XML\ v3.5/bin'
DEFAULT_WIX_PREFIX = \
'C:/Program\ Files\ \(x86\)/Windows\ Installer\ XML\ v3.5/bin'
DEFAULT_ALLOW_PARALLEL_BUILD = False
DEFAULT_PACKAGER = "Default <default@change.me>"
CERBERO_UNINSTALLED = 'CERBERO_UNINSTALLED'
......@@ -180,11 +181,11 @@ class Config (object):
perlversionpath = perlversionpath.rsplit('.', 1)[0]
perl5lib = ':'.join(
[to_unixpath(os.path.join(libdir, 'perl5')),
to_unixpath(perlversionpath)])
[to_unixpath(os.path.join(libdir, 'perl5')),
to_unixpath(perlversionpath)])
gstpluginpath = os.path.join(libdir, 'gstreamer-0.10')
gstregistry = os.path.join('~', '.gstreamer-0.10',
'.cerbero-registry-%s' % self.target_arch)
'.cerbero-registry-%s' % self.target_arch)
gstregistry = os.path.expanduser(gstregistry)
pythonpath = os.path.join(prefix, py_prefix, 'site-packages')
......@@ -199,7 +200,7 @@ class Config (object):
if bindir not in path and self.prefix_is_executable():
path = self._join_path(bindir, path)
path = self._join_path(
os.path.join(self.build_tools_prefix, 'bin'), path)
os.path.join(self.build_tools_prefix, 'bin'), path)
if self.prefix_is_executable():
ld_library_path = libdir
......@@ -360,7 +361,7 @@ class Config (object):
self._parse(DEFAULT_CONFIG_FILE)
else:
msg = _('Using default configuration because %s is missing') % \
DEFAULT_CONFIG_FILE
DEFAULT_CONFIG_FILE
m.warning(msg)
def _load_cmd_config(self, filename):
......@@ -422,7 +423,7 @@ class Config (object):
return os.path.abspath(p)
def _perl_version(self):
version = shell.check_call("perl -e 'print \"$]\";'");
version = shell.check_call("perl -e 'print \"$]\";'")
# FIXME: when perl's mayor is >= 10
mayor = version[0]
minor = str(int(version[2:5]))
......
......@@ -73,9 +73,9 @@ class DistroVersion:
OS_X_LEOPARD = 'osx_leopard'
IOS_6_0 = 'ios_6_0'
IOS_6_1 = 'ios_6_1'
ANDROID_GINGERBREAD = 'android_gingerbread' # API Level 9
ANDROID_ICE_CREAM_SANDWICH = 'android_ice_cream_sandwich' # API Level 14
ANDROID_JELLY_BEAN = 'android_jelly_bean' # API Level 16
ANDROID_GINGERBREAD = 'android_gingerbread' # API Level 9
ANDROID_ICE_CREAM_SANDWICH = 'android_ice_cream_sandwich' # API Level 14
ANDROID_JELLY_BEAN = 'android_jelly_bean' # API Level 16
class LicenseDescription:
......
......@@ -37,7 +37,7 @@ from cerbero.errors import UsageError, FatalError, BuildStepError, \
from cerbero.utils import _, N_, user_is_root
from cerbero.utils import messages as m
description = N_('Build and package a set of modules to distribute them in '\
description = N_('Build and package a set of modules to distribute them in '
'a SDK')
......
......@@ -70,7 +70,8 @@ dlpreopen=''
libdir='%(libdir)s'
'''
def __init__(self, libname, major, minor, micro, libdir, platform, deps=None):
def __init__(self, libname, major, minor, micro, libdir, platform,
deps=None):
self.libtool_vars = {
'libname': '',
'dlname': '',
......@@ -112,7 +113,7 @@ libdir='%(libdir)s'
if micro is not None:
dlname_all = '%s.%s' % (dlname, micro)
micro_str = micro
old_library = '%s.a' % libname
old_library = '%s.a' % libname
self.change_value('libname', self.laname)
self.change_value('dlname', dlname)
self.change_value('library_names', '%s %s %s' % (dlname_all, dlname,
......
......@@ -68,7 +68,8 @@ class OSXRelocator(object):
def parse_dir(self, dir_path, filters=None):
for dirpath, dirnames, filenames in os.walk(dir_path):
for f in filenames:
if filters is not None and os.path.splitext(f)[1] not in filters:
if filters is not None and \
os.path.splitext(f)[1] not in filters:
continue
self.change_libs_path(os.path.join(dirpath, f))
if not self.recursive:
......@@ -100,16 +101,16 @@ class OSXRelocator(object):
return path
class Main(object):
def run(self):
# We use OptionParser instead of ArgumentsParse because this script might
# be run in OS X 10.6 or older, which do not provide the argparse module
# We use OptionParser instead of ArgumentsParse because this script
# might be run in OS X 10.6 or older, which do not provide the argparse
# module
import optparse
usage = "usage: %prog [options] directory old_prefix new_prefix"
description='Rellocates object files changing the dependant dynamic '\
'libraries location path with a new one'
description = 'Rellocates object files changing the dependant '\
' dynamic libraries location path with a new one'
parser = optparse.OptionParser(usage=usage, description=description)
parser.add_option('-r', '--recursive', action='store_true',
default=False, dest='recursive',
......
......@@ -21,7 +21,6 @@ import os
class PkgConfigWritter(object):
VARIABLES_TPL = '''\
prefix=%(prefix)s
exec_prefix=${prefix}
......@@ -66,18 +65,18 @@ Cflags: %(cflags)s
def _get_variables(self):
return self.VARIABLES_TPL % {
'prefix': self.prefix,
'rel_libdir': self.rel_libdir,
'rel_incldir': self.rel_incldir,
'rel_sharedir': self.rel_sharedir}
'prefix': self.prefix,
'rel_libdir': self.rel_libdir,
'rel_incldir': self.rel_incldir,
'rel_sharedir': self.rel_sharedir}
def _get_body(self):
return self.BODY_TPL % {
'name': self.name,
'desc': self.desc,
'version': self.version,
'req': self.req,
'req_priv': self.req_priv,
'libs': self.libs,
'libs_priv': self.libs_priv,
'cflags': self.cflags}
'name': self.name,
'desc': self.desc,
'version': self.version,
'req': self.req,
'req_priv': self.req_priv,
'libs': self.libs,
'libs_priv': self.libs_priv,
'cflags': self.cflags}
......@@ -204,7 +204,7 @@ def system_info():
def validate_packager(packager):
# match packager in the form 'Name <email>'
expr = r'(.*\s)*[<]([a-zA-Z0-9+_\-\.]+@'\
'[0-9a-zA-Z][.-0-9a-zA-Z]*.[a-zA-Z]+)[>]$'
'[0-9a-zA-Z][.-0-9a-zA-Z]*.[a-zA-Z]+)[>]$'
return bool(re.match(expr, packager))
......@@ -232,12 +232,13 @@ def remove_list_duplicates(seq):
''' Remove list duplicates maintaining the order '''
seen = set()
seen_add = seen.add
return [ x for x in seq if x not in seen and not seen_add(x)]
return [x for x in seq if x not in seen and not seen_add(x)]
def parse_file(filename, dict):
try:
execfile(filename, dict)
except Exception, ex:
import traceback; traceback.print_exc()
import traceback
traceback.print_exc()
raise ex
......@@ -80,8 +80,9 @@ def create_tag(git_dir, tagname, tagdescription, commit, fail=True):
@param fail: raise an error if the command failed
@type fail: false
'''
shell.call('%s tag -s %s -m "%s" %s' % (GIT, tagname, tagdescription, commit),
git_dir, fail=fail)
shell.call('%s tag -s %s -m "%s" %s' %
(GIT, tagname, tagdescription, commit), git_dir, fail=fail)
return shell.call('%s push origin --tags' % GIT, git_dir, fail=fail)
......@@ -175,6 +176,7 @@ def add_remote(git_dir, name, url):
shell.call('%s remote add -f %s %s' % (GIT, name, url), git_dir,
fail=False)
def check_line_endings(platform):
'''
Checks if on windows we don't use the automatic line endings conversion
......@@ -191,4 +193,3 @@ def check_line_endings(platform):
if ('false' in val.lower()):
return True
return False
......@@ -25,7 +25,6 @@ from cerbero.utils import fix_winpath, shell
class MSBuild(object):
def __init__(self, solution, arch=Architecture.X86, config='Release',
sdk='Windows7.1SDK', **properties):
self.properties = {}
......
......@@ -90,8 +90,9 @@ def call(cmd, cmd_dir='.', fail=True):
shell = False
stream = LOGFILE or sys.stdout
ret = subprocess.check_call(cmd, cwd=cmd_dir,
stderr=subprocess.STDOUT, stdout=StdOut(stream),
env=os.environ.copy(), shell=shell)
stderr=subprocess.STDOUT,
stdout=StdOut(stream),
env=os.environ.copy(), shell=shell)
except subprocess.CalledProcessError:
if fail:
raise FatalError(_("Error running command: %s") % cmd)
......@@ -105,7 +106,8 @@ def check_call(cmd, cmd_dir=None, shell=False, split=True, fail=False):
if split:
cmd = shlex.split(cmd)
process = subprocess.Popen(cmd, cwd=cmd_dir,
stdout=subprocess.PIPE, stderr=open(os.devnull), shell=shell)
stdout=subprocess.PIPE,
stderr=open(os.devnull), shell=shell)
output, unused_err = process.communicate()
if process.poll() and fail:
raise Exception()
......@@ -125,6 +127,7 @@ def apply_patch(patch, directory, strip=1):
@param strip: strip
@type strip: int
'''
logging.info("Applying patch %s" % (patch))
call('%s -p%s -f -i %s' % (PATCH, strip, patch), directory)
......@@ -181,7 +184,7 @@ def download(url, destination=None, recursive=False, check_cert=True):
raise e
def download_curl (url, destination=None, recursive=False, check_cert=True):
def download_curl(url, destination=None, recursive=False, check_cert=True):
'''
Downloads a file with cURL
......@@ -241,7 +244,7 @@ def ls_files(files, prefix):
if files == []:
return files
sfiles = check_call('ls %s' % ' '.join(files),
prefix, True, False, False).split('\n')
prefix, True, False, False).split('\n')
sfiles.remove('')
return list(set(sfiles))
......
......@@ -53,4 +53,3 @@ def checkout_file(url, out_path):
@type revision: str
'''
shell.call('svn export --force %s %s' % (url, out_path))
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment