aboutsummaryrefslogtreecommitdiffstats
path: root/build_scripts/utils.py
diff options
context:
space:
mode:
authorCristián Maureira-Fredes <Cristian.Maureira-Fredes@qt.io>2022-06-27 23:33:10 +0200
committerCristián Maureira-Fredes <cristian.maureira-fredes@qt.io>2022-06-29 11:01:58 +0200
commit39b38b0cfc81d352c60c44efeb890b10c3e1bc88 (patch)
treea7777082b293a490f73fd49f72820b1dd3fda4a9 /build_scripts/utils.py
parenteba195611ac30fd490e87a03238060eca05f2073 (diff)
build: fix readability details
Removing some leftover common anti-patterns: - remove unnecessary dict() usage - remove unnecessary map() - avoid index-based loops - use capitalize() instead of index-based capitalization - use f-strings for concatenation Pick-to: 6.2 6.3 Change-Id: I0ffdf73ec47c6ef537789015052dea0fd047350d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'build_scripts/utils.py')
-rw-r--r--build_scripts/utils.py14
1 files changed, 6 insertions, 8 deletions
diff --git a/build_scripts/utils.py b/build_scripts/utils.py
index 532fd8576..a1b37c93a 100644
--- a/build_scripts/utils.py
+++ b/build_scripts/utils.py
@@ -109,7 +109,7 @@ def winsdk_setenv(platform_arch, build_type):
setenv_env = get_environment_from_batch_command(setenv_cmd)
_setenv_paths = [setenv_env[k] for k in setenv_env if k.upper() == 'PATH']
setenv_env_paths = os.pathsep.join(_setenv_paths).split(os.pathsep)
- setenv_env_without_paths = dict([(k, setenv_env[k]) for k in setenv_env if k.upper() != 'PATH'])
+ setenv_env_without_paths = {k: setenv_env[k] for k in setenv_env if k.upper() != 'PATH'}
# Extend os.environ with SDK env
log.info("Initializing Windows SDK env...")
@@ -203,7 +203,7 @@ def init_msvc_env(platform_arch, build_type):
msvc_env = get_environment_from_batch_command(vcvars_cmd)
_msvc_paths = [msvc_env[k] for k in msvc_env if k.upper() == 'PATH']
msvc_env_paths = os.pathsep.join(_msvc_paths).split(os.pathsep)
- msvc_env_without_paths = dict([(k, msvc_env[k]) for k in msvc_env if k.upper() != 'PATH'])
+ msvc_env_without_paths = {k: msvc_env[k] for k in msvc_env if k.upper() != 'PATH'}
# Extend os.environ with MSVC env
log.info("Initializing MSVC env...")
@@ -305,11 +305,9 @@ def copydir(src, dst, _filter=None, ignore=None, force=True, recursive=True, _va
src = src.format(**_vars)
dst = dst.format(**_vars)
if _filter is not None:
- for i in range(len(_filter)):
- _filter[i] = _filter[i].format(**_vars)
+ _filter = [i.format(**_vars) for i in _filter]
if ignore is not None:
- for i in range(len(ignore)):
- ignore[i] = ignore[i].format(**_vars)
+ ignore = [i.format(**_vars) for i in ignore]
if not os.path.exists(src) and not force:
log.info(f"**Skipping copy tree\n {src} to\n {dst}\n Source does not exist. "
@@ -444,12 +442,12 @@ def get_environment_from_batch_command(env_cmd, initial=None):
# parse the output sent to stdout
lines = proc.stdout
# make sure the lines are strings
- lines = map(lambda s: s.decode(), lines)
+ lines = [s.decode() for s in lines]
# consume whatever output occurs until the tag is reached
consume(itertools.takewhile(lambda l: tag not in l, lines))
# define a way to handle each KEY=VALUE line
# parse key/values into pairs
- pairs = map(lambda l: l.rstrip().split('=', 1), lines)
+ pairs = [l.rstrip().split('=', 1) for l in lines]
# make sure the pairs are valid
valid_pairs = filter(validate_pair, pairs)
# construct a dictionary of the pairs