Skip to content

Commit 7b9df18

Browse files
committed
Minor style update to use f-strings over %
This was updated to satisfy ruff recommending code style refresh.
1 parent 5a329c2 commit 7b9df18

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/impactlab_tools/utils/paralog.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def __init__(self, jobname, jobtitle, logdir, timeout, exclusive_jobnames=None):
6464
if not os.path.exists(logdir):
6565
os.makedirs(logdir)
6666
for ii in itertools.count():
67-
logpath = os.path.join(logdir, "%s-%d.log" % (jobname, ii))
67+
logpath = os.path.join(logdir, f"{jobname}-{ii:d}.log")
6868
if not os.path.exists(logpath):
6969
self.logpath = logpath
7070
break
@@ -73,12 +73,7 @@ def __init__(self, jobname, jobtitle, logdir, timeout, exclusive_jobnames=None):
7373
# Record this process in the master log
7474
with open(os.path.join(logdir, "master.log"), 'a') as fp:
7575
fp.write(
76-
"%s %s: %d %s\n" % (
77-
time.asctime(),
78-
self.jobtitle,
79-
os.getpid(),
80-
self.logpath
81-
)
76+
f"{time.asctime()} {self.jobtitle}: {os.getpid():d} {self.logpath}\n"
8277
)
8378
except Exception:
8479
print("CAUGHT A WILD EXCEPTION BUT IGNORING IT WITHOUT LOGGING IT!")
@@ -106,7 +101,7 @@ def claim(self, dirpath):
106101
status_path = StatusManager.claiming_filepath(dirpath, self.jobname)
107102
try:
108103
with open(status_path, 'w') as fp:
109-
fp.write("%d %s: %s\n" % (os.getpid(), self.jobtitle, self.logpath))
104+
fp.write(f"{os.getpid():d} {self.jobtitle}: {self.logpath}\n")
110105
except Exception:
111106
print("CAUGHT A WILD EXCEPTION BUT IGNORING IT WITHOUT LOGGING IT!")
112107
return False # Writing error: cannot calim directory

0 commit comments

Comments
 (0)