aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@chromium.org>2024-01-02 12:46:55 -0500
committerMike Frysinger <vapier@gentoo.org>2024-01-02 12:46:55 -0500
commitcf84a6c35151b790ec104892883e85010ca252ac (patch)
tree3e4ec1a381c8bda33e7b5c296470c17983651ba2
parentgithub: update to checkout@v4 (diff)
downloadpax-utils-cf84a6c35151b790ec104892883e85010ca252ac.tar.gz
pax-utils-cf84a6c35151b790ec104892883e85010ca252ac.tar.bz2
pax-utils-cf84a6c35151b790ec104892883e85010ca252ac.zip
lddtree: use older Python typing style
Support for list[...] is new to Python 3.9. We still support Python 3.6 (or at least, 3.8) so we need to use List[...] instead. Signed-off-by: Mike Frysinger <vapier@chromium.org> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rwxr-xr-xlddtree.py24
1 files changed, 12 insertions, 12 deletions
diff --git a/lddtree.py b/lddtree.py
index 89733be..247e9db 100755
--- a/lddtree.py
+++ b/lddtree.py
@@ -49,7 +49,7 @@ import os
import re
import shutil
import sys
-from typing import Any, cast, Iterable, Optional, Union
+from typing import Any, Dict, Iterable, List, Optional, Tuple, Union, cast
assert sys.version_info >= (3, 6), f"Python 3.6+ required, but found {sys.version}"
@@ -126,9 +126,9 @@ def readlink(path: str, root: str, prefixed: Optional[bool] = False) -> str:
return normpath((root + path) if prefixed else path)
-def dedupe(items: list[str]) -> list[str]:
+def dedupe(items: List[str]) -> List[str]:
"""Remove all duplicates from |items| (keeping order)"""
- seen: dict[str, str] = {}
+ seen: Dict[str, str] = {}
return [seen.setdefault(x, x) for x in items if x not in seen]
@@ -229,7 +229,7 @@ def ParseLdPaths(
root: str = "",
cwd: Optional[str] = None,
path: str = "",
-) -> list[str]:
+) -> List[str]:
"""Parse the colon-delimited list of paths and apply ldso rules to each
Note the special handling as dictated by the ldso:
@@ -276,7 +276,7 @@ def ParseLdSoConf(
root: str = "/",
debug: bool = False,
_first: bool = True,
-) -> list[str]:
+) -> List[str]:
"""Load all the paths from a given ldso config file
This should handle comments, whitespace, and "include" statements.
@@ -334,7 +334,7 @@ def LoadLdpaths(
cwd: Optional[str] = None,
prefix: str = "",
debug: bool = False,
-) -> dict[str, list[str]]:
+) -> Dict[str, List[str]]:
"""Load linker paths from common locations
This parses the ld.so.conf and LD_LIBRARY_PATH env var.
@@ -348,7 +348,7 @@ def LoadLdpaths(
Returns:
dict containing library paths to search
"""
- ldpaths: dict[str, list[str]] = {
+ ldpaths: Dict[str, List[str]] = {
"conf": [],
"env": [],
"interp": [],
@@ -401,10 +401,10 @@ def CompatibleELFs(elf1: ELFFile, elf2: ELFFile) -> bool:
def FindLib(
elf: ELFFile,
lib: str,
- ldpaths: list[str],
+ ldpaths: List[str],
root: str = "/",
debug: bool = False,
-) -> tuple[Optional[str], Optional[str]]:
+) -> Tuple[Optional[str], Optional[str]]:
"""Try to locate a |lib| that is compatible to |elf| in the given |ldpaths|
Args:
@@ -451,7 +451,7 @@ def ParseELF(
debug: bool = False,
_first: bool = True,
_all_libs={},
-) -> dict[str, Any]:
+) -> Dict[str, Any]:
"""Parse the ELF dependency tree of the specified file
Args:
@@ -658,7 +658,7 @@ def _ActionShow(options: argparse.Namespace, elf: dict):
shown_libs = set(elf["needed"])
new_libs = elf["needed"][:]
- chain_libs: list[str] = []
+ chain_libs: List[str] = []
interp = elf["interp"]
if interp:
lib = os.path.basename(interp)
@@ -916,7 +916,7 @@ def GetParser() -> argparse.ArgumentParser:
return parser
-def main(argv: list[str]) -> Optional[int]:
+def main(argv: List[str]) -> Optional[int]:
"""The main entry point!"""
parser = GetParser()
options = parser.parse_args(argv)