mirror of https://github.com/encounter/SDL.git
'Refactored by Sourcery'
This commit is contained in:
parent
b6f1c91862
commit
cddf095a16
|
@ -7,7 +7,7 @@ import re
|
||||||
|
|
||||||
filename = "SDL_gamecontrollerdb.h"
|
filename = "SDL_gamecontrollerdb.h"
|
||||||
input = open(filename)
|
input = open(filename)
|
||||||
output = open(filename + ".new", "w")
|
output = open(f"{filename}.new", "w")
|
||||||
parsing_controllers = False
|
parsing_controllers = False
|
||||||
controllers = []
|
controllers = []
|
||||||
controller_guids = {}
|
controller_guids = {}
|
||||||
|
@ -57,14 +57,14 @@ def write_controllers():
|
||||||
print("Warning: entry '%s' is duplicate of entry '%s'" % (current_name, existing_name))
|
print("Warning: entry '%s' is duplicate of entry '%s'" % (current_name, existing_name))
|
||||||
|
|
||||||
if (not current_name.startswith("(DUPE)")):
|
if (not current_name.startswith("(DUPE)")):
|
||||||
entry[2] = "(DUPE) " + current_name
|
entry[2] = f"(DUPE) {current_name}"
|
||||||
|
|
||||||
if (not existing_name.startswith("(DUPE)")):
|
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
|
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 = "".join(entry) + "\n"
|
||||||
line = line.replace("\t", " ")
|
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"):
|
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 = {}
|
controller_guids = {}
|
||||||
|
|
||||||
for line in input:
|
for line in input:
|
||||||
if (parsing_controllers):
|
if parsing_controllers:
|
||||||
if (line.startswith("{")):
|
if (line.startswith("{")):
|
||||||
output.write(line)
|
output.write(line)
|
||||||
elif (line.startswith(" NULL")):
|
elif (line.startswith(" NULL")):
|
||||||
|
@ -83,7 +83,7 @@ for line in input:
|
||||||
write_controllers()
|
write_controllers()
|
||||||
output.write(line)
|
output.write(line)
|
||||||
elif (line.startswith("#if")):
|
elif (line.startswith("#if")):
|
||||||
print("Parsing " + line.strip())
|
print(f"Parsing {line.strip()}")
|
||||||
output.write(line)
|
output.write(line)
|
||||||
elif (line.startswith("#endif")):
|
elif (line.startswith("#endif")):
|
||||||
write_controllers()
|
write_controllers()
|
||||||
|
@ -97,4 +97,4 @@ for line in input:
|
||||||
output.write(line)
|
output.write(line)
|
||||||
|
|
||||||
output.close()
|
output.close()
|
||||||
print("Finished writing %s.new" % filename)
|
print(f"Finished writing {filename}.new")
|
||||||
|
|
Loading…
Reference in New Issue