Skip to content

Commit 3d7d4f1

Browse files
committed
chore: use proper file reading APIs
1 parent bbe48e1 commit 3d7d4f1

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

toolshed/build_pathfinder_dlls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import collections
1313
import sys
14+
from pathlib import Path
1415

1516
# ATTENTION: Ambiguous shorter names need to appear after matching longer names
1617
# (e.g. "cufft" after "cufftw")
@@ -61,7 +62,7 @@ def is_suppressed_dll(libname, dll):
6162
def run(args):
6263
dlls_from_files = set()
6364
for filename in args:
64-
lines_iter = iter(open(filename).read().splitlines())
65+
lines_iter = iter(Path(filename).read_text().splitlines())
6566
for line in lines_iter:
6667
if line.startswith("-------------------"):
6768
break

toolshed/build_pathfinder_sonames.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# The output of this script is expected to be usable as-is.
1111

1212
import sys
13+
from pathlib import Path
1314

1415
LIBNAMES_IN_SCOPE_OF_CUDA_PATHFINDER = (
1516
"nvJitLink",
@@ -47,7 +48,7 @@ def run(args):
4748
assert len(args) == 1, "output-of-find_sonames.sh"
4849

4950
sonames_from_file = set()
50-
for line in open(args[0]).read().splitlines():
51+
for line in Path(args[0]).read_text().splitlines():
5152
flds = line.split()
5253
assert len(flds) == 3, flds
5354
if flds[-1] != "SONAME_NOT_SET":

toolshed/reformat_cuda_enums_as_py.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
# SPDX-License-Identifier: Apache-2.0
55

66
import sys
7+
from pathlib import Path
78

89

910
def extract_enum_block(header_file_lines):
@@ -101,7 +102,7 @@ def run(args):
101102
)
102103
sys.exit(1)
103104

104-
header_file_text = open(sys.argv[1]).read().splitlines()
105+
header_file_text = Path(sys.argv[1]).read_text().splitlines()
105106
python_dict_name, enum_block = extract_enum_block(header_file_text)
106107
entries = parse_enum_doc_and_value_pairs(enum_block)
107108
emit_python_dict(python_dict_name, entries)

0 commit comments

Comments
 (0)