public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: lib/portage/
Date: Mon,  4 Apr 2022 19:04:57 +0000 (UTC)	[thread overview]
Message-ID: <1649099072.231d7d26c9076a8a88eddbf048437d46ed46a7ed.sam@gentoo> (raw)

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")


             reply	other threads:[~2022-04-04 19:05 UTC|newest]

Thread overview: 148+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-04 19:04 Sam James [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-01-21 21:14 [gentoo-commits] proj/portage:master commit in: lib/portage/ Sam James
2025-01-11 16:01 Mike Gilbert
2025-01-11 16:01 Mike Gilbert
2025-01-01  0:33 Zac Medico
2024-11-02 22:12 Zac Medico
2024-11-02 15:48 Zac Medico
2024-11-02 15:48 Zac Medico
2024-09-09 18:08 Ulrich Müller
2024-09-09 18:08 Ulrich Müller
2024-08-14 15:22 Zac Medico
2024-06-09 17:54 Zac Medico
2024-06-02 18:28 Zac Medico
2024-04-26 22:06 Sam James
2024-04-26 22:06 Sam James
2024-02-28 16:01 Sam James
2024-02-28 15:52 Sam James
2024-02-28 15:49 Sam James
2024-02-25  8:25 Sam James
2024-02-24 20:10 Zac Medico
2024-02-21  2:08 Sam James
2024-02-21  2:08 Sam James
2024-02-12  7:58 Zac Medico
2024-02-11 19:57 Zac Medico
2024-02-10  6:09 Zac Medico
2024-02-10  6:06 Zac Medico
2024-02-09  8:51 Sam James
2024-02-09  7:08 Sam James
2024-02-07  2:35 Zac Medico
2024-02-07  2:35 Zac Medico
2024-02-05  1:03 Zac Medico
2024-02-05  1:03 Zac Medico
2024-01-29 17:49 Zac Medico
2024-01-29 16:09 Zac Medico
2023-12-26 23:15 Zac Medico
2023-11-02 14:58 Zac Medico
2023-10-24 21:26 Zac Medico
2023-10-24  1:48 Zac Medico
2023-10-03 15:07 Zac Medico
2023-10-02  2:10 Zac Medico
2023-09-26  5:53 Zac Medico
2023-09-08 20:36 Sam James
2023-09-08 19:49 Sam James
2023-08-24 18:23 Mike Gilbert
2023-08-02  6:31 Sam James
2023-07-29  3:57 Sam James
2023-06-29  8:22 Sam James
2023-03-21  2:30 Sam James
2023-03-21  2:30 Sam James
2023-03-21  2:30 Sam James
2023-03-21  2:30 Sam James
2023-03-21  2:30 Sam James
2023-03-21  2:30 Sam James
2023-02-27  6:15 Sam James
2023-02-17  1:23 Sam James
2023-01-02  5:25 Sam James
2022-11-02 22:58 Sam James
2022-11-02 22:58 Sam James
2022-09-29 21:37 Sam James
2022-09-29 20:45 Sam James
2022-09-28 23:56 Sam James
2022-09-26 17:52 Zac Medico
2022-09-20 19:45 Sam James
2022-09-20  3:39 Sam James
2022-09-18 18:30 Mike Gilbert
2022-08-01 22:39 Sam James
2022-08-01 17:34 Mike Gilbert
2022-07-19 21:39 Sam James
2022-07-18 18:47 Sam James
2022-07-11 23:02 Sam James
2022-07-10 15:07 Mike Gilbert
2022-07-05 22:56 Sam James
2022-06-05 20:25 Zac Medico
2022-04-11 12:11 Mike Gilbert
2022-04-11 12:11 Mike Gilbert
2022-04-09  4:32 Sam James
2022-04-04 19:04 Sam James
2022-04-04 19:04 Sam James
2022-04-04 19:04 Sam James
2022-04-04 19:04 Sam James
2022-04-04 19:04 Sam James
2022-04-04 19:04 Sam James
2022-04-04 19:04 Sam James
2022-04-01 20:30 Matt Turner
2022-03-30 23:11 Sam James
2022-03-28  1:10 Sam James
2022-03-27 23:07 Sam James
2022-03-27 23:07 Sam James
2022-03-27 23:07 Sam James
2022-03-27 23:07 Sam James
2022-03-27 23:07 Sam James
2022-03-15  2:52 Matt Turner
2022-02-09 11:13 Sam James
2021-09-20 20:06 Zac Medico
2021-09-20 19:55 Mike Gilbert
2021-09-07  7:04 Michał Górny
2021-09-04 11:53 Michał Górny
2021-05-24  6:08 Zac Medico
2021-05-24  4:55 Zac Medico
2021-03-28  3:33 Zac Medico
2021-03-11 12:32 Zac Medico
2021-03-07 14:03 Zac Medico
2021-03-06  9:18 Zac Medico
2021-03-06  9:05 Zac Medico
2021-03-06  9:05 Zac Medico
2021-03-06  8:20 Zac Medico
2021-03-06  6:16 Zac Medico
2021-02-08  4:55 Zac Medico
2020-09-11 19:02 Zac Medico
2020-08-04  1:39 Zac Medico
2020-08-03 23:28 Zac Medico
2020-08-03 23:28 Zac Medico
2020-08-03 19:30 Zac Medico
2020-08-03 19:30 Zac Medico
2020-08-03 19:30 Zac Medico
2020-08-03 19:30 Zac Medico
2020-06-27 19:46 Zac Medico
2020-06-09  0:58 Zac Medico
2020-05-17  9:37 Michał Górny
2020-05-07 20:35 Zac Medico
2020-04-20 21:16 Mike Gilbert
2020-03-28 18:57 Michał Górny
2020-03-25 19:18 Zac Medico
2020-03-25  7:57 Zac Medico
2020-03-25  7:57 Zac Medico
2020-02-04  6:43 Zac Medico
2020-02-02  9:00 Zac Medico
2019-12-15 23:04 Zac Medico
2019-11-12 22:25 Zac Medico
2019-09-17  2:59 Zac Medico
2019-09-07  6:40 Zac Medico
2019-08-18 22:15 Zac Medico
2019-08-04 18:03 Zac Medico
2019-08-02 20:03 Mike Gilbert
2019-08-01 19:02 Mike Gilbert
2019-05-28  1:49 Zac Medico
2019-04-27 19:20 Zac Medico
2019-02-20  0:58 Zac Medico
2019-02-20  0:58 Zac Medico
2019-02-20  0:58 Zac Medico
2019-02-18  1:01 Zac Medico
2019-02-11 19:46 Zac Medico
2019-01-04  3:49 Zac Medico
2018-12-31  5:27 Zac Medico
2018-12-04  1:35 Zac Medico
2018-11-25  0:03 Zac Medico
2018-11-24 21:34 Zac Medico
2018-08-07 18:36 Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1649099072.231d7d26c9076a8a88eddbf048437d46ed46a7ed.sam@gentoo \
    --to=sam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox