fixed items from code review

This commit is contained in:
Félix Boisselier
2024-06-11 21:26:15 +02:00
parent 6d1e53d4d1
commit ecd57ea3dc
21 changed files with 52 additions and 122 deletions

View File

@@ -1,5 +1,3 @@
#!/usr/bin/env python3
# Common functions for the Shake&Tune package
# Written by Frix_x#0161 #
@@ -35,9 +33,9 @@ def parse_log(logname):
# Check for a PSD file generated by Klipper and raise a warning
if cleaned_line.startswith('#freq,psd_x,psd_y,psd_z,psd_xyz'):
ConsoleOutput.print(
'Warning: %s does not contain raw accelerometer data. '
f'Warning: {logname} does not contain raw accelerometer data. '
'Please use the official Klipper script to process it instead. '
'It will be ignored by Shake&Tune!' % (logname,)
'It will be ignored by Shake&Tune!'
)
return None
@@ -48,8 +46,8 @@ def parse_log(logname):
if not header:
ConsoleOutput.print(
'Warning: file %s has an incorrect header and will be ignored by Shake&Tune!\n'
"Expected '#time,accel_x,accel_y,accel_z', but got '%s'." % (logname, header.strip())
f'Warning: file {logname} has an incorrect header and will be ignored by Shake&Tune!\n'
f"Expected '#time,accel_x,accel_y,accel_z', but got '{header.strip()}'."
)
return None
@@ -57,8 +55,8 @@ def parse_log(logname):
data = np.loadtxt(logname, comments='#', delimiter=',', skiprows=1)
if data.ndim == 1 or data.shape[1] != 4:
ConsoleOutput.print(
'Warning: %s does not have the correct data format; expected 4 columns. '
'It will be ignored by Shake&Tune!' % (logname,)
f'Warning: {logname} does not have the correct data format; expected 4 columns. '
'It will be ignored by Shake&Tune!'
)
return None