rteval/rteval-Use-f-strings-in-memory.py.patch
John Kacur 5ee5bace63 Added patches to use f-strings where possible, no functional change
jiraProject == RHEL-797

Signed-off-by: John Kacur <jkacur@redhat.com>
2023-08-11 16:25:10 -04:00

50 lines
1.7 KiB
Diff

From 6e063353072b73e43a732bb5dfa265767ac0dbd7 Mon Sep 17 00:00:00 2001
From: Anubhav Shelat <ashelat@redhat.com>
Date: Thu, 1 Jun 2023 16:27:31 -0400
Subject: rteval: Use f-strings in memory.py
Use f-strings in memory.py
Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
Signed-off-by: John Kacur <jkacur@redhat.com>
---
rteval/sysinfo/memory.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/rteval/sysinfo/memory.py b/rteval/sysinfo/memory.py
index 7c5fd6f315cf..cc2fa2cfa4be 100644
--- a/rteval/sysinfo/memory.py
+++ b/rteval/sysinfo/memory.py
@@ -49,7 +49,7 @@ class MemoryInfo:
if l.startswith('MemTotal:'):
parts = l.split()
if parts[2].lower() != 'kb':
- raise RuntimeError("Units changed from kB! (%s)" % parts[2])
+ raise RuntimeError(f"Units changed from kB! ({parts[2]})")
rawsize = int(parts[1])
f.close()
break
@@ -76,7 +76,7 @@ class MemoryInfo:
memsize = self.mem_get_size()
mem_n = libxml2.newNode("memory_size")
- mem_n.addContent("%.3f" % memsize[0])
+ mem_n.addContent(f"{memsize[0]:.3f}")
mem_n.newProp("unit", memsize[1])
rep_n.addChild(mem_n)
@@ -88,8 +88,8 @@ def unit_test(rootdir):
import sys
try:
mi = MemoryInfo()
- print("Numa nodes: %i" % mi.mem_get_numa_nodes())
- print("Memory: %i %s" % mi.mem_get_size())
+ print(f"Numa nodes: {mi.mem_get_numa_nodes()}")
+ print(f"Memory: {int(mi.mem_get_size()[0])} {mi.mem_get_size()[1]}")
except Exception as e:
import traceback
traceback.print_exc(file=sys.stdout)
--
2.40.1