f312f6
From 1e2f6a3b64bce4ea335e97b1ab31ada3e082a6bc Mon Sep 17 00:00:00 2001
f312f6
From: Leah Leshchinsky <lleshchi@redhat.com>
f312f6
Date: Tue, 1 Nov 2022 13:24:00 -0400
f312f6
Subject: [PATCH 2/4] tuna: tuna-cmd.py use fstrings
f312f6
f312f6
Add fstrings where possible to improve readabilty
f312f6
f312f6
Due to the discussion regarding dropping the language feature, gettext
f312f6
shorthand _() have been removed.
f312f6
f312f6
Signed-off-by: Leah Leshchinsky <lleshchi@redhat.com>
f312f6
Signed-off-by: John Kacur <jkacur@redhat.com>
f312f6
f312f6
diff --git a/tuna-cmd.py b/tuna-cmd.py
f312f6
index c5bc65059da7..44d9faaf15fb 100755
f312f6
--- a/tuna-cmd.py
f312f6
+++ b/tuna-cmd.py
f312f6
@@ -89,7 +89,7 @@ irqs = None
f312f6
 
f312f6
 class HelpMessageParser(argparse.ArgumentParser):
f312f6
     def error(self, message):
f312f6
-        sys.stderr.write('error: %s\n' % message)
f312f6
+        sys.stderr.write(f'error: {message}\n')
f312f6
         self.print_help()
f312f6
         sys.exit(2)
f312f6
 
f312f6
@@ -263,13 +263,16 @@ def thread_help(tid):
f312f6
         ps = procfs.pidstats()
f312f6
 
f312f6
     if tid not in ps:
f312f6
-        print("tuna: " + _("thread %d doesn't exists!") % tid)
f312f6
+        print(f"tuna: thread {tid} doesn't exist!")
f312f6
         return
f312f6
 
f312f6
     pinfo = ps[tid]
f312f6
     cmdline = procfs.process_cmdline(pinfo)
f312f6
     help, title = tuna.kthread_help_plain_text(tid, cmdline)
f312f6
-    print("%s\n\n%s" % (title, _(help)))
f312f6
+    print(title, "\n\n")
f312f6
+    if help.isspace():
f312f6
+        help = "No help description available."
f312f6
+    print(help)
f312f6
 
f312f6
 
f312f6
 def save(cpu_list, thread_list, filename):
f312f6
@@ -295,7 +298,7 @@ def ps_show_header(has_ctxt_switch_info, cgroups=False):
f312f6
 
f312f6
 def ps_show_sockets(pid, ps, inodes, inode_re, indent=0):
f312f6
     header_printed = False
f312f6
-    dirname = "/proc/%s/fd" % pid
f312f6
+    dirname = f"/proc/{pid}/fd"
f312f6
     try:
f312f6
         filenames = os.listdir(dirname)
f312f6
     except:  # Process died
f312f6
@@ -688,7 +691,7 @@ def main():
f312f6
         try:
f312f6
             tuna.threads_set_priority(args.thread_list, args.priority, args.affect_children)
f312f6
         except OSError as err:
f312f6
-            print("tuna: %s" % err)
f312f6
+            print(f"tuna: {err}")
f312f6
             sys.exit(2)
f312f6
 
f312f6
     elif args.command in ['show_configs']:
f312f6
@@ -705,7 +708,7 @@ def main():
f312f6
         spread = args.command in ['spread', 'x']
f312f6
 
f312f6
         if not (args.thread_list or args.irq_list):
f312f6
-            parser.error("tuna: %s " % (args.command) + _("requires a thread/irq list!\n"))
f312f6
+            parser.error(f"tuna: {args.command} requires a thread/irq list!\n")
f312f6
 
f312f6
         if args.thread_list:
f312f6
             tuna.move_threads_to_cpu(args.cpu_list, args.thread_list, spread=spread)
f312f6
-- 
f312f6
2.31.1
f312f6