Blame SOURCES/tuna-tuna-cmd.py-use-fstrings.patch

5aedf2
From e9f60274865475c4e9081ee356ffbc61d1df2ade Mon Sep 17 00:00:00 2001
5aedf2
From: Leah Leshchinsky <lleshchi@redhat.com>
5aedf2
Date: Wed, 2 Nov 2022 10:57:19 -0400
5aedf2
Subject: [PATCH 3/3] tuna: tuna-cmd.py use fstrings
5aedf2
5aedf2
Add fstrings where possible to improve readabilty
5aedf2
5aedf2
Due to the discussion regarding dropping the language feature, gettext
5aedf2
shorthand _() have been removed.
5aedf2
5aedf2
Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
5aedf2
Signed-off-by: John Kacur <jkacur@redhat.com>
5aedf2
5aedf2
diff --git a/tuna-cmd.py b/tuna-cmd.py
5aedf2
index 79e33371837e..75b63da972c2 100755
5aedf2
--- a/tuna-cmd.py
5aedf2
+++ b/tuna-cmd.py
5aedf2
@@ -176,13 +176,16 @@ def thread_help(tid):
5aedf2
         ps = procfs.pidstats()
5aedf2
 
5aedf2
     if tid not in ps:
5aedf2
-        print("tuna: " + _("thread %d doesn't exists!") % tid)
5aedf2
+        print(f"tuna: thread {tid} doesn't exist!")
5aedf2
         return
5aedf2
 
5aedf2
     pinfo = ps[tid]
5aedf2
     cmdline = procfs.process_cmdline(pinfo)
5aedf2
     help, title = tuna.kthread_help_plain_text(tid, cmdline)
5aedf2
-    print("%s\n\n%s" % (title, _(help)))
5aedf2
+    print(title, "\n\n")
5aedf2
+    if help.isspace():
5aedf2
+        help = "No help description available."
5aedf2
+    print(help)
5aedf2
 
5aedf2
 
5aedf2
 def save(cpu_list, thread_list, filename):
5aedf2
@@ -208,7 +211,7 @@ def ps_show_header(has_ctxt_switch_info, cgroups=False):
5aedf2
 
5aedf2
 def ps_show_sockets(pid, ps, inodes, inode_re, indent=0):
5aedf2
     header_printed = False
5aedf2
-    dirname = "/proc/%s/fd" % pid
5aedf2
+    dirname = f"/proc/{pid}/fd"
5aedf2
     try:
5aedf2
         filenames = os.listdir(dirname)
5aedf2
     except:  # Process died
5aedf2
@@ -650,7 +653,7 @@ def main():
5aedf2
             try:
5aedf2
                 gui_refresh=int(a)
5aedf2
             except Exception as err:
5aedf2
-                print("tuna: --refresh %s" % err)
5aedf2
+                print(f"tuna: --refresh {err}")
5aedf2
                 sys.exit(2)
5aedf2
         elif o in ("-d", "--disable_perf"):
5aedf2
             run_gui = True
5aedf2
@@ -679,7 +682,7 @@ def main():
5aedf2
                 try:
5aedf2
                     tuna.threads_set_priority(thread_list, a, affect_children)
5aedf2
                 except OSError as err:
5aedf2
-                    print("tuna: %s" % err)
5aedf2
+                    print(f"tuna: {err}")
5aedf2
                     sys.exit(2)
5aedf2
         elif o in ("-P", "--show_threads"):
5aedf2
             # If the user specified process names that weren't
5aedf2
-- 
5aedf2
2.31.1
5aedf2