Replaced str.format() with f-strings in Python code.

This commit is contained in:
Project Nayuki 2022-01-07 06:00:18 +00:00
parent e6ef02e0f5
commit daa3114dcf
2 changed files with 6 additions and 6 deletions

View File

@ -180,14 +180,14 @@ def to_svg_str(qr: QrCode, border: int) -> str:
for y in range(qr.get_size()):
for x in range(qr.get_size()):
if qr.get_module(x, y):
parts.append("M{},{}h1v1h-1z".format(x + border, y + border))
return """<?xml version="1.0" encoding="UTF-8"?>
parts.append(f"M{x+border},{y+border}h1v1h-1z")
return f"""<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 {0} {0}" stroke="none">
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" viewBox="0 0 {qr.get_size()+border*2} {qr.get_size()+border*2}" stroke="none">
<rect width="100%" height="100%" fill="#FFFFFF"/>
<path d="{1}" fill="#000000"/>
<path d="{" ".join(parts)}" fill="#000000"/>
</svg>
""".format(qr.get_size() + border * 2, " ".join(parts))
"""
def print_qr(qrcode: QrCode) -> None:

View File

@ -93,7 +93,7 @@ class QrCode:
if version >= maxversion: # All versions in the range could not fit the given data
msg: str = "Segment too long"
if datausedbits is not None:
msg = "Data length = {} bits, Max capacity = {} bits".format(datausedbits, datacapacitybits)
msg = f"Data length = {datausedbits} bits, Max capacity = {datacapacitybits} bits"
raise DataTooLongError(msg)
assert datausedbits is not None