Basic 2to3 fixes

This commit is contained in:
Alexander van Gessel 2017-09-20 15:04:50 +02:00 committed by loonycyborg
parent 51f250ca8e
commit 6af2eb00df
9 changed files with 33 additions and 27 deletions

View file

@ -18,7 +18,7 @@ from os import access, F_OK
AddOption('--option-cache', dest='option_cache', nargs=1, type = 'string', action = 'store', metavar = 'FILE', help='file with cached construction variables', default = '.scons-option-cache')
if os.path.exists(GetOption("option_cache")):
optfile = file(GetOption("option_cache"))
print "Saved options:", optfile.read().replace("\n", ", ")[:-2]
print("Saved options:", optfile.read().replace("\n", ", ")[:-2])
optfile.close()
#
@ -29,9 +29,9 @@ config_h_re = re.compile(r"^.*#define\s*(\S*)\s*\"(\S*)\".*$", re.MULTILINE)
build_config = dict( config_h_re.findall(File("src/wesconfig.h").get_contents()) )
try:
version = build_config["VERSION"]
print "Building Wesnoth version %s" % version
print("Building Wesnoth version %s" % version)
except KeyError:
print "Couldn't determine the Wesnoth version number, bailing out!"
print("Couldn't determine the Wesnoth version number, bailing out!")
sys.exit(1)
#
@ -117,7 +117,7 @@ sys.path = toolpath + sys.path
env = Environment(tools=["tar", "gettext", "install", "python_devel", "scanreplace"], options = opts, toolpath = toolpath)
if env["lockfile"]:
print "Creating lockfile"
print("Creating lockfile")
lockfile = os.path.abspath("scons.lock")
open(lockfile, "wx").write(str(os.getpid()))
import atexit
@ -231,7 +231,7 @@ if env["fast"]:
SetOption('implicit_cache', 1)
if not os.path.isabs(env["prefix"]):
print "Warning: prefix is set to relative dir. destdir setting will be ignored."
print("Warning: prefix is set to relative dir. destdir setting will be ignored.")
env["destdir"] = ""
#
@ -278,9 +278,14 @@ if sys.platform == 'win32':
#
# Check some preconditions
#
print("---[checking prerequisites]---")
def Info(message):
print("INFO: " + message)
return True
def Warning(message):
print message
print("WARNING: " + message)
return False
from metasconf import init_metasconf
@ -398,8 +403,8 @@ if env["prereqs"]:
if not have_test_prereqs and "test" in env["default_targets"]:
env["default_targets"].remove("test")
print env.subst("If any config checks fail, look in $build_dir/config.log for details")
print "If a check fails spuriously due to caching, use --config=force to force its rerun"
print(" " + env.subst("If any config checks fail, look in $build_dir/config.log for details"))
print(" If a check fails spuriously due to caching, use --config=force to force its rerun")
else:
have_client_prereqs = True
@ -420,13 +425,14 @@ have_msgfmt = env["MSGFMT"]
if not have_msgfmt:
env["nls"] = False
if not have_msgfmt:
print "NLS tools are not present..."
print("NLS tools are not present...")
if not env['nls']:
print "NLS catalogue installation is disabled."
print("NLS catalogue installation is disabled.")
#
# Implement configuration switches
#
print("---[applying configuration]---")
for env in [test_env, client_env, env]:
build_root="#/"
@ -587,8 +593,8 @@ if have_client_prereqs and have_X and env["desktop_entry"]:
env.InstallData("desktopdir", "wesnoth", "icons/wesnoth.desktop")
# Python tools
env.InstallData("bindir", "pytools", map(lambda tool: os.path.join("data", "tools", tool), pythontools))
env.InstallData("python_site_packages_dir", "pytools", map(lambda module: os.path.join("data", "tools", "wesnoth", module), pythonmodules))
env.InstallData("bindir", "pytools", [os.path.join("data", "tools", tool) for tool in pythontools])
env.InstallData("python_site_packages_dir", "pytools", [os.path.join("data", "tools", "wesnoth", module) for module in pythonmodules])
# Wesnoth MP server install
env.InstallBinary(wesnothd)
@ -596,7 +602,7 @@ InstallManpages(env, "wesnothd")
if not access(fifodir, F_OK):
fifodir = env.Command(fifodir, [], [
Mkdir(fifodir),
Chmod(fifodir, 0700),
Chmod(fifodir, 0o700),
Action("chown %s:%s %s" %
(env["server_uid"], env["server_gid"], fifodir)),
])

View file

@ -28,7 +28,7 @@ def find_boost(env):
versions.append(map(int, re.findall(r"^boost-(\d*)_(\d*)$", basename(dirname(dirname(includefile))))[0]))
except IndexError:
versions.append((0,0))
version_nums = map(lambda (major, minor): 100000 * major + 100 * minor, versions)
version_nums = [100000 * major_minor[0] + 100 * major_minor[1] for major_minor in versions]
include_index = version_nums.index(max(version_nums))
prefix, includefile = includes[include_index]
version = versions[include_index]

View file

@ -29,6 +29,6 @@ def generate(env):
'CCACHE_HASHDIR',
'CCACHE_UNIFY',
'CCACHE_EXTENSION']:
if os.environ.has_key(i) and not env.has_key(i):
if i in os.environ and i not in env:
env['ENV'][i] = os.environ[i]

View file

@ -19,7 +19,7 @@ def setup_cross_compile(env):
"RC"
]
for tool in tools:
if env.has_key(tool):
if tool in env:
env[tool] = env["host"] + "-" + env[tool]
env.PrependUnique(CPPPATH="$prefix/include", LIBPATH="$prefix/lib")

View file

@ -8,7 +8,7 @@ def exists():
return True
def generate(env):
print env["ENV"]["PATH"]
print(env["ENV"]["PATH"])
env['DISTCC'] = env.WhereIs("distcc")
env['CC'] = '$DISTCC %s' % env['CC']
env['CXX'] = '$DISTCC %s' % env['CXX']
@ -22,5 +22,5 @@ def generate(env):
'DISTCC_TCP_CORK',
'DISTCC_SSH'
]:
if os.environ.has_key(i) and not env.has_key(i):
if i in os.environ and i not in env:
env['ENV'][i] = os.environ[i]

View file

@ -8,18 +8,18 @@ def InstallFilteredHook(target, source, env):
target = Flatten(target)
source = Flatten(source)
if(len(target) != len(source)):
raise ValueError, "Number of targets doesn't match number of sources"
raise ValueError("Number of targets doesn't match number of sources")
def do_copy(target, source):
if CopyFilter(source):
if os.path.isfile(source):
if env["verbose"]:
print "cp %s %s" % (source, target)
print("cp %s %s" % (source, target))
shutil.copy2(source, target)
else:
if not os.path.exists(target):
if env["verbose"]:
print "Make directory", target
print("Make directory", target)
os.makedirs(target)
for file in os.listdir(source):
do_copy(os.path.join(target, file), os.path.join(source, file))
@ -31,7 +31,7 @@ def InstallFilteredHook(target, source, env):
os.makedirs(target_path)
for d in (target_path, source_path):
if not os.path.isdir(d):
raise ValueError, "%s is not a directory" % d
raise ValueError("%s is not a directory" % d)
do_copy(target_path, source_path)
from SCons.Action import ActionFactory
@ -42,7 +42,7 @@ def hard_link(dest, src, symlink = False):
os.symlink(src, dest)
else:
os.link(src, dest)
except OSError, e:
except OSError as e:
if e.errno == 18:
hard_link(dest, src, True)
else:
@ -79,7 +79,7 @@ def InstallData(env, datadir, component, source, subdir = ""):
if len(dirs) == 1:
install = env.InstallFiltered(installdir.path, dirs[0].path)
else:
install = map(lambda x : env.InstallFiltered(os.path.join(installdir.path, x.name), x.path), dirs)
install = [env.InstallFiltered(os.path.join(installdir.path, x.name), x.path) for x in dirs]
AlwaysBuild(install)
env.Alias("install-" + component, install)

View file

@ -553,7 +553,7 @@ libwesnoth_extras.extend(SConscript("lua/SConscript"))
def error_action(target, source, env):
from SCons.Errors import UserError
raise UserError, "Target disabled because its prerequisites are not met"
raise UserError("Target disabled because its prerequisites are not met")
def WesnothProgram(env, target, source, can_build, **kw):
if can_build:

View file

@ -1,4 +1,4 @@
import sys
from subprocess import call
print "scons --directory=.. " + " ".join(sys.argv[1:])
print("scons --directory=.. " + " ".join(sys.argv[1:]))
Exit(call(Split("scons --directory=..") + sys.argv[1:]))

View file

@ -1,4 +1,4 @@
import sys
from subprocess import call
print "scons --directory=../.. " + " ".join(sys.argv[1:])
print("scons --directory=../.. " + " ".join(sys.argv[1:]))
Exit(call(Split("scons --directory=../..") + sys.argv[1:]))