Browse Source

python3: Run 2to3 script to conver the whole codebase

This is only the raw output of the script, no manual editing. The code
is now python3 only.

https://bugzilla.gnome.org/show_bug.cgi?id=733067
zrythm
Xavier Claessens 6 years ago
parent
commit
029a2a8d3b
  1. 2
      cerbero/bootstrap/android.py
  2. 2
      cerbero/bootstrap/windows.py
  3. 14
      cerbero/build/build.py
  4. 20
      cerbero/build/cookbook.py
  5. 2
      cerbero/build/filesprovider.py
  6. 4
      cerbero/build/oven.py
  7. 40
      cerbero/build/recipe.py
  8. 20
      cerbero/build/source.py
  9. 4
      cerbero/commands/__init__.py
  10. 16
      cerbero/commands/add_package.py
  11. 6
      cerbero/commands/add_recipe.py
  12. 4
      cerbero/commands/check.py
  13. 5
      cerbero/commands/checkpackage.py
  14. 6
      cerbero/commands/cleanone.py
  15. 2
      cerbero/commands/debugpackages.py
  16. 2
      cerbero/commands/genlibfiles.py
  17. 4
      cerbero/commands/gensdkshell.py
  18. 4
      cerbero/commands/info.py
  19. 6
      cerbero/commands/list.py
  20. 14
      cerbero/config.py
  21. 6
      cerbero/hacks.py
  22. 4
      cerbero/ide/vs/pkgconfig2vsprops.py
  23. 4
      cerbero/ide/xcode/fwlib.py
  24. 3
      cerbero/ide/xcode/xcconfig.py
  25. 20
      cerbero/main.py
  26. 2
      cerbero/packages/android.py
  27. 2
      cerbero/packages/debian.py
  28. 4
      cerbero/packages/linux.py
  29. 2
      cerbero/packages/osx/buildtools.py
  30. 4
      cerbero/packages/osx/bundles.py
  31. 6
      cerbero/packages/osx/packager.py
  32. 16
      cerbero/packages/package.py
  33. 10
      cerbero/packages/packagesstore.py
  34. 1
      cerbero/packages/rpm.py
  35. 6
      cerbero/packages/wix.py
  36. 4
      cerbero/packages/wix_packager.py
  37. 8
      cerbero/tools/osxuniversalgenerator.py
  38. 4
      cerbero/utils/__init__.py
  39. 154
      cerbero/utils/msbuild.py
  40. 22
      cerbero/utils/shell.py
  41. 2
      config/ios.config
  42. 2
      recipes/cdparanoia.recipe
  43. 2
      recipes/docbook-xml.recipe
  44. 2
      recipes/docbook-xsl.recipe
  45. 2
      recipes/gst-android-1.0.recipe
  46. 2
      recipes/gstreamer-ios-templates.recipe
  47. 2
      recipes/nettle/nettle.recipe
  48. 16
      test/test_cerbero_build_build.py
  49. 40
      test/test_cerbero_build_cookbook.py
  50. 22
      test/test_cerbero_build_filesprovider.py
  51. 54
      test/test_cerbero_build_recipe.py
  52. 36
      test/test_cerbero_config.py
  53. 26
      test/test_cerbero_ide_pkgconfig.py
  54. 4
      test/test_cerbero_ide_xcode_xcconfig.py
  55. 14
      test/test_cerbero_packages_disttarball.py
  56. 42
      test/test_cerbero_packages_linux.py
  57. 12
      test/test_cerbero_packages_osx_info_plist.py
  58. 50
      test/test_cerbero_packages_package.py
  59. 6
      test/test_cerbero_packages_packagemaker.py
  60. 26
      test/test_cerbero_packages_packagesstore.py
  61. 42
      test/test_cerbero_packages_pmdoc.py
  62. 36
      test/test_cerbero_packages_wix.py
  63. 8
      test/test_cerbero_tools_osxuniversalgenerator.py
  64. 4
      test/test_common.py
  65. 16
      tools/certdata2pem.py
  66. 13
      tools/show-coverage.py

2
cerbero/bootstrap/android.py

@ -43,7 +43,7 @@ class AndroidBootstrapper (BootstrapperBase): @@ -43,7 +43,7 @@ class AndroidBootstrapper (BootstrapperBase):
try:
shell.call('unzip %s' % ndk_zip, dest)
shell.call('mv android-ndk-%s/* .' % self.NDK_VERSION, dest)
except Exception, ex:
except Exception as ex:
raise FatalError(_("Error installing Android NDK: %s") % (ex))

2
cerbero/bootstrap/windows.py

@ -175,7 +175,7 @@ class WindowsBootstrapper(BootstrapperBase): @@ -175,7 +175,7 @@ class WindowsBootstrapper(BootstrapperBase):
# get the path
libdir = libdir.split('=')[1]
# strip the surrounding quotes
print "Replacing old libdir : ", libdir
print("Replacing old libdir : ", libdir)
return libdir.strip()[1:-1]
def remove_mingw_cpp(self):

14
cerbero/build/build.py

@ -87,7 +87,7 @@ def modify_environment(func): @@ -87,7 +87,7 @@ def modify_environment(func):
self._restore_env(old_env)
return res
call.func_name = func.func_name
call.__name__ = func.__name__
return call
@ -175,16 +175,16 @@ class MakefilesBase (Build): @@ -175,16 +175,16 @@ class MakefilesBase (Build):
return None
self._old_env = {}
for var in append_env.keys() + new_env.keys():
for var in list(append_env.keys()) + list(new_env.keys()):
self._old_env[var] = os.environ.get(var, None)
for var, val in append_env.iteritems():
if not os.environ.has_key(var):
for var, val in append_env.items():
if var not in os.environ:
os.environ[var] = val
else:
os.environ[var] = '%s %s' % (os.environ[var], val)
for var, val in new_env.iteritems():
for var, val in new_env.items():
if val is None:
if var in os.environ:
del os.environ[var]
@ -197,7 +197,7 @@ class MakefilesBase (Build): @@ -197,7 +197,7 @@ class MakefilesBase (Build):
if old_env is None:
return
for var, val in old_env.iteritems():
for var, val in old_env.items():
if val is None:
if var in os.environ:
del os.environ[var]
@ -267,7 +267,7 @@ class Autotools (MakefilesBase): @@ -267,7 +267,7 @@ class Autotools (MakefilesBase):
# On windows, environment variables are upperscase, but we still
# need to pass things like am_cv_python_platform in lowercase for
# configure and autogen.sh
for k, v in os.environ.iteritems():
for k, v in os.environ.items():
if k[2:6] == '_cv_':
self.configure_tpl += ' %s="%s"' % (k, v)

20
cerbero/build/cookbook.py

@ -143,7 +143,7 @@ class CookBook (object): @@ -143,7 +143,7 @@ class CookBook (object):
@return: list of recipes
@rtype: list
'''
recipes = self.recipes.values()
recipes = list(self.recipes.values())
recipes.sort(key=lambda x: x.name)
return recipes
@ -268,10 +268,10 @@ class CookBook (object): @@ -268,10 +268,10 @@ class CookBook (object):
@rtype: list
'''
recipe = self.get_recipe(recipe_name)
return [r for r in self.recipes.values() if recipe.name in r.deps]
return [r for r in list(self.recipes.values()) if recipe.name in r.deps]
def _runtime_deps (self):
return [x.name for x in self.recipes.values() if x.runtime_dep]
return [x.name for x in list(self.recipes.values()) if x.runtime_dep]
def _cache_file(self, config):
if config.cache_file is not None:
@ -294,7 +294,7 @@ class CookBook (object): @@ -294,7 +294,7 @@ class CookBook (object):
os.makedirs(os.path.dirname(cache_file))
with open(cache_file, 'wb') as f:
pickle.dump(self.status, f)
except IOError, ex:
except IOError as ex:
m.warning(_("Could not cache the CookBook: %s") % ex)
def _find_deps(self, recipe, state={}, ordered=[]):
@ -309,7 +309,7 @@ class CookBook (object): @@ -309,7 +309,7 @@ class CookBook (object):
for recipe_name in recipe_deps:
try:
recipedep = self.get_recipe(recipe_name)
except RecipeNotFoundError, e:
except RecipeNotFoundError as e:
raise FatalError(_("Recipe %s has a unknown dependency %s"
% (recipe.name, recipe_name)))
try:
@ -335,14 +335,14 @@ class CookBook (object): @@ -335,14 +335,14 @@ class CookBook (object):
self.recipes = {}
recipes = defaultdict(dict)
recipes_repos = self._config.get_recipes_repos()
for reponame, (repodir, priority) in recipes_repos.iteritems():
for reponame, (repodir, priority) in recipes_repos.items():
recipes[int(priority)].update(self._load_recipes_from_dir(repodir))
# Add recipes by asceding pripority
for key in sorted(recipes.keys()):
self.recipes.update(recipes[key])
# Check for updates in the recipe file to reset the status
for recipe in self.recipes.values():
for recipe in list(self.recipes.values()):
if recipe.name not in self.status:
continue
st = self.status[recipe.name]
@ -399,7 +399,7 @@ class CookBook (object): @@ -399,7 +399,7 @@ class CookBook (object):
recipe = crecipe.UniversalFlatRecipe(self._config)
else:
recipe = crecipe.UniversalRecipe(self._config)
for c in self._config.arch_config.keys():
for c in list(self._config.arch_config.keys()):
try:
d = {'Platform': Platform, 'Architecture': Architecture,
'BuildType': BuildType, 'SourceType': SourceType,
@ -423,9 +423,9 @@ class CookBook (object): @@ -423,9 +423,9 @@ class CookBook (object):
recipe.add_recipe(r)
else:
return r
except InvalidRecipeError, e:
except InvalidRecipeError as e:
self._invalid_recipes[r.name] = e
except Exception, ex:
except Exception as ex:
m.warning("Error loading recipe in file %s %s" %
(filepath, ex))
if self._config.target_arch == Architecture.UNIVERSAL:

2
cerbero/build/filesprovider.py

@ -191,7 +191,7 @@ class FilesProvider(object): @@ -191,7 +191,7 @@ class FilesProvider(object):
# The library search function returns a dict that is a mapping from
# library name to filenames, but we only want a list of filenames
if not isinstance(cat_files, list):
cat_files = flatten_files_list(cat_files.values())
cat_files = flatten_files_list(list(cat_files.values()))
files.extend(cat_files)
return sorted(list(set(files)))

4
cerbero/build/oven.py

@ -95,7 +95,7 @@ class Oven (object): @@ -95,7 +95,7 @@ class Oven (object):
for recipe in ordered_recipes:
try:
self._cook_recipe(recipe, i, len(ordered_recipes))
except BuildStepError, be:
except BuildStepError as be:
if not self.interactive:
raise be
msg = be.msg
@ -144,7 +144,7 @@ class Oven (object): @@ -144,7 +144,7 @@ class Oven (object):
# update status successfully
self.cookbook.update_step_status(recipe.name, step)
shell.close_logfile_output()
except FatalError, e:
except FatalError as e:
shell.close_logfile_output(dump=True)
self._handle_build_step_error(recipe, step, e.arch)
except Exception:

40
cerbero/build/recipe.py

@ -31,6 +31,7 @@ from cerbero.tools.osxuniversalgenerator import OSXUniversalGenerator @@ -31,6 +31,7 @@ from cerbero.tools.osxuniversalgenerator import OSXUniversalGenerator
from cerbero.utils import N_, _
from cerbero.utils import shell
from cerbero.utils import messages as m
from functools import reduce
class MetaRecipe(type):
@ -84,7 +85,7 @@ class BuildSteps(object): @@ -84,7 +85,7 @@ class BuildSteps(object):
BuildSteps.POST_INSTALL]
class Recipe(FilesProvider):
class Recipe(FilesProvider, metaclass=MetaRecipe):
'''
Base class for recipes.
A Recipe describes a module and the way it's built.
@ -109,8 +110,6 @@ class Recipe(FilesProvider): @@ -109,8 +110,6 @@ class Recipe(FilesProvider):
@type runtime_dep: bool
'''
__metaclass__ = MetaRecipe
name = None
licenses = []
version = None
@ -221,7 +220,7 @@ class Recipe(FilesProvider): @@ -221,7 +220,7 @@ class Recipe(FilesProvider):
output_dir = os.path.join(self.config.prefix,
'lib' + self.config.lib_suffix)
genlib = GenLib()
for (libname, dllpaths) in self.libraries().items():
for (libname, dllpaths) in list(self.libraries().items()):
if len(dllpaths) > 1:
m.warning("BUG: Found multiple DLLs for libname {}:\n{}".format(libname, '\n'.join(dllpaths)))
continue
@ -278,7 +277,7 @@ class MetaUniversalRecipe(type): @@ -278,7 +277,7 @@ class MetaUniversalRecipe(type):
setattr(cls, step, lambda self, name=step: step_func(self, name))
class UniversalRecipe(object):
class UniversalRecipe(object, metaclass=MetaUniversalRecipe):
'''
Stores similar recipe objects that are going to be built together
@ -287,16 +286,14 @@ class UniversalRecipe(object): @@ -287,16 +286,14 @@ class UniversalRecipe(object):
other targets, it will likely be a unitary group
'''
__metaclass__ = MetaUniversalRecipe
def __init__(self, config):
self._config = config
self._recipes = {}
self._proxy_recipe = None
def __str__(self):
if self._recipes.values():
return str(self._recipes.values()[0])
if list(self._recipes.values()):
return str(list(self._recipes.values())[0])
return super(UniversalRecipe, self).__str__()
def add_recipe(self, recipe):
@ -329,7 +326,7 @@ class UniversalRecipe(object): @@ -329,7 +326,7 @@ class UniversalRecipe(object):
def __setattr__(self, name, value):
object.__setattr__(self, name, value)
if name not in ['_config', '_recipes', '_proxy_recipe']:
for o in self._recipes.values():
for o in list(self._recipes.values()):
setattr(o, name, value)
def get_for_arch (self, arch, name):
@ -341,14 +338,15 @@ class UniversalRecipe(object): @@ -341,14 +338,15 @@ class UniversalRecipe(object):
def _do_step(self, step):
if step in BuildSteps.FETCH:
# No, really, let's not download a million times...
stepfunc = getattr(self._recipes.values()[0], step)
stepfunc = getattr(list(self._recipes.values())[0], step)
try:
stepfunc()
except FatalError, e:
except FatalError as e:
e.arch = arch
raise e
return
for arch, recipe in self._recipes.iteritems():
for arch, recipe in self._recipes.items():
config = self._config.arch_config[arch]
config.do_setup_env()
stepfunc = getattr(recipe, step)
@ -356,7 +354,7 @@ class UniversalRecipe(object): @@ -356,7 +354,7 @@ class UniversalRecipe(object):
# Call the step function
try:
stepfunc()
except FatalError, e:
except FatalError as e:
e.arch = arch
raise e
@ -378,7 +376,7 @@ class UniversalFlatRecipe(UniversalRecipe): @@ -378,7 +376,7 @@ class UniversalFlatRecipe(UniversalRecipe):
def merge(self):
arch_inputs = {}
for arch, recipe in self._recipes.iteritems():
for arch, recipe in self._recipes.items():
# change the prefix temporarly to the arch prefix where files are
# actually installed
recipe.config.prefix = os.path.join(self.config.prefix, arch)
@ -386,15 +384,15 @@ class UniversalFlatRecipe(UniversalRecipe): @@ -386,15 +384,15 @@ class UniversalFlatRecipe(UniversalRecipe):
recipe.config.prefix = self._config.prefix
# merge the common files
inputs = reduce(lambda x, y: x & y, arch_inputs.values())
inputs = reduce(lambda x, y: x & y, list(arch_inputs.values()))
output = self._config.prefix
generator = OSXUniversalGenerator(output)
generator.merge_files(list(inputs),
[os.path.join(self._config.prefix, arch) for arch in
self._recipes.keys()])
list(self._recipes.keys())])
# merge the architecture specific files
for arch in self._recipes.keys():
for arch in list(self._recipes.keys()):
ainputs = list(inputs ^ arch_inputs[arch])
output = self._config.prefix
generator = OSXUniversalGenerator(output)
@ -404,7 +402,7 @@ class UniversalFlatRecipe(UniversalRecipe): @@ -404,7 +402,7 @@ class UniversalFlatRecipe(UniversalRecipe):
def _do_step(self, step):
if step in BuildSteps.FETCH:
# No, really, let's not download a million times...
stepfunc = getattr(self._recipes.values()[0], step)
stepfunc = getattr(list(self._recipes.values())[0], step)
stepfunc()
return
@ -412,9 +410,9 @@ class UniversalFlatRecipe(UniversalRecipe): @@ -412,9 +410,9 @@ class UniversalFlatRecipe(UniversalRecipe):
# with the same final prefix, but we want to install each architecture
# on a different path (eg: /path/to/prefix/x86).
archs_prefix = self._recipes.keys()
archs_prefix = list(self._recipes.keys())
for arch, recipe in self._recipes.iteritems():
for arch, recipe in self._recipes.items():
config = self._config.arch_config[arch]
config.do_setup_env()
stepfunc = getattr(recipe, step)

20
cerbero/build/source.py

@ -19,8 +19,8 @@ @@ -19,8 +19,8 @@
import os
import shutil
import tarfile
import urllib
import urlparse
import urllib.request, urllib.parse, urllib.error
import urllib.parse
from cerbero.config import Platform
from cerbero.utils import git, svn, shell, _
@ -104,10 +104,10 @@ class Tarball (Source): @@ -104,10 +104,10 @@ class Tarball (Source):
self.replace_name_and_version(self.tarball_dirname)
self.download_path = os.path.join(self.repo_dir, self.tarball_name)
# URL-encode spaces and other special characters in the URL's path
split = list(urlparse.urlsplit(self.url))
split[2] = urllib.quote(split[2])
self.url = urlparse.urlunsplit(split)
self.mirror_url = urlparse.urljoin(TARBALL_MIRROR, self.tarball_name)
split = list(urllib.parse.urlsplit(self.url))
split[2] = urllib.parse.quote(split[2])
self.url = urllib.parse.urlunsplit(split)
self.mirror_url = urllib.parse.urljoin(TARBALL_MIRROR, self.tarball_name)
def fetch(self, redownload=False):
if not os.path.exists(self.repo_dir):
@ -180,18 +180,18 @@ class GitCache (Source): @@ -180,18 +180,18 @@ class GitCache (Source):
# First try to get the sources from the cached dir if there is one
cached_dir = os.path.join(self.config.cached_sources, self.name)
if os.path.isdir(os.path.join(cached_dir, ".git")):
for remote, url in self.remotes.iteritems():
for remote, url in self.remotes.items():
git.add_remote(self.repo_dir, remote, "file://" + cached_dir)
for remote, url in self.config.recipe_remotes(self.name).iteritems():
for remote, url in self.config.recipe_remotes(self.name).items():
git.add_remote(self.repo_dir, remote, "file://" + cached_dir)
git.fetch(self.repo_dir, fail=False)
else:
cached_dir = None
# add remotes from both upstream and config so user can easily
# cherry-pick patches between branches
for remote, url in self.remotes.iteritems():
for remote, url in self.remotes.items():
git.add_remote(self.repo_dir, remote, url)
for remote, url in self.config.recipe_remotes(self.name).iteritems():
for remote, url in self.config.recipe_remotes(self.name).items():
git.add_remote(self.repo_dir, remote, url)
# fetch remote branches
git.fetch(self.repo_dir, fail=False)

4
cerbero/commands/__init__.py

@ -64,9 +64,9 @@ def load_commands(subparsers): @@ -64,9 +64,9 @@ def load_commands(subparsers):
continue
try:
__import__('cerbero.commands.%s' % name)
except ImportError, e:
except ImportError as e:
m.warning("Error importing command %s:\n %s" % (name, e))
for command in _commands.values():
for command in list(_commands.values()):
command.add_parser(subparsers)

16
cerbero/commands/add_package.py

@ -104,7 +104,7 @@ class AddPackage(Command): @@ -104,7 +104,7 @@ class AddPackage(Command):
ArgparseArgument('-l', '--license', default='',
help=_('license of the package. '
'Supported licenses: %s') %
', '.join(self.supported_licenses.keys())),
', '.join(list(self.supported_licenses.keys()))),
ArgparseArgument('-d', '--deps', default='',
help=_('comma separated list of the package '
'dependencies')),
@ -130,7 +130,7 @@ class AddPackage(Command): @@ -130,7 +130,7 @@ class AddPackage(Command):
'windows:recipe2) '
'Supported platforms: %s') %
', '.join(
self.supported_platforms.keys())),
list(self.supported_platforms.keys()))),
ArgparseArgument('--platform-files-devel', default='',
help=_('comma separated list of platform:recipe '
'files to add to the devel package '
@ -138,7 +138,7 @@ class AddPackage(Command): @@ -138,7 +138,7 @@ class AddPackage(Command):
'windows:recipe2) '
'Supported platforms: %s') %
', '.join(
self.supported_platforms.keys())),
list(self.supported_platforms.keys()))),
ArgparseArgument('-f', '--force', action='store_true',
default=False, help=_('Replace package if existing'))])
@ -184,7 +184,7 @@ class AddPackage(Command): @@ -184,7 +184,7 @@ class AddPackage(Command):
for dname in deps:
try:
package = store.get_package(dname)
except Exception, ex:
except Exception as ex:
raise UsageError(_("Error creating package: "
"dependant package %s does not exist") % dname)
template_args['deps'] = deps
@ -201,7 +201,7 @@ class AddPackage(Command): @@ -201,7 +201,7 @@ class AddPackage(Command):
for pname in includes:
try:
package = store.get_package(pname)
except Exception, ex:
except Exception as ex:
raise UsageError(_("Error creating package: "
"included package %s does not exist") % pname)
include_files.extend(package.files)
@ -254,12 +254,12 @@ class AddPackage(Command): @@ -254,12 +254,12 @@ class AddPackage(Command):
m.action(_("Package '%s' successfully created in %s") %
(name, filename))
except IOError, ex:
except IOError as ex:
raise FatalError(_("Error creating package: %s") % ex)
def merge_dict(self, d1, d2):
ret = d1
for k, v in d2.iteritems():
for k, v in d2.items():
if k in ret:
ret[k].extend(v)
else:
@ -303,7 +303,7 @@ class AddPackage(Command): @@ -303,7 +303,7 @@ class AddPackage(Command):
parsed_files = extra_files
template_arg = []
for platform, files in parsed_files.iteritems():
for platform, files in parsed_files.items():
template_arg.append(
self.supported_platforms[platform] + ': [' + \
', '.join(['\'' + recipe_files + '\'' \

6
cerbero/commands/add_recipe.py

@ -75,7 +75,7 @@ class AddRecipe(Command): @@ -75,7 +75,7 @@ class AddRecipe(Command):
ArgparseArgument('-l', '--licenses', default='',
help=_('comma separated list of the recipe '
'licenses. Supported licenses: %s') %
', '.join(self.supported_licenses.keys())),
', '.join(list(self.supported_licenses.keys()))),
ArgparseArgument('-c', '--commit', default='',
help=_('commit to use '
'(default to "sdk-$version")')),
@ -125,7 +125,7 @@ class AddRecipe(Command): @@ -125,7 +125,7 @@ class AddRecipe(Command):
for dname in deps:
try:
recipe = cookbook.get_recipe(dname)
except RecipeNotFoundError, ex:
except RecipeNotFoundError as ex:
raise UsageError(_("Error creating recipe: "
"dependant recipe %s does not exist") % dname)
template_args['deps'] = deps
@ -137,7 +137,7 @@ class AddRecipe(Command): @@ -137,7 +137,7 @@ class AddRecipe(Command):
m.action(_("Recipe '%s' successfully created in %s") %
(name, filename))
except IOError, ex:
except IOError as ex:
raise FatalError(_("Error creating recipe: %s") % ex)
def validate_licenses(self, licenses):

4
cerbero/commands/check.py

@ -63,9 +63,9 @@ class Check(Command): @@ -63,9 +63,9 @@ class Check(Command):
if stepfunc:
try:
stepfunc()
except FatalError, e:
except FatalError as e:
raise e
except Exception, ex:
except Exception as ex:
raise FatalError(_("Error running %s checks: %s") %
(recipe.name, ex))

5
cerbero/commands/checkpackage.py

@ -43,8 +43,7 @@ class CheckPackage(Command): @@ -43,8 +43,7 @@ class CheckPackage(Command):
store = PackagesStore(config)
p = store.get_package(p_name)
ordered_recipes = map(lambda x: cookbook.get_recipe(x),
p.recipes_dependencies())
ordered_recipes = [cookbook.get_recipe(x) for x in p.recipes_dependencies()]
for recipe in ordered_recipes:
if cookbook.recipe_needs_build(recipe.name):
@ -62,7 +61,7 @@ class CheckPackage(Command): @@ -62,7 +61,7 @@ class CheckPackage(Command):
try:
m.message('Running checks for recipe %s' % recipe.name)
stepfunc()
except Exception, ex:
except Exception as ex:
failed.append(recipe.name)
m.warning(_("%s checks failed: %s") % (recipe.name, ex))
if failed:

6
cerbero/commands/cleanone.py

@ -42,14 +42,14 @@ class CleanOne(Command): @@ -42,14 +42,14 @@ class CleanOne(Command):
try:
stepfunc = getattr(recipe, 'clean')
except:
print '%s has no clean step, skipped' % recipe.name
print('%s has no clean step, skipped' % recipe.name)
if stepfunc:
try:
stepfunc()
except FatalError, e:
except FatalError as e:
raise e
except Exception, ex:
except Exception as ex:
raise FatalError(_("Error running %s checks: %s") %
(recipe.name, ex))

2
cerbero/commands/debugpackages.py

@ -56,7 +56,7 @@ class DebugPackages(Command): @@ -56,7 +56,7 @@ class DebugPackages(Command):
def find_orphan_files(self, allfiles, prefix, excludes=[]):
cmd = 'find . -type f %s'
exc = map(lambda x: "\\( ! -name '%s' \\)" % x, excludes)
exc = ["\\( ! -name '%s' \\)" % x for x in excludes]
cmd = cmd % ' '.join(exc)
distfiles = shell.check_call(cmd, prefix).split('\n')

2
cerbero/commands/genlibfiles.py

@ -51,7 +51,7 @@ class GenLibraryFiles(Command): @@ -51,7 +51,7 @@ class GenLibraryFiles(Command):
for recipe in recipes:
try:
recipe.gen_library_file(args.output_dir)
except Exception, e:
except Exception as e:
m.message(_("Error generaring library files for %s:\n %s") %
(recipe.name, e))

4
cerbero/commands/gensdkshell.py

@ -102,7 +102,7 @@ class GenSdkShell(Command): @@ -102,7 +102,7 @@ class GenSdkShell(Command):
self._putvar('GI_TYPELIB_PATH', '%s/girepository-1.0' % libdir)
envstr = 'export %s="%s"\n' % (prefix_env_name, prefix)
for e, v in env.iteritems():
for e, v in env.items():
envstr += 'export %s="%s"\n' % (e, v)
try:
filepath = os.path.join(output_dir, name)
@ -113,7 +113,7 @@ class GenSdkShell(Command): @@ -113,7 +113,7 @@ class GenSdkShell(Command):
with open(filepath, 'w+') as f:
f.write(SCRIPT_TPL % (envstr, cmd))
shell.call("chmod +x %s" % filepath)
except IOError, ex:
except IOError as ex:
raise FatalError(_("Error creating script: %s" % ex))

4
cerbero/commands/info.py

@ -58,8 +58,8 @@ class PackageInfo(Command): @@ -58,8 +58,8 @@ class PackageInfo(Command):
recipes_licenses = p.recipes_licenses()
recipes_licenses.update(p.devel_recipes_licenses())
for recipe_name, categories_licenses in \
recipes_licenses.iteritems():
for category_licenses in categories_licenses.itervalues():
recipes_licenses.items():
for category_licenses in categories_licenses.values():
licenses.extend(category_licenses)
licenses = sorted(list(set(licenses)))
d = {'name': p.name, 'version': p.version, 'url': p.url,

6
cerbero/commands/list.py

@ -70,12 +70,12 @@ class ShowConfig(Command): @@ -70,12 +70,12 @@ class ShowConfig(Command):
def run(self, config, args):
for n in config._properties:
if n == "variants":
print "%25s :" % (n)
print("%25s :" % (n))
variants = getattr(config, n).__dict__
for v in variants:
print "%30s : %s" % (v, variants[v])
print("%30s : %s" % (v, variants[v]))
else:
print "%25s : %s" % (n, getattr(config, n))
print("%25s : %s" % (n, getattr(config, n)))
register_command(List)

14
cerbero/config.py

@ -136,7 +136,7 @@ class Config (object): @@ -136,7 +136,7 @@ class Config (object):
# Map of architectures to the corresponding config file. We
# do this so that we don't need to duplicate arch specific
# config again in the universal config.
for arch, config_file in self.universal_archs.items():
for arch, config_file in list(self.universal_archs.items()):
arch_config[arch] = self._copy(arch)
# Allow the config to detect whether this config is
# running under a universal setup and some
@ -162,7 +162,7 @@ class Config (object): @@ -162,7 +162,7 @@ class Config (object):
self._validate_properties()
self._raw_environ = os.environ.copy()
for config in self.arch_config.values():
for config in list(self.arch_config.values()):
config._restore_environment()
if self.target_arch == Architecture.UNIVERSAL:
config.sources = os.path.join(self.sources, config.target_arch)
@ -179,13 +179,13 @@ class Config (object): @@ -179,13 +179,13 @@ class Config (object):
"prefix, 'gi' variant will be removed"))
self.variants.gi = False
for c in self.arch_config.values():
for c in list(self.arch_config.values()):
c.variants = self.variants
self.do_setup_env()
# Store current os.environ data
for c in self.arch_config.values():
for c in list(self.arch_config.values()):
self._create_path(c.local_sources)
self._create_path(c.sources)
self._create_path(c.logs)
@ -203,7 +203,7 @@ class Config (object): @@ -203,7 +203,7 @@ class Config (object):
self.env = self.get_env(self.prefix, libdir, self.py_prefix)
# set all the variables
for e, v in self.env.iteritems():
for e, v in self.env.items():
os.environ[e] = v
def get_env(self, prefix, libdir, py_prefix):
@ -352,14 +352,14 @@ class Config (object): @@ -352,14 +352,14 @@ class Config (object):
def get_recipes_repos(self):
recipes_dir = {'default': (self.recipes_dir, 0)}
for name, (path, priority) in self.external_recipes.iteritems():
for name, (path, priority) in self.external_recipes.items():
path = os.path.abspath(os.path.expanduser(path))
recipes_dir[name] = (path, priority)
return recipes_dir
def get_packages_repos(self):
packages_dir = {'default': (self.packages_dir, 0)}
for name, (path, priority) in self.external_packages.iteritems():
for name, (path, priority) in self.external_packages.items():
path = os.path.abspath(os.path.expanduser(path))
packages_dir[name] = (path, priority)
return packages_dir

6
cerbero/hacks.py

@ -23,7 +23,7 @@ import sys @@ -23,7 +23,7 @@ import sys
### XML Hacks ###
import re
import StringIO
import io
from xml.dom import minidom
from cerbero.utils import etree
oldwrite = etree.ElementTree.write
@ -39,7 +39,7 @@ def pretify(string, pretty_print=True): @@ -39,7 +39,7 @@ def pretify(string, pretty_print=True):
def write(self, file_or_filename, encoding=None, pretty_print=False):
if not pretty_print:
return oldwrite(self, file_or_filename, encoding)
tmpfile = StringIO.StringIO()
tmpfile = io.StringIO()
oldwrite(self, tmpfile, encoding)
tmpfile.seek(0)
if hasattr(file_or_filename, "write"):
@ -69,7 +69,7 @@ class _Environ(environclass): @@ -69,7 +69,7 @@ class _Environ(environclass):
def __init__(self, environ):
UserDict.UserDict.__init__(self)
self.data = {}
for k, v in environ.items():
for k, v in list(environ.items()):
self.data[k] = v
def __setitem__(self, key, item):

4
cerbero/ide/vs/pkgconfig2vsprops.py

@ -36,7 +36,7 @@ class PkgConfig2VSProps(object): @@ -36,7 +36,7 @@ class PkgConfig2VSProps(object):
if target not in self.generators:
raise FatalError('Target version must be one of %s' %
generators.keys())
list(generators.keys()))
pkgconfig = PkgConfig([libname], False)
requires = pkgconfig.requires()
@ -70,7 +70,7 @@ if __name__ == "__main__": @@ -70,7 +70,7 @@ if __name__ == "__main__":
try:
p2v = PkgConfig2VSProps(args.library, args.c)
p2v.create(args.o)
except Exception, e:
except Exception as e:
import traceback
traceback.print_exc()
m.error(str(e))

4
cerbero/ide/xcode/fwlib.py

@ -148,12 +148,12 @@ class StaticFrameworkLibrary(FrameworkLibrary): @@ -148,12 +148,12 @@ class StaticFrameworkLibrary(FrameworkLibrary):
if len(s) == 4 and s[2] == 'T':
syms[s[3]].append(s)
dups = {}
for k,v in syms.iteritems():
for k,v in syms.items():
if len(v) > 1:
dups[k] = v
if dups:
m.warning ("The static library contains duplicated symbols")
for k, v in dups.iteritems():
for k, v in dups.items():
m.message (k) # symbol name
for l in v:
m.message (" %s" % l[0]) # file

3
cerbero/ide/xcode/xcconfig.py

@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
import sys
from cerbero.ide.pkgconfig import PkgConfig
from functools import reduce
XCCONFIG_TPL = '''
@ -55,7 +56,7 @@ class XCConfig(object): @@ -55,7 +56,7 @@ class XCConfig(object):
if __name__ == "__main__":
if len(sys.argv) < 2:
print "usage: xcconfig output_file libraries"
print("usage: xcconfig output_file libraries")
sys.exit(1)
xcconfig = XCConfig(sys.argv[2:])
xcconfig.create(sys.argv[1])

20
cerbero/main.py

@ -20,9 +20,9 @@ from cerbero import hacks @@ -20,9 +20,9 @@ from cerbero import hacks
try:
import argparse
except ImportError, e:
print "Could not import argparse. Try installing it with "\
"'sudo easy_install argparse"
except ImportError as e:
print("Could not import argparse. Try installing it with "\
"'sudo easy_install argparse")
raise e
import sys
@ -96,28 +96,28 @@ class Main(object): @@ -96,28 +96,28 @@ class Main(object):
try:
self.config = config.Config()
self.config.load(self.args.config)
except ConfigurationError, exc:
except ConfigurationError as exc:
self.log_error(exc, False)
def run_command(self):
command = self.args.command
try:
res = commands.run(command, self.config, self.args)
except UsageError, exc:
except UsageError as exc:
self.log_error(exc, True, command)
sys.exit(1)
except FatalError, exc:
except FatalError as exc:
traceback.print_exc()
self.log_error(exc, True, command)
except BuildStepError, exc:
except BuildStepError as exc:
self.log_error(exc.msg, False, command)
except AbortedError, exc:
except AbortedError as exc:
self.log_error('', False, command)
except CerberoException, exc:
except CerberoException as exc:
self.log_error(exc, False, command)
except KeyboardInterrupt:
self.log_error(_('Interrupted'))
except IOError, e:
except IOError as e:
if e.errno != errno.EPIPE:
raise
sys.exit(0)

2
cerbero/packages/android.py

@ -48,7 +48,7 @@ class AndroidPackager(DistTarball): @@ -48,7 +48,7 @@ class AndroidPackager(DistTarball):
if isinstance(self.config.universal_archs, list):
archs = self.config.universal_archs
elif isinstance(self.config.universal_archs, dict):
archs = self.config.universal_archs.keys()
archs = list(self.config.universal_archs.keys())
else:
raise ConfigurationError('universal_archs must be a list or a dict')

2
cerbero/packages/debian.py

@ -242,7 +242,7 @@ class DebianPackager(LinuxPackager): @@ -242,7 +242,7 @@ class DebianPackager(LinuxPackager):
self._write_debian_file(packagedir, 'control', control + control_devel)
self._write_debian_file(packagedir, 'copyright', copyright)
rules_path = self._write_debian_file(packagedir, 'rules', rules)
os.chmod(rules_path, 0755)
os.chmod(rules_path, 0o755)
self._write_debian_file(packagedir, os.path.join('source', 'format'),
source_format)
if self.package.has_runtime_package:

4
cerbero/packages/linux.py

@ -169,8 +169,8 @@ class LinuxPackager(PackagerBase): @@ -169,8 +169,8 @@ class LinuxPackager(PackagerBase):
licenses = []
recipes_licenses = self.package.recipes_licenses()
recipes_licenses.update(self.package.devel_recipes_licenses())
for recipe_name, categories_licenses in recipes_licenses.iteritems():
for category_licenses in categories_licenses.itervalues():
for recipe_name, categories_licenses in recipes_licenses.items():
for category_licenses in categories_licenses.values():
licenses.extend(category_licenses)
return sorted(list(set(licenses)))

2
cerbero/packages/osx/buildtools.py

@ -54,7 +54,7 @@ class PackageBuild(object): @@ -54,7 +54,7 @@ class PackageBuild(object):
def _cmd_with_args(self, args, output):
args_str = ''
for k, v in args.iteritems():
for k, v in args.items():
args_str += " --%s '%s'" % (k, v)
return '%s %s %s' % (self.CMD, args_str, output)

4
cerbero/packages/osx/bundles.py

@ -149,10 +149,10 @@ class FrameworkBundlePackager(BundlePackagerBase): @@ -149,10 +149,10 @@ class FrameworkBundlePackager(BundlePackagerBase):
links[name] = 'Versions/Current/%s' % name
# Create all links
for dest, src in links.iteritems():
for dest, src in links.items():
shell.call ('ln -s %s %s' % (src, dest), tmp)
inner_tmp = os.path.join(tmp, vdir)
for dest, src in inner_links.iteritems():
for dest, src in inner_links.items():
shell.call ('ln -s %s %s' % (src, dest), inner_tmp)
# Copy the framework library to Versions/$VERSION/$ARCH/Framework

6
cerbero/packages/osx/packager.py

@ -133,7 +133,7 @@ class OSXPackage(PackagerBase, FrameworkHeadersMixin): @@ -133,7 +133,7 @@ class OSXPackage(PackagerBase, FrameworkHeadersMixin):
try:
runtime_path = self._create_package(PackageType.RUNTIME,
output_dir, force)
except EmptyPackageError, e:
except EmptyPackageError as e:
if not devel:
raise e
runtime_path = None
@ -145,7 +145,7 @@ class OSXPackage(PackagerBase, FrameworkHeadersMixin): @@ -145,7 +145,7 @@ class OSXPackage(PackagerBase, FrameworkHeadersMixin):
# create the development package
devel_path = self._create_package(PackageType.DEVEL, output_dir,
force)
except EmptyPackageError, e:
except EmptyPackageError as e:
if runtime_path is None:
raise e
devel_path = None
@ -332,7 +332,7 @@ class ProductPackage(PackagerBase): @@ -332,7 +332,7 @@ class ProductPackage(PackagerBase):
self.empty_packages[PackageType.DEVEL].append(p)
def _create_packages_dmg(self):
paths = self.packages_paths[PackageType.RUNTIME].values()
paths = list(self.packages_paths[PackageType.RUNTIME].values())
dmg_file = os.path.join(self.output_dir,
self._package_name('-packages.dmg'))

16
cerbero/packages/package.py

@ -258,7 +258,7 @@ class Package(PackageBase): @@ -258,7 +258,7 @@ class Package(PackageBase):
def devel_recipes_licenses(self):
licenses = self._list_licenses(self._recipes_files_devel)
for recipe_name, categories in self._recipes_files.iteritems():
for recipe_name, categories in self._recipes_files.items():
# also add development licenses for recipe from which used the
# 'libs' category
if len(categories) == 0 or FilesProvider.LIBS_CAT in categories:
@ -273,7 +273,7 @@ class Package(PackageBase): @@ -273,7 +273,7 @@ class Package(PackageBase):
def files_list(self):
files = []
for recipe_name, categories in self._recipes_files.iteritems():
for recipe_name, categories in self._recipes_files.items():
recipe = self.cookbook.get_recipe(recipe_name)
if len(categories) == 0:
rfiles = recipe.dist_files_list()
@ -284,13 +284,13 @@ class Package(PackageBase): @@ -284,13 +284,13 @@ class Package(PackageBase):
def devel_files_list(self):
files = []
for recipe, categories in self._recipes_files.iteritems():
for recipe, categories in self._recipes_files.items():
# only add development files for recipe from which used the 'libs'
# category
if len(categories) == 0 or FilesProvider.LIBS_CAT in categories:
rfiles = self.cookbook.get_recipe(recipe).devel_files_list()
files.extend(rfiles)
for recipe, categories in self._recipes_files_devel.iteritems():
for recipe, categories in self._recipes_files_devel.items():
recipe = self.cookbook.get_recipe(recipe)
if not categories:
rfiles = recipe.devel_files_list()
@ -308,21 +308,21 @@ class Package(PackageBase): @@ -308,21 +308,21 @@ class Package(PackageBase):
self._recipes_files = {}
for r in self._files:
l = r.split(':')
if self._recipes_files.has_key(l[0]):
if l[0] in self._recipes_files:
self._recipes_files[l[0]] += l[1:]
else:
self._recipes_files[l[0]] = l[1:]
self._recipes_files_devel = {}
for r in self._files_devel:
l = r.split(':')
if self._recipes_files_devel.has_key(l[0]):
if l[0] in self._recipes_files_devel:
self._recipes_files_devel[l[0]] += l[1:]
else:
self._recipes_files_devel[l[0]] = l[1:]
def _list_licenses(self, recipes_files):
licenses = {}
for recipe_name, categories in recipes_files.iteritems():
for recipe_name, categories in recipes_files.items():
r = self.cookbook.get_recipe(recipe_name)
# Package.files|files_devel|platform_files|platform_files_devel = \
# [recipe:category]
@ -555,7 +555,7 @@ class App(Package): @@ -555,7 +555,7 @@ class App(Package):
# Also include all the libraries provided by the recipes we depend
# on.
for recipe in self.cookbook.list_recipe_deps(self.app_recipe):
files.extend(flatten_files_list(recipe.libraries().values()))
files.extend(flatten_files_list(list(recipe.libraries().values())))
files.extend(recipe.files_list_by_category(FilesProvider.PY_CAT))
files.extend(recipe.files_list_by_category(FilesProvider.TYPELIB_CAT))

10
cerbero/packages/packagesstore.py

@ -58,7 +58,7 @@ class PackagesStore (object): @@ -58,7 +58,7 @@ class PackagesStore (object):
@return: list of packages
@rtype: list
'''
packages = self._packages.values()
packages = list(self._packages.values())
packages.sort(key=lambda x: x.name)
return packages
@ -161,7 +161,7 @@ class PackagesStore (object): @@ -161,7 +161,7 @@ class PackagesStore (object):
self._packages = {}
packages = defaultdict(dict)
repos = self._config.get_packages_repos()
for reponame, (repodir, priority) in repos.iteritems():
for reponame, (repodir, priority) in repos.items():
packages[int(priority)].update(
self._load_packages_from_dir(repodir))
# Add recipes by asceding pripority
@ -177,7 +177,7 @@ class PackagesStore (object): @@ -177,7 +177,7 @@ class PackagesStore (object):
m_path = os.path.join(repo, 'custom.py')
if os.path.exists(m_path):
custom = imp.load_source('custom', m_path)
except Exception, ex:
except Exception as ex:
# import traceback
# traceback.print_exc()
# m.warning("Error loading package %s" % ex)
@ -200,7 +200,7 @@ class PackagesStore (object): @@ -200,7 +200,7 @@ class PackagesStore (object):
'Distro': Distro, 'DistroVersion': DistroVersion,
'License': License, 'package': package,
'PackageType': PackageType, 'custom': custom}
execfile(filepath, d)
exec(compile(open(filepath).read(), filepath, 'exec'), d)
if 'Package' in d:
p = d['Package'](self._config, self, self.cookbook)
elif 'SDKPackage' in d:
@ -217,7 +217,7 @@ class PackagesStore (object): @@ -217,7 +217,7 @@ class PackagesStore (object):
# may have changed it
p.load_files()
return p
except Exception, ex:
except Exception as ex:
import traceback
traceback.print_exc()
m.warning("Error loading package %s" % ex)

1
cerbero/packages/rpm.py

@ -26,6 +26,7 @@ from cerbero.packages import PackageType @@ -26,6 +26,7 @@ from cerbero.packages import PackageType
from cerbero.packages.linux import LinuxPackager
from cerbero.packages.package import MetaPackage
from cerbero.utils import shell, _
from functools import reduce
SPEC_TPL = '''

6
cerbero/packages/wix.py

@ -375,7 +375,7 @@ class MSI(WixBase): @@ -375,7 +375,7 @@ class MSI(WixBase):
self.package.packages]
# Remove empty packages
packages = [x for x in packages if x[0] in self.packages_deps.keys()]
packages = [x for x in packages if x[0] in list(self.packages_deps.keys())]
if len(packages) == 0:
raise FatalError("All packages are empty: %s" %
[x[0] for x in self.package.packages])
@ -393,7 +393,7 @@ class MSI(WixBase): @@ -393,7 +393,7 @@ class MSI(WixBase):
required_packages)
# Add a merge module ref for all the packages
for package, path in self.packages_deps.iteritems():
for package, path in self.packages_deps.items():
etree.SubElement(self.installdir, 'Merge',
Id=self._package_id(package.name), Language='1033',
SourceFile=path, DiskId='1')
@ -519,7 +519,7 @@ class MSI(WixBase): @@ -519,7 +519,7 @@ class MSI(WixBase):
mergerefs = [x for x in deps if x in required_packages]
# don't add empty packages
mergerefs = [x for x in mergerefs if x in self.packages_deps.keys()]
mergerefs = [x for x in mergerefs if x in list(self.packages_deps.keys())]
for p in mergerefs:
etree.SubElement(feature, "MergeRef",

4
cerbero/packages/wix_packager.py

@ -159,7 +159,7 @@ class MSIPackager(PackagerBase): @@ -159,7 +159,7 @@ class MSIPackager(PackagerBase):
zipf.close()
if not keep_temp:
for msms in self.merge_modules.values():
for msms in list(self.merge_modules.values()):
for p in msms:
os.remove(p)
@ -192,7 +192,7 @@ class MSIPackager(PackagerBase): @@ -192,7 +192,7 @@ class MSIPackager(PackagerBase):
except EmptyPackageError:
m.warning("Package %s is empty" % package<