Commit e16069ce authored by Andoni Morales Alastruey's avatar Andoni Morales Alastruey
Browse files

pep8: fix more errors

parent 8bc66074
......@@ -23,6 +23,7 @@ from cerbero.utils import shell, to_unixpath
from cerbero.utils import messages as m
import shutil
class Build (object):
'''
Base class for build handlers
......@@ -124,13 +125,13 @@ class MakefilesBase (Build):
@modify_environment
def configure(self):
shell.call(self.configure_tpl % {'config-sh': self.config_sh,
'prefix': to_unixpath(self.config.prefix),
'libdir': to_unixpath(self.config.libdir),
'host': self.config.host,
'target': self.config.target,
'build': self.config.build,
'options': self.configure_options},
self.make_dir)
'prefix': to_unixpath(self.config.prefix),
'libdir': to_unixpath(self.config.libdir),
'host': self.config.host,
'target': self.config.target,
'build': self.config.build,
'options': self.configure_options},
self.make_dir)
@modify_environment
def compile(self):
......@@ -228,26 +229,30 @@ class Autotools (MakefilesBase):
# Only use --disable-maintainer mode for real autotools based projects
if os.path.exists(os.path.join(self.make_dir, 'configure.in')) or\
os.path.exists(os.path.join(self.make_dir, 'configure.ac')):
self.configure_tpl += " --disable-maintainer-mode --disable-silent-rules "
self.configure_tpl += " --disable-maintainer-mode "
self.configure_tpl += " --disable-silent-rules "
if self.autoreconf:
shell.call(self.autoreconf_sh, self.make_dir)
files = shell.check_call('find %s -type f -name config.guess' % self.make_dir).split('\n')
files = shell.check_call('find %s -type f -name config.guess' %
self.make_dir).split('\n')
files.remove('')
for f in files:
o = os.path.join(self.config._relative_path ('data'), 'autotools', 'config.guess')
o = os.path.join(self.config._relative_path('data'), 'autotools',
'config.guess')
m.action("copying %s to %s" % (o, f))
shutil.copy(o, f)
files = shell.check_call('find %s -type f -name config.sub' % self.make_dir).split('\n')
files = shell.check_call('find %s -type f -name config.sub' %
self.make_dir).split('\n')
files.remove('')
for f in files:
o = os.path.join(self.config._relative_path ('data'), 'autotools', 'config.sub')
o = os.path.join(self.config._relative_path('data'), 'autotools',
'config.sub')
m.action("copying %s to %s" % (o, f))
shutil.copy(o, f)
if self.config.platform == Platform.WINDOWS and \
self.supports_cache_variables:
# On windows, environment variables are upperscase, but we still
......
......@@ -23,7 +23,7 @@ import time
import imp
from cerbero.config import CONFIG_DIR, Platform, Architecture, Distro,\
DistroVersion, License
DistroVersion, License
from cerbero.build.build import BuildType
from cerbero.build.source import SourceType
from cerbero.errors import FatalError, RecipeNotFoundError, InvalidRecipeError
......@@ -52,7 +52,8 @@ class RecipeStatus (object):
@type filepath: str
'''
def __init__(self, filepath, steps=[], needs_build=True, mtime=time.time()):
def __init__(self, filepath, steps=[], needs_build=True,
mtime=time.time()):
self.steps = steps
self.needs_build = needs_build
self.mtime = mtime
......@@ -328,8 +329,7 @@ class CookBook (object):
try:
recipe = self._load_recipe_from_file(f, custom)
except RecipeNotFoundError:
m.warning(_("Could not found a valid recipe in %s") %
f)
m.warning(_("Could not found a valid recipe in %s") % f)
if recipe is None:
continue
recipes[recipe.name] = recipe
......@@ -346,8 +346,9 @@ class CookBook (object):
'Distro': Distro, 'DistroVersion': DistroVersion,
'License': License, 'recipe': crecipe, 'os': os,
'BuildSteps': crecipe.BuildSteps,
'InvalidRecipeError': InvalidRecipeError, 'custom': custom}
parse_file (filepath, d)
'InvalidRecipeError': InvalidRecipeError,
'custom': custom}
parse_file(filepath, d)
r = d['Recipe'](self._config.arch_config[c])
r.__file__ = os.path.abspath(filepath)
r.prepare()
......@@ -358,7 +359,8 @@ class CookBook (object):
except InvalidRecipeError:
pass
except Exception, ex:
m.warning("Error loading recipe in file %s %s" % (filepath, ex))
m.warning("Error loading recipe in file %s %s" %
(filepath, ex))
if self._config.target_arch == Architecture.UNIVERSAL:
if not recipe.is_empty():
return recipe
......
......@@ -76,8 +76,8 @@ class FilesProvider(object):
tarball, which include all files except the development files
'''
return self.files_list_by_categories([x for x in self.categories \
if x != self.DEVEL_CAT])
return self.files_list_by_categories(
[x for x in self.categories if x != self.DEVEL_CAT])
def files_list(self):
'''
......@@ -136,8 +136,9 @@ class FilesProvider(object):
def _list_files_by_category(self, category):
search_category = category
if category.startswith(self.LIBS_CAT + '_'):
search_category = self.LIBS_CAT
search = self._searchfuncs.get(search_category, self._searchfuncs['default'])
search_category = self.LIBS_CAT
search = self._searchfuncs.get(search_category,
self._searchfuncs['default'])
return search(self._get_category_files_list(category))
def _search_files(self, files):
......@@ -148,10 +149,12 @@ class FilesProvider(object):
# replace extensions
fs = [f % self.extensions for f in files]
# fill directories
dirs = [x for x in fs if os.path.isdir(os.path.join(self.config.prefix, x))]
dirs = [x for x in fs if
os.path.isdir(os.path.join(self.config.prefix, x))]
for directory in dirs:
fs.remove(directory)
fs.extend(self._ls_dir(os.path.join(self.config.prefix, directory)))
fs.extend(self._ls_dir(os.path.join(self.config.prefix,
directory)))
# fill paths with pattern expansion *
paths = [x for x in fs if '*' in x]
if len(paths) != 0:
......@@ -232,7 +235,7 @@ class FilesProvider(object):
for category in self.categories:
if category != self.LIBS_CAT and \
not category.startswith(self.LIBS_CAT + '_'):
continue;
continue
pattern = 'lib/%(f)s.a lib/%(f)s.la '
if self.platform == Platform.LINUX:
......@@ -244,7 +247,7 @@ class FilesProvider(object):
elif self.platform in [Platform.DARWIN, Platform.IOS]:
pattern += 'lib/%(f)s.dylib '
libsmatch = [pattern % {'f':x, 'fnolib': x[3:]} for x in \
libsmatch = [pattern % {'f': x, 'fnolib': x[3:]} for x in
self._get_category_files_list(category)]
devel_libs.extend(shell.ls_files(libsmatch, self.config.prefix))
return devel_libs
......
......@@ -200,8 +200,9 @@ class Recipe(FilesProvider):
genlib = GenLib()
for dllpath in self.libraries():
try:
implib = genlib.create(os.path.join(self.config.prefix, dllpath),
os.path.join(self.config.prefix, 'lib'))
implib = genlib.create(
os.path.join(self.config.prefix, dllpath),
os.path.join(self.config.prefix, 'lib'))
logging.debug('Created %s' % implib)
except:
m.warning("Could not create .lib, gendef might be missing")
......@@ -368,7 +369,8 @@ class UniversalRecipe(object):
continue
src = os.path.join(self._config.prefix, f)
dest = os.path.join(self._config.prefix, recipe.config.target_arch, f)
dest = os.path.join(self._config.prefix,
recipe.config.target_arch, f)
if not os.path.exists(os.path.dirname(dest)):
os.makedirs(os.path.dirname(dest))
shutil.move(src, dest)
......@@ -86,10 +86,12 @@ class Tarball (Source):
def __init__(self):
Source.__init__(self)
if not self.url:
raise InvalidRecipeError(_("'url' attribute is missing in the recipe"))
raise InvalidRecipeError(
_("'url' attribute is missing in the recipe"))
self.url = self.replace_name_and_version(self.url)
if self.tarball_name is not None:
self.tarball_name = self.replace_name_and_version(self.tarball_name)
self.tarball_name = \
self.replace_name_and_version(self.tarball_name)
else:
self.tarball_name = os.path.basename(self.url)
if self.tarball_dirname is not None:
......@@ -118,7 +120,6 @@ class Tarball (Source):
shell.apply_patch(patch, self.build_dir, self.strip)
class GitCache (Source):
'''
Base class for source handlers using a Git repository
......@@ -180,7 +181,7 @@ class LocalTarball (GitCache):
x.startswith(self.package_name)]
if len(tarball) != 1:
raise FatalError(_("The local repository %s do not have a "
"valid tarball") % self.repo_dir)
"valid tarball") % self.repo_dir)
self.tarball_path = os.path.join(self.repo_dir, tarball[0])
def _apply_patches(self, patches_dir):
......@@ -271,6 +272,7 @@ class GitExtractedTarball(Git):
if path.endswith(match):
self._files[match].append(full_path)
class Svn(Source):
'''
Source handler for svn repositories
......
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