[javascriptlint-commit] SF.net SVN: javascriptlint:[353] trunk/javascriptlint
Status: Beta
Brought to you by:
matthiasmiller
From: <mat...@us...> - 2014-10-27 22:23:33
|
Revision: 353 http://sourceforge.net/p/javascriptlint/code/353 Author: matthiasmiller Date: 2014-10-27 22:23:26 +0000 (Mon, 27 Oct 2014) Log Message: ----------- Format configuration errors correctly. Modified Paths: -------------- trunk/javascriptlint/conf.py trunk/javascriptlint/jsl.py Modified: trunk/javascriptlint/conf.py =================================================================== --- trunk/javascriptlint/conf.py 2014-10-27 19:42:54 UTC (rev 352) +++ trunk/javascriptlint/conf.py 2014-10-27 22:23:26 UTC (rev 353) @@ -244,7 +244,10 @@ parm = line[len(name):].lstrip() # Load the setting - setting = self._settings[name] + try: + setting = self._settings[name] + except KeyError: + raise ConfError('Unrecognized setting: %s' % name) args = { 'enabled': enabled } Modified: trunk/javascriptlint/jsl.py =================================================================== --- trunk/javascriptlint/jsl.py 2014-10-27 19:42:54 UTC (rev 352) +++ trunk/javascriptlint/jsl.py 2014-10-27 22:23:26 UTC (rev 353) @@ -2,6 +2,7 @@ # vim: ts=4 sw=4 expandtab import codecs import fnmatch +import functools import glob import os import sys @@ -27,12 +28,14 @@ script = fs.readfile(path, encoding) jsparse.dump_tree(script) +def _lint_warning(conf_, path, line, col, errname, errdesc): + _lint_results['warnings'] = _lint_results['warnings'] + 1 + print util.format_error(conf_['output-format'], path, line, col, + errname, errdesc) + def _lint(paths, conf_, printpaths, encoding): - def lint_error(path, line, col, errname, errdesc): - _lint_results['warnings'] = _lint_results['warnings'] + 1 - print util.format_error(conf_['output-format'], path, line, col, - errname, errdesc) - lint.lint_files(paths, lint_error, encoding, conf=conf_, printpaths=printpaths) + lint.lint_files(paths, functools.partial(_lint_warning, conf_), encoding, + conf=conf_, printpaths=printpaths) def _resolve_paths(path, recurse): # Build a list of directories @@ -116,7 +119,11 @@ conf_ = conf.Conf() if options.conf: - conf_.loadfile(options.conf) + try: + conf_.loadfile(options.conf) + except conf.ConfError, error: + _lint_warning(conf_, error.path, error.lineno, 0, 'conf_error', + unicode(error)) profile_func = _profile_disabled if options.profile: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |