[Piglit] [PATCH 4/9] framework/exectest.py: remove deprecated builtin use
Dylan Baker
baker.dylan.c at gmail.com
Wed Apr 9 18:27:22 PDT 2014
Upstream python considers map() and filter() deprecated in favor of
using comprehensions. These comprehensions are easier to read, and can
act as both a map and a filter at the same time. In this case we are
using generator comprehensions, which have an additional advantage of
lower memory consumption.
---
framework/exectest.py | 30 ++++++++++++++----------------
1 file changed, 14 insertions(+), 16 deletions(-)
diff --git a/framework/exectest.py b/framework/exectest.py
index a670ddd..ae397f0 100644
--- a/framework/exectest.py
+++ b/framework/exectest.py
@@ -295,23 +295,21 @@ class PiglitTest(Test):
def interpret_result(self, out, returncode, results):
outlines = out.split('\n')
- outpiglit = map(lambda s: s[7:],
- filter(lambda s: s.startswith('PIGLIT:'), outlines))
+ outpiglit = (s[7:] for s in outlines if s.startswith('PIGLIT:'))
- if len(outpiglit) > 0:
- try:
- for piglit in outpiglit:
- if piglit.startswith('subtest'):
- if not 'subtest' in results:
- results['subtest'] = {}
- results['subtest'].update(eval(piglit[7:]))
- else:
- results.update(eval(piglit))
- out = '\n'.join(filter(lambda s: not s.startswith('PIGLIT:'),
- outlines))
- except:
- results['result'] = 'fail'
- results['note'] = 'Failed to parse result string'
+ try:
+ for piglit in outpiglit:
+ if piglit.startswith('subtest'):
+ if not 'subtest' in results:
+ results['subtest'] = {}
+ results['subtest'].update(eval(piglit[7:]))
+ else:
+ results.update(eval(piglit))
+ out = '\n'.join(s for s in outlines if not
+ s.startswith('PIGLIT:'))
+ except:
+ results['result'] = 'fail'
+ results['note'] = 'Failed to parse result string'
if 'result' not in results:
results['result'] = 'fail'
--
1.9.1
More information about the Piglit
mailing list