Convert .format() to f-strings with flynt

This commit is contained in:
Philip Sargent
2022-11-23 10:51:49 +00:00
parent aca92cb1af
commit aaf6a6c7cf
4 changed files with 19 additions and 21 deletions

View File

@@ -65,7 +65,7 @@ for r in lines[1:]:
if mug:
if not (os.path.isfile(mug)):
print("ERROR: --------------- mug file does not exist: ", mug, file=sys.stderr)
if mug: output += '<a href=%s><img alt=":-)" src="i/mug.png" /></a>' % mug
if mug: output += f'<a href={mug}><img alt=":-)" src="i/mug.png" /></a>'
output += '</td>'
for y in range(len(years)):
if(years[y]):

View File

@@ -80,7 +80,7 @@ class QmExtracter:
grade = grade.upper()
if grade not in ['A', 'B', 'C', 'D', 'E', 'X']:
self.__print_error(svx_file, line,
'Unknown QM grade %s' % grade)
f'Unknown QM grade {grade}')
continue
# Sanitise the resolution station.
@@ -232,10 +232,9 @@ class QmExtracter:
}[grade]
except KeyError:
grade_colour = '00'
formatted_grade = '\033[{}m{}\033[0m'.format(grade_colour,
grade)
formatted_survey_name = '\033[4m{}\033[0m'.format(survey_name)
formatted_name = '\033[4m{}\033[0m'.format(name)
formatted_grade = f'[{grade_colour}m{grade}'
formatted_survey_name = f'{survey_name}'
formatted_name = f'{name}'
else:
formatted_grade = grade
formatted_survey_name = survey_name
@@ -254,11 +253,10 @@ class QmExtracter:
if n_printed == 0 and not qms:
print('No QMs found')
elif n_printed == 0:
print('No unresolved QMs found (but %u resolved ones were)' %
len(qms))
print(f'No unresolved QMs found (but {len(qms)} resolved ones were)')
def __print_error(self, svx_file, line, exc):
sys.stderr.write('%s: %s\n %s\n' % (svx_file, exc, line))
sys.stderr.write(f'{svx_file}: {exc}\n {line}\n')
def main():