Skip to content
Snippets Groups Projects
Commit 56b3b3dd authored by aboensch's avatar aboensch
Browse files

sort gl_types by having gl types before the rest

issue #483
parent 9240e15d
No related branches found
No related tags found
1 merge request!155Feature/#483 cleanup opengl mock
...@@ -32,20 +32,18 @@ def sortListAlphabetically(content): ...@@ -32,20 +32,18 @@ def sortListAlphabetically(content):
sub_content = content[content.find("[")+1:content.find("']")] sub_content = content[content.find("[")+1:content.find("']")]
params = sub_content.split("',") params = sub_content.split("',")
#if (params_to_be_sorted[1] not in prefix): params = sorted(params, key=lambda s: s.lower())
#params = sorted(params, key=lambda s: s.lower())
#else:
params = sorted(params)
if (params_to_be_sorted[1] in prefix): if (params_to_be_sorted[1] in prefix):
sub_content = SortGlewBeforeGl(params) sub_content = sortGlewBeforeGl(params)
elif (params_to_be_sorted[2] in prefix):
sub_content = sortGLBeforeRest(params)
else: 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):
def SortGlewBeforeGl(params):
d = defaultdict(list) d = defaultdict(list)
for val in params: for val in params:
d["glew" in val].append(val) d["glew" in val].append(val)
...@@ -54,6 +52,15 @@ def SortGlewBeforeGl(params): ...@@ -54,6 +52,15 @@ def SortGlewBeforeGl(params):
sortedParams += ','.join(str(p)+"'" for p in d[False]) sortedParams += ','.join(str(p)+"'" for p in d[False])
return sortedParams return sortedParams
def sortGLBeforeRest(params):
d = defaultdict(list)
for val in params:
d["GL" 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])
...@@ -63,7 +70,7 @@ def printToFile(file, content): ...@@ -63,7 +70,7 @@ def printToFile(file, content):
printWith80CharacterLimit(file, content, nr_of_blanks) printWith80CharacterLimit(file, content, nr_of_blanks)
def printWith80CharacterLimit(file, content, nr_of_blanks): def printWith80CharacterLimit(file, content, nr_of_blanks):
input = ('\n'+' '*nr_of_blanks+'').join(textwrap.wrap(content, input = ('\n'+' '*nr_of_blanks).join(textwrap.wrap(content,
80-nr_of_blanks)) 80-nr_of_blanks))
input += "\n" input += "\n"
file.write(input) file.write(input)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment