From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-1382592-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 41CF515808B
	for <garchives@archives.gentoo.org>; Mon,  4 Apr 2022 19:05:05 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 4EB48E0895;
	Mon,  4 Apr 2022 19:05:01 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.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) server-digest SHA256)
	(No client certificate requested)
	by pigeon.gentoo.org (Postfix) with ESMTPS id C62EBE07B3
	for <gentoo-commits@lists.gentoo.org>; Mon,  4 Apr 2022 19:05:00 +0000 (UTC)
Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84])
	(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 80B1B34128E
	for <gentoo-commits@lists.gentoo.org>; Mon,  4 Apr 2022 19:04:59 +0000 (UTC)
Received: from localhost.localdomain (localhost [IPv6:::1])
	by oystercatcher.gentoo.org (Postfix) with ESMTP id CC2842D7
	for <gentoo-commits@lists.gentoo.org>; Mon,  4 Apr 2022 19:04:57 +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: <1649099072.231d7d26c9076a8a88eddbf048437d46ed46a7ed.sam@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/
X-VCS-Repository: proj/portage
X-VCS-Files: lib/portage/manifest.py lib/portage/metadata.py lib/portage/module.py lib/portage/news.py
X-VCS-Directories: lib/portage/
X-VCS-Committer: sam
X-VCS-Committer-Name: Sam James
X-VCS-Revision: 231d7d26c9076a8a88eddbf048437d46ed46a7ed
X-VCS-Branch: master
Date: Mon,  4 Apr 2022 19:04:57 +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: 6faab268-97e3-4769-9f1e-573d54f73a13
X-Archives-Hash: 402a06721b6d58f7d373b919238fff89

commit:     231d7d26c9076a8a88eddbf048437d46ed46a7ed
Author:     Kenneth Raplee <kenrap <AT> kennethraplee <DOT> com>
AuthorDate: Sat Apr  2 01:04:55 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Apr  4 19:04:32 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=231d7d26

Use String Interpolation where possible

Signed-off-by: Kenneth Raplee <kenrap <AT> kennethraplee.com>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 lib/portage/manifest.py | 17 ++++++++--------
 lib/portage/metadata.py | 19 +++++++++---------
 lib/portage/module.py   | 53 +++++++++++++++++++------------------------------
 lib/portage/news.py     | 31 +++++++++++++----------------
 4 files changed, 52 insertions(+), 68 deletions(-)

diff --git a/lib/portage/manifest.py b/lib/portage/manifest.py
index 0b4fad76c..5472e8fb1 100644
--- a/lib/portage/manifest.py
+++ b/lib/portage/manifest.py
@@ -352,7 +352,7 @@ class Manifest:
                     # non-empty for all currently known use cases.
                     write_atomic(
                         self.getFullname(),
-                        "".join("%s\n" % str(myentry) for myentry in myentries),
+                        "".join(f"{myentry}\n" for myentry in myentries),
                     )
                     self._apply_max_mtime(preserved_stats, myentries)
                     rval = True
@@ -447,8 +447,7 @@ class Manifest:
                     # unless this repo is being prepared for distribution
                     # via rsync.
                     writemsg_level(
-                        "!!! utime('%s', (%s, %s)): %s\n"
-                        % (path, max_mtime, max_mtime, e),
+                        f"!!! utime('{path}', ({max_mtime}, {max_mtime})): {e}\n",
                         level=logging.WARNING,
                         noiselevel=-1,
                     )
@@ -590,12 +589,12 @@ class Manifest:
             return None
         pf = filename[:-7]
         ps = portage.versions._pkgsplit(pf)
-        cpv = "%s/%s" % (cat, pf)
+        cpv = f"{cat}/{pf}"
         if not ps:
-            raise PortagePackageException(_("Invalid package name: '%s'") % cpv)
+            raise PortagePackageException(_(f"Invalid package name: '{cpv}'"))
         if ps[0] != pn:
             raise PortagePackageException(
-                _("Package name does not " "match directory name: '%s'") % cpv
+                _(f"Package name does not match directory name: '{cpv}'")
             )
         return cpv
 
@@ -635,7 +634,7 @@ class Manifest:
             else:
                 continue
             self.fhashdict[mytype][f] = perform_multiple_checksums(
-                self.pkgdir + f, self.hashes
+                f"{self.pkgdir}{f}", self.hashes
             )
         recursive_files = []
 
@@ -693,7 +692,7 @@ class Manifest:
         except FileNotFound as e:
             if not ignoreMissing:
                 raise
-            return False, _("File Not Found: '%s'") % str(e)
+            return False, _(f"File Not Found: '{e}'")
 
     def checkCpvHashes(
         self, cpv, checkDistfiles=True, onlyDistfiles=False, checkMiscfiles=False
@@ -704,7 +703,7 @@ class Manifest:
             self.checkTypeHashes("AUX", ignoreMissingFiles=False)
             if checkMiscfiles:
                 self.checkTypeHashes("MISC", ignoreMissingFiles=False)
-            ebuildname = "%s.ebuild" % self._catsplit(cpv)[1]
+            ebuildname = f"{self._catsplit(cpv)[1]}.ebuild"
             self.checkFileHashes("EBUILD", ebuildname, ignoreMissing=False)
         if checkDistfiles or onlyDistfiles:
             for f in self._getCpvDistfiles(cpv):

diff --git a/lib/portage/metadata.py b/lib/portage/metadata.py
index 0bd2bcce4..357917051 100644
--- a/lib/portage/metadata.py
+++ b/lib/portage/metadata.py
@@ -38,12 +38,11 @@ def action_metadata(settings, portdb, myopts, porttrees=None):
         "/var",
     ]:
         print(
-            "!!! PORTAGE_DEPCACHEDIR IS SET TO A PRIMARY "
-            + "ROOT DIRECTORY ON YOUR SYSTEM.",
-            file=sys.stderr,
-        )
-        print(
-            "!!! This is ALMOST CERTAINLY NOT what you want: '%s'" % cachedir,
+            (
+                "!!! PORTAGE_DEPCACHEDIR IS SET TO A PRIMARY "
+                "ROOT DIRECTORY ON YOUR SYSTEM.\n"
+                f"!!! This is ALMOST CERTAINLY NOT what you want: '{cachedir}'",
+            ),
             file=sys.stderr,
         )
         sys.exit(73)
@@ -123,7 +122,7 @@ def action_metadata(settings, portdb, myopts, porttrees=None):
 
             src_chf = tree_data.src_db.validation_chf
             dest_chf = tree_data.dest_db.validation_chf
-            dest_chf_key = "_%s_" % dest_chf
+            dest_chf_key = f"_{dest_chf}_"
             dest_chf_getter = operator.attrgetter(dest_chf)
 
             for cpv in portdb.cp_list(cp, mytree=tree_data.path):
@@ -219,8 +218,10 @@ def action_metadata(settings, portdb, myopts, porttrees=None):
             dead_nodes = set(tree_data.dest_db)
         except CacheError as e:
             writemsg_level(
-                "Error listing cache entries for "
-                + "'%s': %s, continuing...\n" % (tree_data.path, e),
+                (
+                    "Error listing cache entries for "
+                    f"'{tree_data.path}': {e}, continuing...\n"
+                ),
                 level=logging.ERROR,
                 noiselevel=-1,
             )

diff --git a/lib/portage/module.py b/lib/portage/module.py
index a30d509ee..61c85aa47 100644
--- a/lib/portage/module.py
+++ b/lib/portage/module.py
@@ -53,12 +53,13 @@ class Module:
                 kid["module_name"] = ".".join([mod_name, kid["sourcefile"]])
             except KeyError:
                 kid["module_name"] = ".".join([mod_name, self.name])
-                msg = (
-                    "%s module's module_spec is old, missing attribute: "
-                    "'sourcefile'.  Backward compatibility may be "
-                    "removed in the future.\nFile: %s\n"
+                writemsg(
+                    _(
+                        f"{self.name} module's module_spec is old, missing attribute: "
+                        "'sourcefile'.  Backward compatibility may be "
+                        f"removed in the future.\nFile: {self._module.__file__}\n"
+                    )
                 )
-                writemsg(_(msg) % (self.name, self._module.__file__))
             kid["is_imported"] = False
             self.kids[kidname] = kid
             self.kids_names.append(kidname)
@@ -67,8 +68,10 @@ class Module:
     def get_class(self, name):
         if not name or name not in self.kids_names:
             raise InvalidModuleName(
-                "Module name '%s' is invalid or not" % name
-                + "part of the module '%s'" % self.name
+                (
+                    f"Module name '{name}' is invalid or not"
+                    f"part of the module '{self.name}'"
+                )
             )
         kid = self.kids[name]
         if kid["is_imported"]:
@@ -149,9 +152,7 @@ class Modules:
         if modname and modname in self.module_names:
             mod = self._modules[modname]["parent"].get_class(modname)
         else:
-            raise InvalidModuleName(
-                "Module name '%s' is invalid or not" % modname + "found"
-            )
+            raise InvalidModuleName(f"Module name '{modname}' is invalid or not found")
         return mod
 
     def get_description(self, modname):
@@ -165,9 +166,7 @@ class Modules:
         if modname and modname in self.module_names:
             mod = self._modules[modname]["description"]
         else:
-            raise InvalidModuleName(
-                "Module name '%s' is invalid or not" % modname + "found"
-            )
+            raise InvalidModuleName(f"Module name '{modname}' is invalid or not found")
         return mod
 
     def get_functions(self, modname):
@@ -181,9 +180,7 @@ class Modules:
         if modname and modname in self.module_names:
             mod = self._modules[modname]["functions"]
         else:
-            raise InvalidModuleName(
-                "Module name '%s' is invalid or not" % modname + "found"
-            )
+            raise InvalidModuleName(f"Module name '{modname}' is invalid or not found")
         return mod
 
     def get_func_descriptions(self, modname):
@@ -197,9 +194,7 @@ class Modules:
         if modname and modname in self.module_names:
             desc = self._modules[modname]["func_desc"]
         else:
-            raise InvalidModuleName(
-                "Module name '%s' is invalid or not" % modname + "found"
-            )
+            raise InvalidModuleName(f"Module name '{modname}' is invalid or not found")
         return desc
 
     def get_opt_descriptions(self, modname):
@@ -213,9 +208,7 @@ class Modules:
         if modname and modname in self.module_names:
             desc = self._modules[modname].get("opt_desc")
         else:
-            raise InvalidModuleName(
-                "Module name '%s' is invalid or not found" % modname
-            )
+            raise InvalidModuleName(f"Module name '{modname}' is invalid or not found")
         return desc
 
     def get_spec(self, modname, var):
@@ -231,22 +224,16 @@ class Modules:
         if modname and modname in self.module_names:
             value = self._modules[modname].get(var, None)
         else:
-            raise InvalidModuleName(
-                "Module name '%s' is invalid or not found" % modname
-            )
+            raise InvalidModuleName(f"Module name '{modname}' is invalid or not found")
         return value
 
     def _check_compat(self, module):
         if self.compat_versions:
             if not module.module_spec["version"] in self.compat_versions:
                 raise ModuleVersionError(
-                    "Error loading '%s' plugin module: %s, version: %s\n"
-                    "Module is not compatible with the current application version\n"
-                    "Compatible module API versions are: %s"
-                    % (
-                        self._namepath,
-                        module.module_spec["name"],
-                        module.module_spec["version"],
-                        self.compat_versions,
+                    (
+                        f"Error loading '{self._namepath}' plugin module: {module.module_spec['name']}, version: {module.module_spec['version']}\n"
+                        "Module is not compatible with the current application version\n"
+                        f"Compatible module API versions are: {self.compat_versions}"
                     )
                 )

diff --git a/lib/portage/news.py b/lib/portage/news.py
index ce61f8490..9ef6efde0 100644
--- a/lib/portage/news.py
+++ b/lib/portage/news.py
@@ -91,15 +91,15 @@ class NewsManager:
         self._profile_path = profile_path
 
     def _unread_filename(self, repoid):
-        return os.path.join(self.unread_path, "news-%s.unread" % repoid)
+        return os.path.join(self.unread_path, f"news-{repoid}.unread")
 
     def _skip_filename(self, repoid):
-        return os.path.join(self.unread_path, "news-%s.skip" % repoid)
+        return os.path.join(self.unread_path, f"news-{repoid}.skip")
 
     def _news_dir(self, repoid):
         repo_path = self.portdb.getRepositoryPath(repoid)
         if repo_path is None:
-            raise AssertionError(_("Invalid repoID: %s") % repoid)
+            raise AssertionError(_(f"Invalid repoID: {repoid}"))
         return os.path.join(repo_path, self.news_path)
 
     def updateItems(self, repoid):
@@ -164,7 +164,7 @@ class NewsManager:
                 if itemid in skip:
                     continue
                 filename = os.path.join(
-                    news_dir, itemid, itemid + "." + self.language_id + ".txt"
+                    news_dir, itemid, f"{itemid}.{self.language_id}.txt"
                 )
                 if not os.path.isfile(filename):
                     continue
@@ -178,9 +178,7 @@ class NewsManager:
                     skip.add(item.name)
 
             if unread != unread_orig:
-                write_atomic(
-                    unread_filename, "".join("%s\n" % x for x in sorted(unread))
-                )
+                write_atomic(unread_filename, "".join(f"{x}\n" for x in sorted(unread)))
                 apply_secpass_permissions(
                     unread_filename,
                     uid=self._uid,
@@ -190,7 +188,7 @@ class NewsManager:
                 )
 
             if skip != skip_orig:
-                write_atomic(skip_filename, "".join("%s\n" % x for x in sorted(skip)))
+                write_atomic(skip_filename, "".join(f"{x}\n" for x in sorted(skip)))
                 apply_secpass_permissions(
                     skip_filename,
                     uid=self._uid,
@@ -348,12 +346,12 @@ class NewsItem:
 
         if invalids:
             self._valid = False
-            msg = []
-            msg.append(_("Invalid news item: %s") % (self.path,))
-            for lineno, line in invalids:
-                msg.append(_("  line %d: %s") % (lineno, line))
+            msg = [
+                _(f"Invalid news item: {self.path}"),
+                *(_(f"  line {lineno}: {line}") for lineno, line in invalids),
+            ]
             writemsg_level(
-                "".join("!!! %s\n" % x for x in msg), level=logging.ERROR, noiselevel=-1
+                "".join(f"!!! {x}\n" for x in msg), level=logging.ERROR, noiselevel=-1
             )
 
         self._parsed = True
@@ -473,7 +471,7 @@ def count_unread_news(portdb, vardb, repos=None, update=True):
             # NOTE: The NewsManager typically handles permission errors by
             # returning silently, so PermissionDenied won't necessarily be
             # raised even if we do trigger a permission error above.
-            msg = "Permission denied: '%s'\n" % (e,)
+            msg = f"Permission denied: '{e}'\n"
             if msg in permission_msgs:
                 pass
             else:
@@ -498,9 +496,8 @@ def display_news_notifications(news_counts):
                 newsReaderDisplay = True
                 print()
             print(colorize("WARN", " * IMPORTANT:"), end=" ")
-            print("%s news items need reading for repository '%s'." % (count, repo))
+            print(f"{count} news items need reading for repository '{repo}'.")
 
     if newsReaderDisplay:
         print(colorize("WARN", " *"), end=" ")
-        print("Use " + colorize("GOOD", "eselect news read") + " to view new items.")
-        print()
+        print(f"Use {colorize('GOOD', 'eselect news read')} to view new items.\n")