This commit is contained in:
paintedblue 2023-11-08 18:22:05 +09:00 committed by GitHub
commit 82e28383be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,7 +50,6 @@ def which(program):
"""Returns `program` path or `None`."""
try:
from shutil import which
return which(program)
except ImportError:
def is_exe(fpath):
@ -62,14 +61,18 @@ def which(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
# Strip only the whitespace by default
path = path.strip()
# Remove only the surrounding double quotes, if any
if path.startswith('"') and path.endswith('"'):
path = path[1:-1]
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
def default_settings(params):
"""Adds default values to settings if it not presented.