Skip to content
Snippets Groups Projects
Commit 9240e15d authored by aboensch's avatar aboensch
Browse files

sort allow_calls_provided params in two subgroups: glew and gl

issue #483
parent ff730cde
No related branches found
No related tags found
1 merge request!155Feature/#483 cleanup opengl mock
...@@ -21,13 +21,14 @@ ...@@ -21,13 +21,14 @@
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
import textwrap import textwrap
import os import os
from collections import defaultdict
params_to_be_sorted = ["functions_to_mock", "allow_calls_provided", params_to_be_sorted = ["functions_to_mock", "allow_calls_provided",
"gl_types"] "gl_types"]
def sortListAlphabetically(content): def sortListAlphabetically(content):
prefix = content[0:content.find("=")] prefix = content[0:content.find("=")]
print("... sorting prefix " + prefix) print("... sorting " + prefix)
sub_content = content[content.find("[")+1:content.find("']")] sub_content = content[content.find("[")+1:content.find("']")]
params = sub_content.split("',") params = sub_content.split("',")
...@@ -36,10 +37,24 @@ def sortListAlphabetically(content): ...@@ -36,10 +37,24 @@ def sortListAlphabetically(content):
#else: #else:
params = sorted(params) params = sorted(params)
if (params_to_be_sorted[1] in prefix):
sub_content = SortGlewBeforeGl(params)
else:
sub_content = ', '.join(str(val)+"'" for val in params) sub_content = ', '.join(str(val)+"'" for val in params)
return (prefix+ " = [" + sub_content+"]") return (prefix+ " = [" + sub_content+"]")
def SortGlewBeforeGl(params):
d = defaultdict(list)
for val in params:
d["glew" in val].append(val)
sortedParams = ', '.join(str(p)+"'" for p in d[True])
sortedParams += ','
sortedParams += ','.join(str(p)+"'" for p in d[False])
return sortedParams
def printToFile(file, content): def printToFile(file, content):
nr_of_blanks = len(content[0:content.find("[")+1]) nr_of_blanks = len(content[0:content.find("[")+1])
if (params_to_be_sorted[1] in content): if (params_to_be_sorted[1] in content):
...@@ -57,7 +72,7 @@ def printWithLineBreakAtComma(file, content, nr_of_blanks): ...@@ -57,7 +72,7 @@ def printWithLineBreakAtComma(file, content, nr_of_blanks):
content = content.replace ("',", "',\n") content = content.replace ("',", "',\n")
params = content.split("\n") params = content.split("\n")
for val in params: for val in params:
file.write(val+"\n" if val == params[0] else ' '*(nr_of_blanks-1)+val+"\n") file.write(val+"\n" if val == params[0] else ' '*(nr_of_blanks)+val+"\n")
def main(): def main():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment