Skip to content

Commit 5351639

Browse files
authored
Merge pull request #1522 from stonebig/master
modernise to Pathlib
2 parents 604ddea + d6551e9 commit 5351639

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

make.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ def copy_items(source_directories: list[Path], target_directory: Path, verbose:
8989
if not source_dir.is_dir():
9090
print(f"Warning: Source directory not found: {source_dir}")
9191
continue
92-
for item_name in os.listdir(source_dir):
93-
source_item = source_dir / item_name
94-
target_item = target_directory / item_name
92+
for source_item in source_dir.iterdir():
93+
target_item = target_directory / source_item.name
9594
copy_function = shutil.copytree if source_item.is_dir() else shutil.copy2
9695
try:
9796
copy_function(source_item, target_item)
@@ -149,9 +148,9 @@ def __init__(self, build_number: int, release_level: str, target_directory: Path
149148

150149
def _get_python_zip_file(self) -> Path:
151150
"""Finds the Python .zip file in the wheels directory."""
152-
for filename in os.listdir(self.wheels_directory):
153-
if re.match("(pypy3|python-)([0-9]|[a-zA-Z]|.)*.zip", filename):
154-
return self.wheels_directory / filename
151+
for source_item in self.wheels_directory.iterdir():
152+
if re.match("(pypy3|python-)([0-9]|[a-zA-Z]|.)*.zip", source_item.name):
153+
return source_item
155154
raise RuntimeError(f"Could not find Python zip package in {self.wheels_directory}")
156155

157156
@property

0 commit comments

Comments
 (0)