summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2015-05-18 17:11:03 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2015-05-18 17:11:03 -0700
commitc622337802f10f33dc803aef06171674bcb7f52a (patch)
treec6c8eb7787b72b5c9bf14479ff83bda76e19a196 /lib
parentf813d823a14f25a8f06c2f0bb7ba88db33c0af68 (diff)
downloadspack-c622337802f10f33dc803aef06171674bcb7f52a.tar.gz
spack-c622337802f10f33dc803aef06171674bcb7f52a.tar.bz2
spack-c622337802f10f33dc803aef06171674bcb7f52a.tar.xz
spack-c622337802f10f33dc803aef06171674bcb7f52a.zip
Remove redundancy: convert `with closing(open(...))` to `with open(...)`
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/cmd/create.py3
-rw-r--r--lib/spack/spack/cmd/mirror.py2
-rw-r--r--lib/spack/spack/cmd/python.py5
-rw-r--r--lib/spack/spack/config.py4
-rw-r--r--lib/spack/spack/modules.py3
-rw-r--r--lib/spack/spack/test/directory_layout.py5
-rw-r--r--lib/spack/spack/test/git_fetch.py1
-rw-r--r--lib/spack/spack/test/hg_fetch.py3
-rw-r--r--lib/spack/spack/test/install.py1
-rw-r--r--lib/spack/spack/test/link_tree.py1
-rw-r--r--lib/spack/spack/test/mock_repo.py3
-rw-r--r--lib/spack/spack/test/python_version.py3
-rw-r--r--lib/spack/spack/test/stage.py6
-rw-r--r--lib/spack/spack/test/svn_fetch.py1
-rw-r--r--lib/spack/spack/util/crypto.py3
15 files changed, 14 insertions, 30 deletions
diff --git a/lib/spack/spack/cmd/create.py b/lib/spack/spack/cmd/create.py
index c09b9a3e36..c734f58b99 100644
--- a/lib/spack/spack/cmd/create.py
+++ b/lib/spack/spack/cmd/create.py
@@ -26,7 +26,6 @@ import string
import os
import hashlib
import re
-from contextlib import closing
from external.ordereddict import OrderedDict
import llnl.util.tty as tty
@@ -192,7 +191,7 @@ def create(parser, args):
tty.die("Could not fetch any tarballs for %s." % name)
# Write out a template for the file
- with closing(open(pkg_path, "w")) as pkg_file:
+ with open(pkg_path, "w") as pkg_file:
pkg_file.write(
package_template.substitute(
name=name,
diff --git a/lib/spack/spack/cmd/mirror.py b/lib/spack/spack/cmd/mirror.py
index 02a1467ee6..2356170a9a 100644
--- a/lib/spack/spack/cmd/mirror.py
+++ b/lib/spack/spack/cmd/mirror.py
@@ -103,7 +103,7 @@ def mirror_list(args):
def _read_specs_from_file(filename):
- with closing(open(filename, "r")) as stream:
+ with open(filename, "r") as stream:
for i, string in enumerate(stream):
try:
s = Spec(string)
diff --git a/lib/spack/spack/cmd/python.py b/lib/spack/spack/cmd/python.py
index 86b8c827f8..7bd2e45ce0 100644
--- a/lib/spack/spack/cmd/python.py
+++ b/lib/spack/spack/cmd/python.py
@@ -27,7 +27,6 @@ import sys
import code
from external import argparse
import platform
-from contextlib import closing
import spack
@@ -44,13 +43,13 @@ def python(parser, args):
if "PYTHONSTARTUP" in os.environ:
startup_file = os.environ["PYTHONSTARTUP"]
if os.path.isfile(startup_file):
- with closing(open(startup_file)) as startup:
+ with open(startup_file) as startup:
console.runsource(startup.read(), startup_file, 'exec')
python_args = args.python_args
if python_args:
sys.argv = python_args
- with closing(open(python_args[0])) as file:
+ with open(python_args[0]) as file:
console.runsource(file.read(), python_args[0], 'exec')
else:
console.interact("Spack version %s\nPython %s, %s %s"""
diff --git a/lib/spack/spack/config.py b/lib/spack/spack/config.py
index 34dee86473..3e91958c2c 100644
--- a/lib/spack/spack/config.py
+++ b/lib/spack/spack/config.py
@@ -94,7 +94,6 @@ from external.ordereddict import OrderedDict
from llnl.util.lang import memoized
import spack.error
-from contextlib import closing
from external import yaml
from external.yaml.error import MarkedYAMLError
import llnl.util.tty as tty
@@ -325,7 +324,7 @@ def remove_from_config(category_name, key_to_rm, scope=None):
continue
if not key_to_rm in result[category_name]:
continue
- with closing(open(path, 'w')) as f:
+ with open(path, 'w') as f:
result[category_name].pop(key_to_rm, None)
yaml.dump(result, stream=f, default_flow_style=False)
category.result_dict.pop(key_to_rm, None)
@@ -339,4 +338,3 @@ def print_category(category_name):
tty.die("Unknown config category %s. Valid options are: %s" %
(category_name, ", ".join([s for s in _config_sections])))
yaml.dump(get_config(category_name), stream=sys.stdout, default_flow_style=False)
-
diff --git a/lib/spack/spack/modules.py b/lib/spack/spack/modules.py
index 7d2ca97a62..493c454f1d 100644
--- a/lib/spack/spack/modules.py
+++ b/lib/spack/spack/modules.py
@@ -50,7 +50,6 @@ import re
import textwrap
import shutil
from glob import glob
-from contextlib import closing
import llnl.util.tty as tty
from llnl.util.filesystem import join_path, mkdirp
@@ -152,7 +151,7 @@ class EnvModule(object):
if not self.paths:
return
- with closing(open(self.file_name, 'w')) as f:
+ with open(self.file_name, 'w') as f:
self._write(f)
diff --git a/lib/spack/spack/test/directory_layout.py b/lib/spack/spack/test/directory_layout.py
index 7ca84090f2..beac038410 100644
--- a/lib/spack/spack/test/directory_layout.py
+++ b/lib/spack/spack/test/directory_layout.py
@@ -29,7 +29,6 @@ import unittest
import tempfile
import shutil
import os
-from contextlib import closing
from llnl.util.filesystem import *
@@ -52,7 +51,7 @@ class DirectoryLayoutTest(unittest.TestCase):
def tearDown(self):
- #shutil.rmtree(self.tmpdir, ignore_errors=True)
+ shutil.rmtree(self.tmpdir, ignore_errors=True)
self.layout = None
@@ -95,7 +94,7 @@ class DirectoryLayoutTest(unittest.TestCase):
self.assertTrue(spec_from_file.concrete)
# Ensure that specs that come out "normal" are really normal.
- with closing(open(spec_path)) as spec_file:
+ with open(spec_path) as spec_file:
read_separately = Spec.from_yaml(spec_file.read())
read_separately.normalize()
diff --git a/lib/spack/spack/test/git_fetch.py b/lib/spack/spack/test/git_fetch.py
index da57f87bd0..9700bd7533 100644
--- a/lib/spack/spack/test/git_fetch.py
+++ b/lib/spack/spack/test/git_fetch.py
@@ -26,7 +26,6 @@ import os
import unittest
import shutil
import tempfile
-from contextlib import closing
from llnl.util.filesystem import *
diff --git a/lib/spack/spack/test/hg_fetch.py b/lib/spack/spack/test/hg_fetch.py
index e1ab2cffe6..531dfabaa1 100644
--- a/lib/spack/spack/test/hg_fetch.py
+++ b/lib/spack/spack/test/hg_fetch.py
@@ -24,9 +24,6 @@
##############################################################################
import os
import unittest
-import shutil
-import tempfile
-from contextlib import closing
from llnl.util.filesystem import *
diff --git a/lib/spack/spack/test/install.py b/lib/spack/spack/test/install.py
index d240a393a6..5659e97a4d 100644
--- a/lib/spack/spack/test/install.py
+++ b/lib/spack/spack/test/install.py
@@ -26,7 +26,6 @@ import os
import unittest
import shutil
import tempfile
-from contextlib import closing
from llnl.util.filesystem import *
diff --git a/lib/spack/spack/test/link_tree.py b/lib/spack/spack/test/link_tree.py
index bc7c2c6b5e..9e887ecc49 100644
--- a/lib/spack/spack/test/link_tree.py
+++ b/lib/spack/spack/test/link_tree.py
@@ -26,7 +26,6 @@ import os
import unittest
import shutil
import tempfile
-from contextlib import closing
from llnl.util.filesystem import *
from llnl.util.link_tree import LinkTree
diff --git a/lib/spack/spack/test/mock_repo.py b/lib/spack/spack/test/mock_repo.py
index 659f29067a..fd184e64bc 100644
--- a/lib/spack/spack/test/mock_repo.py
+++ b/lib/spack/spack/test/mock_repo.py
@@ -24,7 +24,6 @@
##############################################################################
import os
import shutil
-from contextlib import closing
from llnl.util.filesystem import *
@@ -67,7 +66,7 @@ class MockArchive(MockRepo):
with working_dir(self.path):
configure = join_path(self.path, 'configure')
- with closing(open(configure, 'w')) as cfg_file:
+ with open(configure, 'w') as cfg_file:
cfg_file.write(
"#!/bin/sh\n"
"prefix=$(echo $1 | sed 's/--prefix=//')\n"
diff --git a/lib/spack/spack/test/python_version.py b/lib/spack/spack/test/python_version.py
index f814df3226..06d87e11ad 100644
--- a/lib/spack/spack/test/python_version.py
+++ b/lib/spack/spack/test/python_version.py
@@ -31,7 +31,6 @@ Spack was originally 2.7, but enough systems in 2014 are still using
import unittest
import os
import re
-from contextlib import closing
import llnl.util.tty as tty
@@ -62,7 +61,7 @@ class PythonVersionTest(unittest.TestCase):
all_issues = {}
for fn in self.spack_python_files():
- with closing(open(fn)) as pyfile:
+ with open(fn) as pyfile:
versions = pyqver2.get_versions(pyfile.read())
for ver, reasons in versions.items():
if ver > spack_max_version:
diff --git a/lib/spack/spack/test/stage.py b/lib/spack/spack/test/stage.py
index c5a7013675..8cff8f7960 100644
--- a/lib/spack/spack/test/stage.py
+++ b/lib/spack/spack/test/stage.py
@@ -76,7 +76,7 @@ class StageTest(unittest.TestCase):
mkdirp(archive_dir_path)
mkdirp(test_tmp_path)
- with closing(open(test_readme, 'w')) as readme:
+ with open(test_readme, 'w') as readme:
readme.write(readme_text)
with working_dir(test_files_dir):
@@ -161,7 +161,7 @@ class StageTest(unittest.TestCase):
readme = join_path(stage_path, archive_dir, readme_name)
self.assertTrue(os.path.isfile(readme))
- with closing(open(readme)) as file:
+ with open(readme) as file:
self.assertEqual(readme_text, file.read())
@@ -289,7 +289,7 @@ class StageTest(unittest.TestCase):
self.check_chdir_to_source(stage, stage_name)
# Try to make a file in the old archive dir
- with closing(open('foobar', 'w')) as file:
+ with open('foobar', 'w') as file:
file.write("this file is to be destroyed.")
self.assertTrue('foobar' in os.listdir(stage.source_path))
diff --git a/lib/spack/spack/test/svn_fetch.py b/lib/spack/spack/test/svn_fetch.py
index 0159fb087f..184fe8faa1 100644
--- a/lib/spack/spack/test/svn_fetch.py
+++ b/lib/spack/spack/test/svn_fetch.py
@@ -27,7 +27,6 @@ import re
import unittest
import shutil
import tempfile
-from contextlib import closing
from llnl.util.filesystem import *
diff --git a/lib/spack/spack/util/crypto.py b/lib/spack/spack/util/crypto.py
index 950e807596..8a8574cd3d 100644
--- a/lib/spack/spack/util/crypto.py
+++ b/lib/spack/spack/util/crypto.py
@@ -23,7 +23,6 @@
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
##############################################################################
import hashlib
-from contextlib import closing
"""Set of acceptable hashes that Spack will use."""
_acceptable_hashes = [
@@ -44,7 +43,7 @@ def checksum(hashlib_algo, filename, **kwargs):
"""
block_size = kwargs.get('block_size', 2**20)
hasher = hashlib_algo()
- with closing(open(filename)) as file:
+ with open(filename) as file:
while True:
data = file.read(block_size)
if not data: