[Piglit] [PATCH 13/20] framework: Update sequence type usage to support Python 3.x as well as Python 2.x.

Jon Severinsson jon at severinsson.net
Fri Apr 12 16:39:55 PDT 2013


---
 framework/core.py      |    2 +-
 framework/exectest.py  |    2 +-
 piglit-summary-html.py |   11 +++++------
 3 filer ändrade, 7 tillägg(+), 8 borttagningar(-)

diff --git a/framework/core.py b/framework/core.py
index 7c54d55..8543520 100644
--- a/framework/core.py
+++ b/framework/core.py
@@ -503,7 +503,7 @@ class Test:
 
 	# Default handling for stderr messages
 	def handleErr(self, results, err):
-		errors = filter(lambda s: len(s) > 0, map(lambda s: s.strip(), err.split('\n')))
+		errors = list(filter(lambda s: len(s) > 0, map(lambda s: s.strip(), err.split('\n'))))
 
 		ignored = [s for s in errors if self.isIgnored(s)]
 		errors = [s for s in errors if s not in ignored]
diff --git a/framework/exectest.py b/framework/exectest.py
index 2386e80..a25f433 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -231,7 +231,7 @@ class PlainExecTest(ExecTest):
 
 	def interpretResult(self, out, returncode, results):
 		outlines = out.split('\n')
-		outpiglit = map(lambda s: s[7:], filter(lambda s: s.startswith('PIGLIT:'), outlines))
+		outpiglit = list(map(lambda s: s[7:], filter(lambda s: s.startswith('PIGLIT:'), outlines)))
 
 		if len(outpiglit) > 0:
 			try:
diff --git a/piglit-summary-html.py b/piglit-summary-html.py
index c2c2df5..b273f88 100755
--- a/piglit-summary-html.py
+++ b/piglit-summary-html.py
@@ -38,7 +38,7 @@ import framework.summary
 #############################################################################
 
 def testPathToHtmlFilename(path):
-	return 'test_' + filter(lambda s: s.isalnum() or s == '_', path.replace('/', '__')) + '.html'
+	return 'test_' + "".join(filter(lambda s: s.isalnum() or s == '_', path.replace('/', '__'))) + '.html'
 
 
 #############################################################################
@@ -109,7 +109,7 @@ def buildDetails(testResult):
 		value = buildDetailValue(testResult[name])
 		details += [(name, value)]
 
-	details.sort(lambda a, b: len(a[1])-len(b[1]))
+	details.sort(key=lambda x: len(x[1]))
 
 	text = ''
 	alternate = 'a'
@@ -213,7 +213,7 @@ def buildGroupSummary(indent, groupsummary, showcurrent):
 	elif showcurrent == 'skipped':
 		names = filter(lambda n: groupsummary.children[n].skipped, names)
 
-	names.sort()
+	names = sorted(names)
 	for n in names:
 		child = groupsummary.children[n]
 		if isinstance(child, framework.summary.GroupSummary):
@@ -255,8 +255,7 @@ results is an array containing the top-level results dictionarys.
 	testruns = "".join([IndexTestrun % tr.__dict__ for tr in summary.testruns])
 	testrunsb = "".join([testrunb(tr) for tr in summary.testruns])
 
-	tolist = SummaryPages.keys()
-	tolist.sort()
+	tolist = sorted(SummaryPages.keys())
 	showlinks = " | ".join([link(to) for to in tolist])
 
 	writefile(summaryDir + '/' + SummaryPages[showcurrent], Index % locals())
@@ -330,7 +329,7 @@ def main():
 	summary = framework.summary.Summary(results)
 	for j in range(len(summary.testruns)):
 		tr = summary.testruns[j]
-		tr.codename = filter(lambda s: s.isalnum(), tr.name)
+		tr.codename = "".join(filter(lambda s: s.isalnum(), tr.name))
 		dirname = summaryDir + '/' + tr.codename
 		core.checkDir(dirname, False)
 		writeTestrunHtml(tr, dirname + '/index.html')
-- 
1.7.10.4



More information about the Piglit mailing list