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

◆ save_controller()

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)

◆ write_controllers()

def sort_controllers.write_controllers ( )

Definition at line 27 of file sort_controllers.py.

References save_controller().

27 def write_controllers():
28  global controllers
29  global controller_guids
30  for entry in sorted(controllers, key=lambda entry: entry[2]):
31  line = "".join(entry) + "\n"
32  line = line.replace("\t", " ")
33  if not line.endswith(",\n") and not line.endswith("*/\n"):
34  print("Warning: '%s' is missing a comma at the end of the line" % (line))
35  if (entry[1] in controller_guids):
36  print("Warning: entry '%s' is duplicate of entry '%s'" % (entry[2], controller_guids[entry[1]][2]))
37  controller_guids[entry[1]] = entry
38 
39  output.write(line)
40  controllers = []
41  controller_guids = {}
42 

Variable Documentation

◆ controller_guids

dictionary sort_controllers.controller_guids = {}

Definition at line 13 of file sort_controllers.py.

◆ controllers

list sort_controllers.controllers = []

◆ filename

string sort_controllers.filename = "SDL_gamecontrollerdb.h"

Definition at line 8 of file sort_controllers.py.

Referenced by main().

◆ input

sort_controllers.input = open(filename)

Definition at line 9 of file sort_controllers.py.

◆ output

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

Definition at line 10 of file sort_controllers.py.

Referenced by main(), SDL_LogOutput(), and stdlib_sscanf().

◆ parsing_controllers

bool sort_controllers.parsing_controllers = False

Definition at line 11 of file sort_controllers.py.

◆ split_pattern

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

Definition at line 14 of file sort_controllers.py.