On Tue, 4 Jan 2022, Leah Leshchinsky wrote:
Condense various conditionals in print statements into a single line
to improve readability.
Small fix, remove header_printed section.
Normally you would add a line to explain what the differences are between
the different versions of the patch, but since you got rid of the
header_printed section changes altogether, I would just remove this
comment
Signed-off-by: Leah Leshchinsky <lleshchi(a)redhat.com>
---
tuna-cmd.py | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/tuna-cmd.py b/tuna-cmd.py
index 7e33a128d676..ccd7036093d9 100755
--- a/tuna-cmd.py
+++ b/tuna-cmd.py
@@ -156,10 +156,7 @@ def ps_show_header(has_ctxt_switch_info, cgroups=False):
has_ctxt_switch_info and " %9s %12s" %
(
"voluntary",
"nonvoluntary")
or "", "cmd"), end='
')
- if cgroups:
- print(" %7s" % ("cgroup"))
- else:
- print("")
+ print(" %7s" % ("cgroup") if cgroups else "")
def ps_show_sockets(pid, ps, inodes, inode_re, indent=0):
@@ -203,7 +200,6 @@ def format_affinity(affinity):
ncpus = os.sysconf('SC_NPROCESSORS_CONF')
return ",".join(str(hex(a)) for a in procfs.hexbitmask(affinity, ncpus))
-
def ps_show_thread(pid, affect_children, ps, has_ctxt_switch_info, sock_inodes,
sock_inode_re, cgroups):
global irqs
@@ -246,15 +242,12 @@ def ps_show_thread(pid, affect_children, ps, has_ctxt_switch_info,
sock_inodes,
ctxt_switch_info = " %9d %12s" % (voluntary_ctxt_switches,
nonvoluntary_ctxt_switches)
- if affect_children:
- print(" %-5d " % pid, end=' ')
- else:
- print(" %-5d" % pid, end=' ')
+ # Indent affected children
+ print(" %-5d " % pid if affect_children else " %-5d" % pid,
end=' ')
print("%6s %5d %8s%s %15s %s" % (sched, rtprio, affinity,
ctxt_switch_info, cmd, users), end=' ')
- if cgroups:
- print(" %9s" % cgout, end=' ')
- print("")
+ print(" %9s" % cgout if cgroups else "")
+
The original code does print("") unconditionally
Your code only does that if cgroups
if sock_inodes:
ps_show_sockets(pid, ps, sock_inodes, sock_inode_re,
affect_children and 3 or 4)
--
2.27.0
_______________________________________________
tuna-devel mailing list -- tuna-devel(a)lists.fedorahosted.org
To unsubscribe send an email to tuna-devel-leave(a)lists.fedorahosted.org
Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives:
https://lists.fedorahosted.org/archives/list/tuna-devel@lists.fedorahoste...
Do not reply to spam on the list, report it:
https://pagure.io/fedora-infrastructure