Do not use 'with ... as ...' in validate_failures.py

Some of the hosts were we run this script are still using Python 2.4.
This patch replaces the use of 'with ... as ...' to avoid syntax errors.

2012-07-26   Diego Novillo  <dnovillo@google.com>

	* testsuite-management/validate_failures.py: Do not use
	'with ... as ...' constructs.

From-SVN: r189893
This commit is contained in:
Diego Novillo 2012-07-26 11:31:00 -04:00 committed by Diego Novillo
parent e902c26647
commit 55b073bae6
2 changed files with 23 additions and 14 deletions

View File

@ -1,3 +1,8 @@
2012-07-26 Diego Novillo <dnovillo@google.com>
* testsuite-management/validate_failures.py: Do not use
'with ... as ...' constructs.
2012-07-19 Diego Novillo <dnovillo@google.com> 2012-07-19 Diego Novillo <dnovillo@google.com>
* testsuite-management/validate_failures.py (CollectSumFiles): * testsuite-management/validate_failures.py (CollectSumFiles):

View File

@ -138,12 +138,14 @@ class TestResult(object):
def GetMakefileValue(makefile_name, value_name): def GetMakefileValue(makefile_name, value_name):
if os.path.exists(makefile_name): if os.path.exists(makefile_name):
with open(makefile_name) as makefile: makefile = open(makefile_name)
for line in makefile: for line in makefile:
if line.startswith(value_name): if line.startswith(value_name):
(_, value) = line.split('=', 1) (_, value) = line.split('=', 1)
value = value.strip() value = value.strip()
return value makefile.close()
return value
makefile.close()
return None return None
@ -173,10 +175,11 @@ def IsInterestingResult(line):
def ParseSummary(sum_fname): def ParseSummary(sum_fname):
"""Create a set of TestResult instances from the given summary file.""" """Create a set of TestResult instances from the given summary file."""
result_set = set() result_set = set()
with open(sum_fname) as sum_file: sum_file = open(sum_fname)
for line in sum_file: for line in sum_file:
if IsInterestingResult(line): if IsInterestingResult(line):
result_set.add(TestResult(line)) result_set.add(TestResult(line))
sum_file.close()
return result_set return result_set
@ -317,10 +320,11 @@ def ProduceManifest(options):
sum_files = GetSumFiles(options.results, options.build_dir) sum_files = GetSumFiles(options.results, options.build_dir)
actual = GetResults(sum_files) actual = GetResults(sum_files)
with open(manifest_name, 'w') as manifest_file: manifest_file = open(manifest_name, 'w')
for result in sorted(actual): for result in sorted(actual):
print result print result
manifest_file.write('%s\n' % result) manifest_file.write('%s\n' % result)
manifest_file.close()
return True return True