diff options
author | Mike Taves <mwtoews@gmail.com> | 2022-10-28 22:37:29 +1300 |
---|---|---|
committer | Mike Taves <mwtoews@gmail.com> | 2022-10-29 14:08:54 +1300 |
commit | 080cf82ebc5858ec47eff0d49bdf48b74f955274 (patch) | |
tree | c843b284d9994186ab988c7c535a895433ae9905 /numpy/distutils | |
parent | a8ebbd5fdb9df3d1d2885b24e783757d747dec8e (diff) | |
download | numpy-080cf82ebc5858ec47eff0d49bdf48b74f955274.tar.gz |
MAINT: remove redundant open() modes and io.open() alias
Diffstat (limited to 'numpy/distutils')
-rw-r--r-- | numpy/distutils/ccompiler.py | 2 | ||||
-rw-r--r-- | numpy/distutils/command/build_ext.py | 4 | ||||
-rw-r--r-- | numpy/distutils/command/build_src.py | 4 | ||||
-rw-r--r-- | numpy/distutils/command/install.py | 2 | ||||
-rw-r--r-- | numpy/distutils/fcompiler/ibm.py | 2 | ||||
-rw-r--r-- | numpy/distutils/misc_util.py | 4 | ||||
-rw-r--r-- | numpy/distutils/system_info.py | 8 | ||||
-rw-r--r-- | numpy/distutils/tests/test_system_info.py | 4 |
8 files changed, 15 insertions, 15 deletions
diff --git a/numpy/distutils/ccompiler.py b/numpy/distutils/ccompiler.py index f0487cb64..8e71266ee 100644 --- a/numpy/distutils/ccompiler.py +++ b/numpy/distutils/ccompiler.py @@ -57,7 +57,7 @@ def _needs_build(obj, cc_args, extra_postargs, pp_opts): # the last line contains the compiler commandline arguments as some # projects may compile an extension multiple times with different # arguments - with open(dep_file, "r") as f: + with open(dep_file) as f: lines = f.readlines() cmdline =_commandline_dep_string(cc_args, extra_postargs, pp_opts) diff --git a/numpy/distutils/command/build_ext.py b/numpy/distutils/command/build_ext.py index 8b568c159..8ab1c2684 100644 --- a/numpy/distutils/command/build_ext.py +++ b/numpy/distutils/command/build_ext.py @@ -634,12 +634,12 @@ class build_ext (old_build_ext): if os.path.isfile(fake_lib): # Replace fake static library libraries.remove(lib) - with open(fake_lib, 'r') as f: + with open(fake_lib) as f: unlinkable_fobjects.extend(f.read().splitlines()) # Expand C objects c_lib = os.path.join(libdir, lib + '.cobjects') - with open(c_lib, 'r') as f: + with open(c_lib) as f: objects.extend(f.read().splitlines()) # Wrap unlinkable objects to a linkable one diff --git a/numpy/distutils/command/build_src.py b/numpy/distutils/command/build_src.py index 5581011f6..bf3d03c70 100644 --- a/numpy/distutils/command/build_src.py +++ b/numpy/distutils/command/build_src.py @@ -725,7 +725,7 @@ _has_c_header = re.compile(r'-\*-\s*c\s*-\*-', re.I).search _has_cpp_header = re.compile(r'-\*-\s*c\+\+\s*-\*-', re.I).search def get_swig_target(source): - with open(source, 'r') as f: + with open(source) as f: result = None line = f.readline() if _has_cpp_header(line): @@ -735,7 +735,7 @@ def get_swig_target(source): return result def get_swig_modulename(source): - with open(source, 'r') as f: + with open(source) as f: name = None for line in f: m = _swig_module_name_match(line) diff --git a/numpy/distutils/command/install.py b/numpy/distutils/command/install.py index 2eff2d145..efa9b4740 100644 --- a/numpy/distutils/command/install.py +++ b/numpy/distutils/command/install.py @@ -62,7 +62,7 @@ class install(old_install): # bdist_rpm fails when INSTALLED_FILES contains # paths with spaces. Such paths must be enclosed # with double-quotes. - with open(self.record, 'r') as f: + with open(self.record) as f: lines = [] need_rewrite = False for l in f: diff --git a/numpy/distutils/fcompiler/ibm.py b/numpy/distutils/fcompiler/ibm.py index eff24401a..29927518c 100644 --- a/numpy/distutils/fcompiler/ibm.py +++ b/numpy/distutils/fcompiler/ibm.py @@ -76,7 +76,7 @@ class IBMFCompiler(FCompiler): xlf_cfg = '/etc/opt/ibmcmp/xlf/%s/xlf.cfg' % version fo, new_cfg = make_temp_file(suffix='_xlf.cfg') log.info('Creating '+new_cfg) - with open(xlf_cfg, 'r') as fi: + with open(xlf_cfg) as fi: crt1_match = re.compile(r'\s*crt\s*=\s*(?P<path>.*)/crt1.o').match for line in fi: m = crt1_match(line) diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py index 79ba08515..e226b4744 100644 --- a/numpy/distutils/misc_util.py +++ b/numpy/distutils/misc_util.py @@ -475,7 +475,7 @@ def _get_f90_modules(source): if not f90_ext_match(source): return [] modules = [] - with open(source, 'r') as f: + with open(source) as f: for line in f: m = f90_module_name_match(line) if m: @@ -1932,7 +1932,7 @@ class Configuration: revision0 = f.read().strip() branch_map = {} - with open(branch_cache_fn, 'r') as f: + with open(branch_cache_fn) as f: for line in f: branch1, revision1 = line.split()[:2] if revision1==revision0: diff --git a/numpy/distutils/system_info.py b/numpy/distutils/system_info.py index d5a1687da..5a87c080d 100644 --- a/numpy/distutils/system_info.py +++ b/numpy/distutils/system_info.py @@ -1260,7 +1260,7 @@ class mkl_info(system_info): paths = os.environ.get('LD_LIBRARY_PATH', '').split(os.pathsep) ld_so_conf = '/etc/ld.so.conf' if os.path.isfile(ld_so_conf): - with open(ld_so_conf, 'r') as f: + with open(ld_so_conf) as f: for d in f: d = d.strip() if d: @@ -2190,7 +2190,7 @@ class blas_info(system_info): }""") src = os.path.join(tmpdir, 'source.c') try: - with open(src, 'wt') as f: + with open(src, 'w') as f: f.write(s) try: @@ -2345,7 +2345,7 @@ class openblas_info(blas_info): except Exception: extra_args = [] try: - with open(src, 'wt') as f: + with open(src, 'w') as f: f.write(s) obj = c.compile([src], output_dir=tmpdir) try: @@ -2456,7 +2456,7 @@ class flame_info(system_info): # Add the additional "extra" arguments extra_args = info.get('extra_link_args', []) try: - with open(src, 'wt') as f: + with open(src, 'w') as f: f.write(s) obj = c.compile([src], output_dir=tmpdir) try: diff --git a/numpy/distutils/tests/test_system_info.py b/numpy/distutils/tests/test_system_info.py index eb7235e04..66304a5e5 100644 --- a/numpy/distutils/tests/test_system_info.py +++ b/numpy/distutils/tests/test_system_info.py @@ -271,7 +271,7 @@ class TestSystemInfoReading: # But if we copy the values to a '[mkl]' section the value # is correct - with open(cfg, 'r') as fid: + with open(cfg) as fid: mkl = fid.read().replace('[ALL]', '[mkl]', 1) with open(cfg, 'w') as fid: fid.write(mkl) @@ -279,7 +279,7 @@ class TestSystemInfoReading: assert info.get_lib_dirs() == lib_dirs # Also, the values will be taken from a section named '[DEFAULT]' - with open(cfg, 'r') as fid: + with open(cfg) as fid: dflt = fid.read().replace('[mkl]', '[DEFAULT]', 1) with open(cfg, 'w') as fid: fid.write(dflt) |