88from pathlib import Path
99
1010
11- def _is_dir (path : Path ) -> bool :
12- """``path.is_dir()``, but False instead of raising on an inaccessible path.
13-
14- This walks directories nobody here controls, so it has to tolerate whatever
15- it runs into. Path.is_dir() only swallows the errnos in pathlib's ignore
16- list, and raises for the rest (EACCES, ENAMETOOLONG); os.path.isdir, which
17- this replaces, returned False for all of them.
18- """
19- try :
20- return path .is_dir ()
21- except OSError :
22- return False
23-
24-
2511def find_sub_dirs_no_cache (parent_dirs : Sequence [str ], sub_dirs : Sequence [str ]) -> list [str ]:
2612 # Results stay str: they are consumed by _binaries, _dynamic_libs, _headers
2713 # and _static_libs, so the type flip belongs in its own change.
@@ -31,7 +17,7 @@ def find_sub_dirs_no_cache(parent_dirs: Sequence[str], sub_dirs: Sequence[str])
3117 while stack :
3218 current_path , idx = stack .pop ()
3319 if idx == len (sub_dirs ):
34- if _is_dir ( current_path ):
20+ if current_path . is_dir ( ):
3521 results .append (str (current_path ))
3622 continue
3723
@@ -42,11 +28,11 @@ def find_sub_dirs_no_cache(parent_dirs: Sequence[str], sub_dirs: Sequence[str])
4228 except OSError :
4329 continue
4430 for entry_path in entries :
45- if _is_dir ( entry_path ):
31+ if entry_path . is_dir ( ):
4632 stack .append ((entry_path , idx + 1 ))
4733 else :
4834 next_path = current_path / sub
49- if _is_dir ( next_path ):
35+ if next_path . is_dir ( ):
5036 stack .append ((next_path , idx + 1 ))
5137 return results
5238
0 commit comments