SDL  2.0
sort_controllers Namespace Reference

Functions

def save_controller (line)
 
def write_controllers ()
 

Variables

string filename = "SDL_gamecontrollerdb.h"
 
 input = open(filename)
 
 output = open(filename + ".new", "w")
 
bool parsing_controllers = False
 
list controllers = []
 
dictionary controller_guids = {}
 
 split_pattern = re.compile(r'([^"]*")([^,]*,)([^,]*,)([^"]*)(".*)')
 

Function Documentation

def sort_controllers.save_controller (   line)

Definition at line 16 of file sort_controllers.py.

Referenced by write_controllers().

16 def save_controller(line):
17  global controllers
18  match = split_pattern.match(line)
19  entry = [ match.group(1), match.group(2), match.group(3) ]
20  bindings = sorted(match.group(4).split(","))
21  if (bindings[0] == ""):
22  bindings.pop(0)
23  entry.extend(",".join(bindings) + ",")
24  entry.append(match.group(5))
25  controllers.append(entry)
26 
def save_controller(line)
def sort_controllers.write_controllers ( )

Definition at line 27 of file sort_controllers.py.

References save_controller().

28  global controllers
29  global controller_guids
30  for entry in sorted(controllers, key=lambda entry: entry[2]):
31  line = "".join(entry) + "\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))
34  if (entry[1] in controller_guids):
35  print("Warning: entry '%s' is duplicate of entry '%s'" % (entry[2], controller_guids[entry[1]][2]))
36  controller_guids[entry[1]] = entry
37 
38  output.write(line)
39  controllers = []
40  controller_guids = {}
41 

Variable Documentation

dictionary sort_controllers.controller_guids = {}

Definition at line 13 of file sort_controllers.py.

list sort_controllers.controllers = []
string sort_controllers.filename = "SDL_gamecontrollerdb.h"

Definition at line 8 of file sort_controllers.py.

Referenced by main().

sort_controllers.input = open(filename)

Definition at line 9 of file sort_controllers.py.

sort_controllers.output = open(filename + ".new", "w")

Definition at line 10 of file sort_controllers.py.

Referenced by SDL_LogOutput().

bool sort_controllers.parsing_controllers = False

Definition at line 11 of file sort_controllers.py.

sort_controllers.split_pattern = re.compile(r'([^"]*")([^,]*,)([^,]*,)([^"]*)(".*)')

Definition at line 14 of file sort_controllers.py.