diff --git a/linkcheck/configuration.py b/linkcheck/configuration.py index c17aca29..0315f2be 100644 --- a/linkcheck/configuration.py +++ b/linkcheck/configuration.py @@ -234,12 +234,12 @@ class Configuration (dict): # system wide config settings config_dir = _linkchecker_configdata.config_dir path = normpath(os.path.join(config_dir, "linkcheckerrc")) - if os.path.exists(path): - cfiles.append(path) + cfiles.append(path) # per user config settings path = normpath("~/.linkchecker/linkcheckerrc") - if os.path.exists(path): - cfiles.append(path) + cfiles.append(path) + # weed out invalid files + cfiles = [f for f in cfiles if os.path.isfile(f)] self.read_config(cfiles) # re-init logger self['logger'] = self.logger_new('text') diff --git a/linkchecker b/linkchecker index 4f48eb73..9bae71d5 100755 --- a/linkchecker +++ b/linkchecker @@ -488,7 +488,6 @@ if has_optcomplete: # read and parse command line options and arguments (options, args) = optparser.parse_args() - # build a config object for this check session config = linkcheck.configuration.Configuration() # initialize logging @@ -505,14 +504,18 @@ if options.trace: options.psyco = False config.init_logging(debug=options.debug) -linkcheck.log.debug(linkcheck.LOG_CMDLINE, "Python %s on %s", +linkcheck.log.debug(linkcheck.LOG_CMDLINE, _("Python %s on %s"), sys.version, sys.platform) # read configuration files try: + files = [] if options.configfile: - config.read(files=[options.configfile]) - else: - config.read() + if os.path.isfile(options.configfile): + files.append(options.configfile) + else: + linkcheck.log.warn(linkcheck.LOG_CMDLINE, + _("Unreadable config file: %r"), options.configfile) + config.read(files=files) except linkcheck.LinkCheckerError, msg: # config error print_usage(str(msg))