From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 39E84158094 for ; Wed, 28 Sep 2022 07:42:59 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1F5EEE07EA; Wed, 28 Sep 2022 07:42:58 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 04F48E076B for ; Wed, 28 Sep 2022 07:42:57 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id BE7C3341005 for ; Wed, 28 Sep 2022 07:42:56 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id E97C65C0 for ; Wed, 28 Sep 2022 07:42:54 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1664350937.c8f5de35cfa59ce7620ed646cce9c9715b0ed72e.vapier@gentoo> Subject: [gentoo-commits] proj/pax-utils:master commit in: / X-VCS-Repository: proj/pax-utils X-VCS-Files: lddtree.py X-VCS-Directories: / X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: c8f5de35cfa59ce7620ed646cce9c9715b0ed72e X-VCS-Branch: master Date: Wed, 28 Sep 2022 07:42:54 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 5d6472cd-5911-489e-9b3f-81d3c919589a X-Archives-Hash: 1d93a3f32d07001ef4e9d8a8a1ca954d commit: c8f5de35cfa59ce7620ed646cce9c9715b0ed72e Author: Mike Frysinger chromium org> AuthorDate: Wed Sep 28 05:46:01 2022 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Wed Sep 28 07:42:17 2022 +0000 URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=c8f5de35 lddtree: switch to f-strings in most places These are a bit more readable than % formatting. Signed-off-by: Mike Frysinger gentoo.org> lddtree.py | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/lddtree.py b/lddtree.py index 349bace..ecb353d 100755 --- a/lddtree.py +++ b/lddtree.py @@ -250,7 +250,7 @@ def ParseLdSoConf(ldso_conf, root='/', debug=False, _first=True): dbg_pfx = '' if _first else ' ' try: - dbg(debug, '%sParseLdSoConf(%s)' % (dbg_pfx, ldso_conf)) + dbg(debug, f"{dbg_pfx}ParseLdSoConf({ldso_conf})") with open(ldso_conf, encoding='utf-8') as f: for line in f.readlines(): line = line.split('#', 1)[0].strip() @@ -262,7 +262,7 @@ def ParseLdSoConf(ldso_conf, root='/', debug=False, _first=True): line = root + line.lstrip('/') else: line = os.path.dirname(ldso_conf) + '/' + line - dbg(debug, '%s glob: %s' % (dbg_pfx, line)) + dbg(debug, dbg_pfx, "glob:", line) # ldconfig in glibc uses glob() which returns entries sorted according # to LC_COLLATE. Further, ldconfig does not reset that but respects # the active env settings (which might be a mistake). Python does not @@ -336,7 +336,7 @@ def CompatibleELFs(elf1, elf2): """ osabis = frozenset([e.header['e_ident']['EI_OSABI'] for e in (elf1, elf2)]) compat_sets = ( - frozenset('ELFOSABI_%s' % x for x in ('NONE', 'SYSV', 'GNU', 'LINUX',)), + frozenset(f"ELFOSABI_{x}" for x in ("NONE", "SYSV", "GNU", "LINUX")), ) return ((len(osabis) == 1 or any(osabis.issubset(x) for x in compat_sets)) and elf1.elfclass == elf2.elfclass and @@ -357,13 +357,13 @@ def FindLib(elf, lib, ldpaths, root='/', debug=False): Returns: Tuple of the full path to the desired library and the real path to it """ - dbg(debug, ' FindLib(%s)' % lib) + dbg(debug, f" FindLib({lib})") for ldpath in ldpaths: path = os.path.join(ldpath, lib) target = readlink(path, root, prefixed=True) if path != target: - dbg(debug, ' checking: %s -> %s' % (path, target)) + dbg(debug, " checking:", path, "->", target) else: dbg(debug, ' checking:', path) @@ -374,7 +374,7 @@ def FindLib(elf, lib, ldpaths, root='/', debug=False): if CompatibleELFs(elf, libelf): return (target, path) except exceptions.ELFError as e: - warn('%s: %s' % (target, e)) + warn(f"{target}: {e}") return (None, None) @@ -429,7 +429,7 @@ def ParseELF(path, root='/', cwd=None, prefix='', 'libs': _all_libs, } - dbg(debug, 'ParseELF(%s)' % path) + dbg(debug, f"ParseELF({path})") with open(path, 'rb') as f: try: @@ -527,7 +527,7 @@ def ParseELF(path, root='/', cwd=None, prefix='', lret = ParseELF(realpath, root, cwd, prefix, ldpaths, display=fullpath, debug=debug, _first=False, _all_libs=_all_libs) except exceptions.ELFError as e: - warn('%s: %s' % (realpath, e)) + warn(f"{realpath}: {e}") _all_libs[lib]['needed'] = lret['needed'] del elf @@ -549,13 +549,14 @@ def _ActionShow(options, elf): if options.list: print(fullpath or lib) else: - print('%s%s => %s' % (' ' * depth, lib, fullpath)) + indent = " " * depth + print(f"{indent}{lib}", "=>", fullpath) new_libs = [] for lib in elf['libs'][lib]['needed']: if lib in chain_libs: if not options.list: - print('%s%s => !!! circular loop !!!' % (' ' * depth, lib)) + print(f"{indent}{lib} => !!! circular loop !!!") continue if options.all or not lib in shown_libs: shown_libs.add(lib) @@ -584,7 +585,7 @@ def _ActionShow(options, elf): if not interp is None: print(interp) else: - print('%s (interpreter => %s)' % (elf['path'], interp)) + print(elf["path"], f"(interpreter => {interp})") for lib in new_libs: _show(lib, 1) @@ -627,7 +628,7 @@ def _ActionCopy(options, elf): raise if options.verbose: - print('%s -> %s' % (src, dst)) + print(src, "->", dst) os.makedirs(os.path.dirname(dst), exist_ok=True) try: @@ -644,7 +645,7 @@ def _ActionCopy(options, elf): if wrapit: if options.verbose: - print('generate wrapper %s' % (dst,)) + print("generate wrapper", dst) if options.libdir: interp = os.path.join(options.libdir, os.path.basename(elf['interp'])) @@ -662,7 +663,7 @@ def _ActionCopy(options, elf): libdata = elf['libs'][lib] path = libdata['realpath'] if path is None: - warn('could not locate library: %s' % lib) + warn("could not locate library:", lib) continue if not options.libdir: uniq_libpaths.add(_StripRoot(os.path.dirname(path))) @@ -838,11 +839,11 @@ def main(argv): _ActionCopy(options, elf) continue ret = 1 - warn('%s: %s' % (p, e)) + warn(f"{p}: {e}") continue except IOError as e: ret = 1 - warn('%s: %s' % (p, e)) + warn(f"{p}: {e}") continue if options.dest is None: @@ -853,7 +854,7 @@ def main(argv): if not matched: if not options.skip_missing: ret = 1 - warn('%s: did not match any paths' % (path,)) + warn(f"{path}: did not match any paths") return ret