Merge commit 'cddf095a16263734bef07cefbbac1a42bf70d171' into main
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
diff --git a/src/joystick/sort_controllers.py b/src/joystick/sort_controllers.py
index 93461eb..df04241 100755
--- a/src/joystick/sort_controllers.py
+++ b/src/joystick/sort_controllers.py
@@ -7,7 +7,7 @@ import re
filename = "SDL_gamecontrollerdb.h"
input = open(filename)
-output = open(filename + ".new", "w")
+output = open(f"{filename}.new", "w")
parsing_controllers = False
controllers = []
controller_guids = {}
@@ -57,14 +57,14 @@ def write_controllers():
print("Warning: entry '%s' is duplicate of entry '%s'" % (current_name, existing_name))
if (not current_name.startswith("(DUPE)")):
- entry[2] = "(DUPE) " + current_name
+ entry[2] = f"(DUPE) {current_name}"
if (not existing_name.startswith("(DUPE)")):
- controller_guids[entry[1]][2] = "(DUPE) " + existing_name
+ controller_guids[entry[1]][2] = f"(DUPE) {existing_name}"
controller_guids[entry[1]] = entry
- for entry in sorted(controllers, key=lambda entry: entry[2]+"-"+entry[1]):
+ for entry in sorted(controllers, key=lambda entry: f"{entry[2]}-{entry[1]}"):
line = "".join(entry) + "\n"
line = line.replace("\t", " ")
if not line.endswith(",\n") and not line.endswith("*/\n") and not line.endswith(",\r\n") and not line.endswith("*/\r\n"):
@@ -75,7 +75,7 @@ def write_controllers():
controller_guids = {}
for line in input:
- if (parsing_controllers):
+ if parsing_controllers:
if (line.startswith("{")):
output.write(line)
elif (line.startswith(" NULL")):
@@ -83,7 +83,7 @@ for line in input:
write_controllers()
output.write(line)
elif (line.startswith("#if")):
- print("Parsing " + line.strip())
+ print(f"Parsing {line.strip()}")
output.write(line)
elif (line.startswith("#endif")):
write_controllers()
@@ -97,4 +97,4 @@ for line in input:
output.write(line)
output.close()
-print("Finished writing %s.new" % filename)
+print(f"Finished writing {filename}.new")