From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1499168-garchives=archives.gentoo.org@lists.gentoo.org>
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 A612E15A7D9
	for <garchives@archives.gentoo.org>; Tue, 21 Mar 2023 23:52:48 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id CA360E087A;
	Tue, 21 Mar 2023 23:52:47 +0000 (UTC)
Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (4096 bits))
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id A999BE087A
	for <gentoo-commits@lists.gentoo.org>; Tue, 21 Mar 2023 23:52:47 +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))
	(No client certificate requested)
	by smtp.gentoo.org (Postfix) with ESMTPS id A297C340BBD
	for <gentoo-commits@lists.gentoo.org>; Tue, 21 Mar 2023 23:52:46 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id 4D18D8BC
	for <gentoo-commits@lists.gentoo.org>; Tue, 21 Mar 2023 23:52:44 +0000 (UTC)
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org>
Message-ID: <1679442760.7cd4343393b97ae8684ab53bbdd283e4788bd3b1.sam@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: bin/
X-VCS-Repository: proj/portage
X-VCS-Files: bin/archive-conf bin/binhost-snapshot bin/dispatch-conf bin/ebuild bin/ebuild-ipc.py bin/egencache bin/emerge bin/glsa-check bin/install.py bin/portageq bin/quickpkg bin/xattr-helper.py
X-VCS-Directories: bin/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 7cd4343393b97ae8684ab53bbdd283e4788bd3b1
X-VCS-Branch: master
Date: Tue, 21 Mar 2023 23:52:44 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply
X-Archives-Salt: 6f043f78-2965-4ba2-8425-c07d9ca31bfb
X-Archives-Hash: 4b81239b252f0c31f1e31c43aac4fdeb

commit:     7cd4343393b97ae8684ab53bbdd283e4788bd3b1
Author:     Oskari Pirhonen <xxc3ncoredxx <AT> gmail <DOT> com>
AuthorDate: Mon Mar 20 02:01:37 2023 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Mar 21 23:52:40 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=7cd43433

Convert %-formats to fstrings

Files under bin/

Signed-off-by: Oskari Pirhonen <xxc3ncoredxx <AT> gmail.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 bin/archive-conf     | 10 +++-------
 bin/binhost-snapshot | 10 ++++------
 bin/dispatch-conf    | 36 ++++++++++++++++++++----------------
 bin/ebuild           |  6 +++---
 bin/ebuild-ipc.py    |  8 ++------
 bin/egencache        | 37 ++++++++++++-------------------------
 bin/emerge           |  4 ++--
 bin/glsa-check       |  5 ++---
 bin/install.py       |  3 +--
 bin/portageq         |  8 ++++----
 bin/quickpkg         |  5 ++---
 bin/xattr-helper.py  |  4 ++--
 12 files changed, 57 insertions(+), 79 deletions(-)

diff --git a/bin/archive-conf b/bin/archive-conf
index b2c381bc6..a11677753 100755
--- a/bin/archive-conf
+++ b/bin/archive-conf
@@ -27,8 +27,6 @@ import portage.dispatch_conf
 from portage import os
 from portage.checksum import perform_md5
 
-FIND_EXTANT_CONTENTS = "find %s -name CONTENTS"
-
 MANDATORY_OPTS = ["archive-dir"]
 
 
@@ -45,11 +43,9 @@ def archive_conf():
         args += [conf]
         md5_match_hash[conf] = ""
 
-    # Find all the CONTENT files in VDB_PATH.
-    with os.popen(
-        FIND_EXTANT_CONTENTS
-        % (os.path.join(portage.settings["EROOT"], portage.VDB_PATH))
-    ) as f:
+    # Find all the CONTENTS files in VDB_PATH.
+    eroot_vdb_path = os.path.join(portage.settings["EROOT"], portage.VDB_PATH)
+    with os.popen(f"find {eroot_vdb_path} -type f -name CONTENTS") as f:
         content_files += f.readlines()
 
     # Search for the saved md5 checksum of all the specified config files

diff --git a/bin/binhost-snapshot b/bin/binhost-snapshot
index 05d2f514b..e0ac7c9b9 100755
--- a/bin/binhost-snapshot
+++ b/bin/binhost-snapshot
@@ -92,15 +92,13 @@ def main(argv):
     if os.path.isdir(snapshot_dir):
         parser.error(f"snapshot_dir already exists: '{snapshot_dir}'")
 
+    dirname_ss_dir = os.path.dirname(snapshot_dir)
     try:
-        os.makedirs(os.path.dirname(snapshot_dir))
+        os.makedirs(dirname_ss_dir)
     except OSError:
         pass
-    if not os.path.isdir(os.path.dirname(snapshot_dir)):
-        parser.error(
-            "snapshot_dir parent could not be created: '%s'"
-            % os.path.dirname(snapshot_dir)
-        )
+    if not os.path.isdir(dirname_ss_dir):
+        parser.error(f"snapshot_dir parent could not be created: '{dirname_ss_dir}'")
 
     try:
         os.makedirs(binhost_dir)

diff --git a/bin/dispatch-conf b/bin/dispatch-conf
index e0069d007..3dbfb0ed6 100755
--- a/bin/dispatch-conf
+++ b/bin/dispatch-conf
@@ -48,14 +48,8 @@ from portage.dispatch_conf import (
 from portage.process import find_binary, spawn
 from portage.util import writemsg, writemsg_stdout
 
-FIND_EXTANT_CONFIGS = (
-    "find '%s' %s -name '._cfg????_%s' ! -name '.*~' ! -iname '.*.bak' -print"
-)
 DIFF_CONTENTS = "diff -Nu '%s' '%s'"
 
-if "case-insensitive-fs" in portage.settings.features:
-    FIND_EXTANT_CONFIGS = FIND_EXTANT_CONFIGS.replace("-name '._cfg", "-iname '._cfg")
-
 # We need a secure scratch dir and python does silly verbose errors on the use of tempnam
 oldmask = os.umask(0o077)
 SCRATCH_DIR = None
@@ -160,18 +154,29 @@ class dispatch:
                 continue
 
             basename = "*"
-            find_opts = "-name '.*' -type d -prune -o"
+            find_opts = ["-name", ".*", "-type", "d", "-prune", "-o"]
             if not os.path.isdir(path):
                 path, basename = os.path.split(path)
-                find_opts = "-maxdepth 1"
+                find_opts = ["-maxdepth", "1"]
+            if "case-insensitive-fs" in portage.settings.features:
+                find_opts += ["-iname"]
+            else:
+                find_opts += ["-name"]
+            find_opts += [
+                f"._cfg????_{basename}",
+                "!",
+                "-name",
+                ".*~",
+                "!",
+                "-iname",
+                ".*.bak",
+                "-print",
+            ]
 
             try:
+                # Find existing configs
                 path_list = _unicode_decode(
-                    subprocess.check_output(
-                        portage.util.shlex_split(
-                            FIND_EXTANT_CONFIGS % (path, find_opts, basename)
-                        )
-                    ),
+                    subprocess.check_output(["find", path] + find_opts),
                     errors="strict",
                 ).splitlines()
             except subprocess.CalledProcessError:
@@ -340,7 +345,7 @@ class dispatch:
 
                 print()
                 writemsg_stdout(
-                    ">> (%i of %i) -- %s\n" % (count, len(confs), conf["current"]),
+                    f">> ({count} of {len(confs)}) -- {conf['current']}\n",
                     noiselevel=-1,
                 )
                 print(
@@ -444,8 +449,7 @@ class dispatch:
             os.rename(newconf, curconf)
         except (OSError, os.error) as why:
             writemsg(
-                "dispatch-conf: Error renaming %s to %s: %s; fatal\n"
-                % (newconf, curconf, str(why)),
+                f"dispatch-conf: Error renaming {newconf} to {curconf}: {str(why)}; fatal\n",
                 noiselevel=-1,
             )
             return

diff --git a/bin/ebuild b/bin/ebuild
index 8fccbea89..2fa4e7974 100755
--- a/bin/ebuild
+++ b/bin/ebuild
@@ -376,9 +376,9 @@ try:
             env_filename = os.path.join(tmpsettings["T"], "environment")
             if os.path.exists(env_filename):
                 msg = (
-                    "Existing ${T}/environment for '%s' will be sourced. "
-                    + "Run 'clean' to start with a fresh environment."
-                ) % (tmpsettings["PF"],)
+                    f"Existing ${{T}}/environment for '{tmpsettings['PF']}' will be sourced. "
+                    "Run 'clean' to start with a fresh environment."
+                )
                 msg = textwrap.wrap(msg, 70)
                 for x in msg:
                     portage.writemsg(f">>> {x}\n")

diff --git a/bin/ebuild-ipc.py b/bin/ebuild-ipc.py
index df70850c0..059732eaf 100755
--- a/bin/ebuild-ipc.py
+++ b/bin/ebuild-ipc.py
@@ -163,10 +163,7 @@ try:
         def _timeout_retry_msg(self, start_time, when):
             time_elapsed = time.time() - start_time
             portage.util.writemsg_level(
-                portage.localization._(
-                    "ebuild-ipc timed out %s after %d seconds," + " retrying...\n"
-                )
-                % (when, time_elapsed),
+                f"ebuild-ipc timed out {when} after {time_elapsed} seconds, retrying...\n",
                 level=logging.ERROR,
                 noiselevel=-1,
             )
@@ -290,8 +287,7 @@ try:
 
             if retval != os.EX_OK:
                 portage.util.writemsg_level(
-                    "ebuild-ipc: %s: %s\n"
-                    % (msg, portage.localization._("subprocess failure: %s") % retval),
+                    f"ebuild-ipc: {msg}: subprocess failure: {retval}\n",
                     level=logging.ERROR,
                     noiselevel=-1,
                 )

diff --git a/bin/egencache b/bin/egencache
index 671df3014..dbe8d27fe 100755
--- a/bin/egencache
+++ b/bin/egencache
@@ -345,8 +345,7 @@ try:
                 )
                 if not self._trg_caches:
                     raise Exception(
-                        "cache formats '%s' aren't supported"
-                        % (" ".join(conf.cache_formats),)
+                        f"cache formats '{' '.join(conf.cache_formats)}' aren't supported"
                     )
 
             if rsync:
@@ -615,14 +614,7 @@ try:
                             prefix0 = "M"
 
                         print(
-                            " [%s%s] %s (%s):  %s"
-                            % (
-                                colorize("red", prefix0),
-                                color(prefix1),
-                                colorize("bold", pkg_desc.cp),
-                                color(version[len(pkg_desc.cp) + 1 :]),
-                                pkg_desc.desc,
-                            )
+                            f" [{colorize('red', prefix0)}{color(prefix1)}] {colorize('bold', pkg_desc.cp)} ({color(version[len(pkg_desc.cp) + 1 :])}):  {pkg_desc.desc}"
                         )
                         haspkgs = True
 
@@ -835,8 +827,7 @@ try:
                                     reskeys = {_Atom(k): k for k in resdict}
                                 except portage.exception.InvalidAtom as e:
                                     writemsg_level(
-                                        "ERROR: failed parsing %s/metadata.xml: %s\n"
-                                        % (cp, e),
+                                        f"ERROR: failed parsing {cp}/metadata.xml: {e}\n",
                                         level=logging.ERROR,
                                         noiselevel=-1,
                                     )
@@ -938,13 +929,12 @@ try:
 
             output.write(
                 textwrap.dedent(
-                    """\
-                # ChangeLog for %s
-                # Copyright 1999-%s Gentoo Foundation; Distributed under the GPL v2
+                    f"""\
+                # ChangeLog for {cp}
+                # Copyright 1999-{time.strftime("%Y")} Gentoo Foundation; Distributed under the GPL v2
                 # (auto-generated from git log)
 
                 """
-                    % (cp, time.strftime("%Y"))
                 )
             )
 
@@ -1064,9 +1054,10 @@ try:
                 )
                 # but feel free to break commit messages there
                 self._wrapper.break_on_hyphens = True
-                output.write(
-                    "\n%s\n\n" % "\n".join(self._wrapper.fill(x) for x in body)
-                )
+                # temp var needed because fstrings can not have backslashes in
+                # the expression part...
+                temp_joined = "\n".join(self._wrapper.fill(x) for x in body)
+                output.write(f"\n{temp_joined}\n\n")
 
             output.close()
             os.utime(self._changelog_output, (lmod, lmod))
@@ -1249,12 +1240,8 @@ try:
                         gpg_dir = os.path.expanduser(settings["PORTAGE_GPG_DIR"])
                     if not os.access(gpg_dir, os.X_OK):
                         writemsg_level(
-                            (
-                                "egencache: error: "
-                                "Unable to access directory: "
-                                "PORTAGE_GPG_DIR='%s'\n"
-                            )
-                            % gpg_dir,
+                            "egencache: error: Unable to access directory: "
+                            f"PORTAGE_GPG_DIR='{gpg_dir}'\n",
                             level=logging.ERROR,
                             noiselevel=-1,
                         )

diff --git a/bin/emerge b/bin/emerge
index 804dc0371..f5dbc3106 100755
--- a/bin/emerge
+++ b/bin/emerge
@@ -62,9 +62,9 @@ try:
             sys.exit(e.errno)
         except IsADirectory as e:
             sys.stderr.write(
-                "'%s' is a directory, but should be a file!\n"
+                f"'{str(e)}' is a directory, but should be a file!\n"
                 "See portage man page for information on "
-                "which files may be directories.\n" % str(e)
+                "which files may be directories.\n"
             )
             sys.exit(e.errno)
         except ParseError as e:

diff --git a/bin/glsa-check b/bin/glsa-check
index b18ffdc08..f9b2bf022 100755
--- a/bin/glsa-check
+++ b/bin/glsa-check
@@ -220,8 +220,7 @@ if "affected" in params:
 for p in params[:]:
     if not (p in completelist or os.path.exists(p)):
         sys.stderr.write(
-            "(removing %s from parameter list as it isn't a valid GLSA specification)\n"
-            % p
+            f"(removing {p} from parameter list as it isn't a valid GLSA specification)\n"
         )
         params.remove(p)
 
@@ -261,7 +260,7 @@ def summarylist(myglsalist, fd1=sys.stdout, fd2=sys.stderr, encoding="utf-8"):
             color = green
 
         if verbose:
-            access = "[%-8s] " % myglsa.access
+            access = f"[{myglsa.access:8}] "
         else:
             access = ""
 

diff --git a/bin/install.py b/bin/install.py
index 4bdffd255..3c78dae91 100755
--- a/bin/install.py
+++ b/bin/install.py
@@ -174,8 +174,7 @@ def main(args):
         if returncode != os.EX_OK:
             portage.util.writemsg(
                 "!!! install: copy_xattrs failed with the "
-                "following arguments: %s\n"
-                % " ".join(portage._shell_quote(x) for x in args),
+                f"following arguments: {' '.join(portage._shell_quote(x) for x in args)}\n",
                 noiselevel=-1,
             )
     return returncode

diff --git a/bin/portageq b/bin/portageq
index df2b1a872..93fa4edeb 100755
--- a/bin/portageq
+++ b/bin/portageq
@@ -871,8 +871,8 @@ try:
         for arg in argv:
             if arg in ("PORTDIR", "PORTDIR_OVERLAY", "SYNC"):
                 print(
-                    "WARNING: 'portageq envvar %s' is deprecated. Use any of "
-                    "'get_repos, get_repo_path, repos_config' instead." % arg,
+                    f"WARNING: 'portageq envvar {arg}' is deprecated. Use any of "
+                    "'get_repos, get_repo_path, repos_config' instead.",
                     file=sys.stderr,
                 )
 
@@ -1516,8 +1516,8 @@ try:
                     sys.stderr.write(
                         "ERROR: This version of portageq"
                         " only supports <eroot>s ending in"
-                        " '%s'. The provided <eroot>, '%s',"
-                        " doesn't.\n" % (eprefix, eroot)
+                        f" '{eprefix}'. The provided <eroot>, '{eroot}',"
+                        " doesn't.\n"
                     )
                     sys.stderr.flush()
                     sys.exit(os.EX_USAGE)

diff --git a/bin/quickpkg b/bin/quickpkg
index 1ecc079fe..8443a00e6 100755
--- a/bin/quickpkg
+++ b/bin/quickpkg
@@ -176,8 +176,7 @@ def quickpkg_atom(options, infos, arg, eout):
                 if find_binary(compression_binary) is None:
                     missing_package = compression["package"]
                     eout.eerror(
-                        "File compression unsupported %s. Missing package: %s"
-                        % (binpkg_compression, missing_package)
+                        f"File compression unsupported {binpkg_compression} (missing package: {missing_package})"
                     )
                     return 1
 
@@ -391,7 +390,7 @@ def quickpkg_main(options, args, eout):
         eout.einfo(f"{cpv}: {size_str}")
     if infos["config_files_excluded"]:
         print()
-        eout.ewarn("Excluded config files: %d" % infos["config_files_excluded"])
+        eout.ewarn(f"Excluded config files: {infos['config_files_excluded']}")
         eout.ewarn("See --help if you would like to include config files.")
     if infos["missing"]:
         print()

diff --git a/bin/xattr-helper.py b/bin/xattr-helper.py
index 94c2f6816..acab4920e 100755
--- a/bin/xattr-helper.py
+++ b/bin/xattr-helper.py
@@ -120,13 +120,13 @@ def restore_xattrs(file_in):
             parts = line.split(b"=", 1)
             if len(parts) == 2:
                 if pathname is None:
-                    raise ValueError("line %d: missing pathname" % (i + 1,))
+                    raise ValueError(f"line {i + 1}: missing pathname")
                 attr = unquote(parts[0])
                 # strip trailing newline and quotes
                 value = unquote(parts[1].rstrip(b"\n")[1:-1])
                 xattr.set(pathname, attr, value)
             elif line.strip():
-                raise ValueError("line %d: malformed entry" % (i + 1,))
+                raise ValueError(f"line {i + 1}: malformed entry")
 
 
 def main(argv):