Convert formatting automatically to f-strings

Automatically convert formatting with the following call:
flynt -ll 2000 -v frappy*
Result: 303/381 auto-converted.
Failing conversions will be looked at manually in a follow-up commit.

Change-Id: Icd996b27221202faccc15af78e0380cf52ee37f2
Reviewed-on: https://forge.frm2.tum.de/review/c/secop/frappy/+/30900
Tested-by: Jenkins Automated Tests <pedersen+jenkins@frm2.tum.de>
Reviewed-by: Georg Brandl <g.brandl@fz-juelich.de>
Reviewed-by: Alexander Zaft <a.zaft@fz-juelich.de>
This commit is contained in:
Alexander Zaft
2023-04-14 07:12:03 +02:00
committed by Markus Zolliker
parent a9d479ba0a
commit 6f95c0d825
56 changed files with 327 additions and 380 deletions

View File

@@ -66,7 +66,7 @@ class Ls370Sim(Communicator):
self._data['RDGST?%d' % channel] = '0'
def communicate(self, command):
self.comLog('> %s' % command)
self.comLog(f'> {command}')
chunks = command.split(';')
reply = []
@@ -86,7 +86,7 @@ class Ls370Sim(Communicator):
self.data[qcmd] = arg
break
reply = ';'.join(reply)
self.comLog('< %s' % reply)
self.comLog(f'< {reply}')
return reply

View File

@@ -74,7 +74,7 @@ class Switch(Drivable):
def write_target(self, value):
# could tell HW
self.status = (self.Status.BUSY, 'switching %s' % value.name.upper())
self.status = (self.Status.BUSY, f'switching {value.name.upper()}')
# note: setting self.target to the new value is done after this....
def read_status(self):
@@ -284,8 +284,7 @@ class Label(Readable):
dev_ts = self.DISPATCHER.get_module(self.subdev_ts)
if dev_ts:
strings.append('at %.3f %s' %
(dev_ts.read_value(), dev_ts.parameters['value'].datatype.unit))
strings.append(f"at {dev_ts.read_value():.3f} {dev_ts.parameters['value'].datatype.unit}")
else:
strings.append('No connection to sample temp!')
@@ -299,7 +298,7 @@ class Label(Readable):
state = 'Persistent' if mf_mode else 'Non-persistent'
else:
state = mf_stat[1] or 'ramping'
strings.append('%s at %.1f %s' % (state, mf_val, mf_unit))
strings.append(f'{state} at {mf_val:.1f} {mf_unit}')
else:
strings.append('No connection to magnetic field!')