From d83720f05d51184bfbc3d066e5fe3e4540d3fda3 Mon Sep 17 00:00:00 2001 From: calvin Date: Thu, 13 Oct 2005 21:15:31 +0000 Subject: [PATCH] do not parse any invalid config files git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@2895 e7d03fd6-7b0d-0410-9947-9c21f3af8025 --- linkcheck/configuration.py | 8 ++++---- linkchecker | 13 ++++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) 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))