diff --git a/linkcheck/command/linkchecker.py b/linkcheck/command/linkchecker.py index 00cdf578..f4c5ff47 100644 --- a/linkcheck/command/linkchecker.py +++ b/linkcheck/command/linkchecker.py @@ -135,7 +135,7 @@ def linkchecker(): files = [] if options.configfile: path = configuration.normpath(options.configfile) - if os.path.isfile(path): + if fileutil.is_valid_config_source(path): files.append(path) else: log.warn( diff --git a/linkcheck/configuration/__init__.py b/linkcheck/configuration/__init__.py index 1a8f82f0..09214851 100644 --- a/linkcheck/configuration/__init__.py +++ b/linkcheck/configuration/__init__.py @@ -222,7 +222,7 @@ class Configuration(dict): # filter invalid files filtered_cfiles = [] for cfile in cfiles: - if not os.path.isfile(cfile): + if not fileutil.is_valid_config_source(cfile): log.warn(LOG_CHECK, _("Configuration file %r does not exist."), cfile) elif not fileutil.is_readable(cfile): log.warn(LOG_CHECK, _("Configuration file %r is not readable."), cfile) diff --git a/linkcheck/fileutil.py b/linkcheck/fileutil.py index eb9bb91e..db574500 100644 --- a/linkcheck/fileutil.py +++ b/linkcheck/fileutil.py @@ -89,8 +89,8 @@ def is_tty(fp): @lru_cache(128) def is_readable(filename): - """Check if file is a regular file and is readable.""" - return os.path.isfile(filename) and os.access(filename, os.R_OK) + """Check if file is readable.""" + return os.access(filename, os.R_OK) def is_accessable_by_others(filename): @@ -103,3 +103,8 @@ def is_writable_by_others(filename): """Check if file or directory is world writable.""" mode = os.stat(filename)[stat.ST_MODE] return mode & stat.S_IWOTH + + +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)