misc: Use python f-strings for string formatting

This patch has been generated by applying flynt to the
gem5 repo (ext has been excluded)

JIRA: https://gem5.atlassian.net/browse/GEM5-831

Change-Id: I0935db6223d5426b99515959bde78e374cbadb04
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/68957
Maintainer: Bobby Bruce <bbruce@ucdavis.edu>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Bobby Bruce <bbruce@ucdavis.edu>
This commit is contained in:
Giacomo Travaglini
2023-03-15 13:34:46 +00:00
parent 07fca546e6
commit e73655d038
242 changed files with 814 additions and 1002 deletions

View File

@@ -209,7 +209,7 @@ class ArtifactMongoDB(ArtifactDB):
some type and a regex name."""
data = self.artifacts.find(
{"type": typ, "name": {"$regex": "{}".format(name)}}, limit=limit
{"type": typ, "name": {"$regex": f"{name}"}}, limit=limit
)
for d in data:
yield d

View File

@@ -76,9 +76,9 @@ def getGit(path: Path) -> Dict[str, str]:
]
res = subprocess.run(command, stdout=subprocess.PIPE, cwd=path)
if res.returncode != 0:
raise Exception("git repo doesn't exist for {}".format(path))
raise Exception(f"git repo doesn't exist for {path}")
if res.stdout:
raise Exception("git repo dirty for {}".format(path))
raise Exception(f"git repo dirty for {path}")
command = ["git", "remote", "get-url", "origin"]
origin = subprocess.check_output(command, cwd=path)
@@ -203,14 +203,14 @@ class Artifact:
data["git"] = getGit(ppath)
data["hash"] = data["git"]["hash"]
else:
raise Exception("Path {} doesn't exist".format(ppath))
raise Exception(f"Path {ppath} doesn't exist")
pcwd = Path(cwd)
data["cwd"] = pcwd
if not pcwd.exists():
raise Exception("cwd {} doesn't exist.".format(pcwd))
raise Exception(f"cwd {pcwd} doesn't exist.")
if not pcwd.is_dir():
raise Exception("cwd {} is not a directory".format(pcwd))
raise Exception(f"cwd {pcwd} is not a directory")
data["inputs"] = [i._id for i in inputs]

View File

@@ -316,7 +316,7 @@ class gem5Run:
try:
return cls.loadFromDict(d)
except KeyError:
print("Incompatible json file: {}!".format(filename))
print(f"Incompatible json file: {filename}!")
raise
@classmethod
@@ -521,7 +521,7 @@ class gem5Run:
# Check again in five seconds
time.sleep(5)
print("Done running {}".format(" ".join(self.command)))
print(f"Done running {' '.join(self.command)}")
# Done executing
self.running = False
@@ -540,7 +540,7 @@ class gem5Run:
# Store current gem5 run in the database
db.put(self._id, self._getSerializable())
print("Done storing the results of {}".format(" ".join(self.command)))
print(f"Done storing the results of {' '.join(self.command)}")
def run(self, task: Any = None, cwd: str = ".") -> None:
"""Actually run the test.

View File

@@ -112,7 +112,7 @@ class TestSERun(unittest.TestCase):
[
"gem5/build/X86/gem5.opt",
"-re",
"--outdir={}".format(os.path.abspath("results/run_test/out")),
f"--outdir={os.path.abspath('results/run_test/out')}",
"configs-tests/run_test.py",
"extra",
"params",