aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrik Teivonen <patrik.teivonen@qt.io>2023-02-20 11:28:58 +0200
committerPatrik Teivonen <patrik.teivonen@qt.io>2023-02-22 09:57:51 +0000
commitde23418413dd565d16e03942514ef590a191eb89 (patch)
tree53f7d4f5d50ade6132c09197c2970b58c41901d9
parentaf432beadd292121136fb176a01d5de1c0723eae (diff)
Pylint: Enable R0911, R0916, R1702, reduce number of nested blocks
Enable additional passing checks: R0911, R0916 Fix too-many-nested-blocks and enable: R1702 Change-Id: If6853425a2b3a62409f6512cea585fca4d88eb03 Reviewed-by: Antti Kokko <antti.kokko@qt.io>
-rw-r--r--.pre-commit-config.yaml4
-rw-r--r--packaging-tools/bldinstallercommon.py49
-rw-r--r--packaging-tools/dump_debug_infos.py25
3 files changed, 40 insertions, 38 deletions
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index c7a9666eb..aa01cd773 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -36,12 +36,12 @@ repos:
# Disabled:
# Missing docstrings: C0114,C0115,C0116
# Line too long: C0301
- # Need refactoring: C0302,R0201,R0902,R0903,R0911,R0912,R0913,R0914,R0915,R0916,R1702
+ # Need refactoring: C0302,R0201,R0902,R0903,R0912,R0913,R0914,R0915
# Duplicate code: R0801
# TODO comments: W0511
# Too general exceptions: W0703
# Checkers removed in some newer versions of pylint: R0022
- entry: pipenv run python3 -m pylint -j 0 --disable=C0114,C0115,C0116,C0301,C0302,R0201,R0801,R0902,R0903,R0911,R0912,R0913,R0914,R0915,R0916,R1702,W0511,W0703,R0022
+ entry: pipenv run python3 -m pylint -j 0 --disable=C0114,C0115,C0116,C0301,C0302,R0201,R0801,R0902,R0903,R0912,R0913,R0914,R0915,W0511,W0703,R0022
language: system
types: [python]
fail_fast: true
diff --git a/packaging-tools/bldinstallercommon.py b/packaging-tools/bldinstallercommon.py
index 05b0891ce..d194eda06 100644
--- a/packaging-tools/bldinstallercommon.py
+++ b/packaging-tools/bldinstallercommon.py
@@ -490,30 +490,31 @@ def handle_component_rpath(component_root_path: str, destination_lib_paths: str)
for name in files:
file_full_path = os.path.join(root, name)
if not os.path.isdir(file_full_path) and not os.path.islink(file_full_path):
- if requires_rpath(file_full_path):
- rpaths = []
- for destination_lib_path in destination_lib_paths.split(':'):
- dst = os.path.normpath(component_root_path + os.sep + destination_lib_path)
- rpath = calculate_rpath(file_full_path, dst)
- rpaths.append(rpath)
-
- # look for existing $ORIGIN path in the binary
- origin_rpath = None
- with suppress(CalledProcessError):
- output = run_cmd(cmd=["chrpath", "-l", file_full_path])
- origin_rpath = re.search(r"\$ORIGIN[^:\n]*", output)
-
- if origin_rpath is not None:
- if origin_rpath.group() not in rpaths:
- rpaths.append(origin_rpath.group())
-
- rpath = ':'.join(rpaths)
- if sanity_check_rpath_max_length(file_full_path, rpath):
- log.debug("RPath value: [%s] for file: [%s]", rpath, file_full_path)
- cmd_args = ['chrpath', '-r', rpath, file_full_path]
- # force silent operation
- work_dir = os.path.dirname(os.path.realpath(__file__))
- run_cmd(cmd=cmd_args, cwd=work_dir)
+ if not requires_rpath(file_full_path):
+ continue
+ rpaths = []
+ for destination_lib_path in destination_lib_paths.split(':'):
+ dst = os.path.normpath(component_root_path + os.sep + destination_lib_path)
+ rpath = calculate_rpath(file_full_path, dst)
+ rpaths.append(rpath)
+
+ # look for existing $ORIGIN path in the binary
+ origin_rpath = None
+ with suppress(CalledProcessError):
+ output = run_cmd(cmd=["chrpath", "-l", file_full_path])
+ origin_rpath = re.search(r"\$ORIGIN[^:\n]*", output)
+
+ if origin_rpath is not None:
+ if origin_rpath.group() not in rpaths:
+ rpaths.append(origin_rpath.group())
+
+ rpath = ':'.join(rpaths)
+ if sanity_check_rpath_max_length(file_full_path, rpath):
+ log.debug("RPath value: [%s] for file: [%s]", rpath, file_full_path)
+ cmd_args = ['chrpath', '-r', rpath, file_full_path]
+ # force silent operation
+ work_dir = os.path.dirname(os.path.realpath(__file__))
+ run_cmd(cmd=cmd_args, cwd=work_dir)
###############################
diff --git a/packaging-tools/dump_debug_infos.py b/packaging-tools/dump_debug_infos.py
index 7f35174b8..e51be9f02 100644
--- a/packaging-tools/dump_debug_infos.py
+++ b/packaging-tools/dump_debug_infos.py
@@ -110,20 +110,21 @@ def dump_syms(
for root, _, filenames in os.walk(search_path):
for filename in filenames:
absolute_path = os.path.join(root, filename).replace("\\", "/")
- if is_file_with_debug_information(absolute_path):
- base_path = str(Path(absolute_path).with_suffix(""))
- start_slash = 1
- sym_path_base = base_path[start_slash + len(search_path):].replace(os.sep, "_")
- sym_filename = f"{sym_path_base}.sym"
+ if not is_file_with_debug_information(absolute_path):
+ continue
+ base_path = str(Path(absolute_path).with_suffix(""))
+ start_slash = 1
+ sym_path_base = base_path[start_slash + len(search_path):].replace(os.sep, "_")
+ sym_filename = f"{sym_path_base}.sym"
+ sym_path = os.path.join(output_path, sym_filename)
+ if dump_sym(dump_syms_path, architectures[0], absolute_path, sym_path, verbose):
+ sym_filenames.append(sym_filename)
+ if len(architectures) == 2:
+ arch_argument_len = len("--arch ")
+ sym_filename = f"{sym_path_base}_{architectures[1][arch_argument_len:]}.sym"
sym_path = os.path.join(output_path, sym_filename)
- if dump_sym(dump_syms_path, architectures[0], absolute_path, sym_path, verbose):
+ if dump_sym(dump_syms_path, architectures[1], absolute_path, sym_path, verbose):
sym_filenames.append(sym_filename)
- if len(architectures) == 2:
- arch_argument_len = len("--arch ")
- sym_filename = f"{sym_path_base}_{architectures[1][arch_argument_len:]}.sym"
- sym_path = os.path.join(output_path, sym_filename)
- if dump_sym(dump_syms_path, architectures[1], absolute_path, sym_path, verbose):
- sym_filenames.append(sym_filename)
return sym_filenames