From ff3f537b38a2f69b5dc0a5addb9c227e873e6aa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl> Date: Wed, 6 Mar 2024 12:11:42 +0100 Subject: [PATCH] Fix a bug related with whereis --- satella/os/misc.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/satella/os/misc.py b/satella/os/misc.py index d01fcd4a..456aad4f 100644 --- a/satella/os/misc.py +++ b/satella/os/misc.py @@ -44,17 +44,17 @@ def safe_listdir(directory: str) -> tp.Iterator[str]: return -@silence_excs(FileNotFoundError) def _whereis(directory: str, name, available_extensions): for file in safe_listdir(directory): path = os.path.join(directory, file) - if 'x' in stat.filemode(os.stat(path).st_mode): - if sys.platform.startswith('win'): # a POSIX-specific check - file = file.upper() # paths are not case-sensitive on Windows - - for extension in available_extensions: - if file == '%s%s' % (name, extension): - yield path + with silence_excs(FileNotFoundError): + if 'x' in stat.filemode(os.stat(path).st_mode): + if sys.platform.startswith('win'): # a POSIX-specific check + file = file.upper() # paths are not case-sensitive on Windows + + for extension in available_extensions: + if file == '%s%s' % (name, extension): + yield path def is_running_as_root() -> bool: -- GitLab