Avoid FileNotFoundError if FILENAME does not exist

File ".../linkcheck/fileutil.py", line 110, in is_valid_config_source
    return os.path.isfile(filename) or stat.S_ISFIFO(os.stat(filename).st_mode)
                                                     ^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory
This commit is contained in:
Chris Mayo 2023-11-13 19:22:12 +00:00
parent eeee80ec4f
commit 7a3be9ba93

View file

@ -107,4 +107,5 @@ def is_writable_by_others(filename):
def is_valid_config_source(filename):
"""Check if the file is a valid config file."""
return os.path.isfile(filename) or stat.S_ISFIFO(os.stat(filename).st_mode)
return os.path.exists(filename) and (
os.path.isfile(filename) or stat.S_ISFIFO(os.stat(filename).st_mode))