Commit e022b12a47d0d5c070e8a125fcd6eb6a2cd363a6

Sam Lantinga 2022-06-29T17:25:39

Merge commit 'cddf095a16263734bef07cefbbac1a42bf70d171' into main

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")