From 56b3b3dd90f5d9194ecbb61a19ad2bbed85519c8 Mon Sep 17 00:00:00 2001 From: aboensch <boensch@vr.rwth-aachen.de> Date: Sat, 14 Jul 2018 16:30:47 +0200 Subject: [PATCH] sort gl_types by having gl types before the rest issue #483 --- .../mocks/generation/CleanUp_openGL_mock.py | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/src/mocks/generation/CleanUp_openGL_mock.py b/tests/src/mocks/generation/CleanUp_openGL_mock.py index 42733396..4fbd83e2 100644 --- a/tests/src/mocks/generation/CleanUp_openGL_mock.py +++ b/tests/src/mocks/generation/CleanUp_openGL_mock.py @@ -32,28 +32,35 @@ def sortListAlphabetically(content): sub_content = content[content.find("[")+1:content.find("']")] params = sub_content.split("',") - #if (params_to_be_sorted[1] not in prefix): - #params = sorted(params, key=lambda s: s.lower()) - #else: - params = sorted(params) + params = sorted(params, key=lambda s: s.lower()) 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: sub_content = ', '.join(str(val)+"'" for val in params) return (prefix+ " = [" + sub_content+"]") - -def SortGlewBeforeGl(params): +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 = ','.join(str(p)+"'" for p in d[True]) sortedParams += ',' sortedParams += ','.join(str(p)+"'" for p in d[False]) 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): nr_of_blanks = len(content[0:content.find("[")+1]) @@ -63,7 +70,7 @@ def printToFile(file, content): 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)) input += "\n" file.write(input) -- GitLab