src/joystick/sort_controllers.py
changeset 9203 874b59c43a3f
parent 8053 495f4a047be1
child 9205 5302aee2916a
equal deleted inserted replaced
9202:01bb8e3ba14f 9203:874b59c43a3f
    28     global controllers
    28     global controllers
    29     global controller_guids
    29     global controller_guids
    30     for entry in sorted(controllers, key=lambda entry: entry[2]):
    30     for entry in sorted(controllers, key=lambda entry: entry[2]):
    31         line = "".join(entry) + "\n"
    31         line = "".join(entry) + "\n"
    32         if not line.endswith(",\n") and not line.endswith("*/\n"):
    32         if not line.endswith(",\n") and not line.endswith("*/\n"):
    33             print "Warning: '%s' is missing a comma at the end of the line" % (line)
    33             print("Warning: '%s' is missing a comma at the end of the line" % (line))
    34         if (entry[1] in controller_guids):
    34         if (entry[1] in controller_guids):
    35             print "Warning: entry '%s' is duplicate of entry '%s'" % (entry[2], controller_guids[entry[1]][2])
    35             print("Warning: entry '%s' is duplicate of entry '%s'" % (entry[2], controller_guids[entry[1]][2]))
    36         controller_guids[entry[1]] = entry
    36         controller_guids[entry[1]] = entry
    37 
    37 
    38         output.write(line)
    38         output.write(line)
    39     controllers = []
    39     controllers = []
    40     controller_guids = {}
    40     controller_guids = {}
    46         elif (line.startswith("#endif")):
    46         elif (line.startswith("#endif")):
    47             parsing_controllers = False
    47             parsing_controllers = False
    48             write_controllers()
    48             write_controllers()
    49             output.write(line)
    49             output.write(line)
    50         elif (line.startswith("#")):
    50         elif (line.startswith("#")):
    51             print "Parsing " + line.strip()
    51             print("Parsing " + line.strip())
    52             write_controllers()
    52             write_controllers()
    53             output.write(line)
    53             output.write(line)
    54         else:
    54         else:
    55             save_controller(line)
    55             save_controller(line)
    56     else:
    56     else:
    58             parsing_controllers = True
    58             parsing_controllers = True
    59 
    59 
    60         output.write(line)
    60         output.write(line)
    61 
    61 
    62 output.close()
    62 output.close()
    63 print "Finished writing %s.new" % filename
    63 print("Finished writing %s.new" % filename)