diff options
author | Dan Goldsmith <djgoldsmith@googlemail.com> | 2014-04-11 16:22:29 +0100 |
---|---|---|
committer | Dan Goldsmith <djgoldsmith@googlemail.com> | 2014-04-11 16:22:29 +0100 |
commit | fe36ec0486cfc9aba10d8d87b0f42077ad1e78db (patch) | |
tree | 046fbf0baf2ae392120ed930aeafe63a6df83cb2 /lint.py | |
parent | 3804162e9a3f0e320867ffb45e09a43f9d0156c2 (diff) | |
parent | 3965c47e53a1c06c709048d932fe01dcf947c032 (diff) | |
download | pylint-fe36ec0486cfc9aba10d8d87b0f42077ad1e78db.tar.gz |
Merge with trunk
Diffstat (limited to 'lint.py')
-rw-r--r-- | lint.py | 42 |
1 files changed, 25 insertions, 17 deletions
@@ -1,4 +1,4 @@ -# Copyright (c) 2003-2013 LOGILAB S.A. (Paris, FRANCE). +# Copyright (c) 2003-2014 LOGILAB S.A. (Paris, FRANCE). # http://www.logilab.fr/ -- mailto:contact@logilab.fr # # This program is free software; you can redistribute it and/or modify it under @@ -12,7 +12,7 @@ # # You should have received a copy of the GNU General Public License along with # this program; if not, write to the Free Software Foundation, Inc., -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. """ %prog [options] module_or_package Check that a module satisfies a coding standard (and more !). @@ -29,6 +29,7 @@ # import this first to avoid builtin namespace pollution from pylint.checkers import utils +import functools import sys import os import tokenize @@ -389,7 +390,7 @@ warning, statement which respectively contain the number of errors / warnings\ value = check_csv(None, optname, value) if isinstance(value, (list, tuple)): for _id in value: - meth(_id) + meth(_id, ignore_unknown=True) else: meth(value) elif optname == 'output-format': @@ -622,7 +623,7 @@ warning, statement which respectively contain the number of errors / warnings\ self._ignore_file = False # fix the current file (if the source file was not available or # if it's actually a c extension) - self.current_file = astroid.file + self.current_file = astroid.file # pylint: disable=maybe-no-member self.check_astroid_module(astroid, walker, rawcheckers, tokencheckers) self._add_suppression_messages() # notify global end @@ -873,15 +874,20 @@ def preprocess_options(args, search_for): option, val = arg[2:], None try: cb, takearg = search_for[option] + except KeyError: + i += 1 + else: del args[i] if takearg and val is None: if i >= len(args) or args[i].startswith('-'): - raise ArgumentPreprocessingError(arg) + msg = 'Option %s expects a value' % option + raise ArgumentPreprocessingError(msg) val = args[i] del args[i] + elif not takearg and val is not None: + msg = "Option %s doesn't expects a value" % option + raise ArgumentPreprocessingError(msg) cb(option, val) - except KeyError: - i += 1 else: i += 1 @@ -901,12 +907,13 @@ group are mutually exclusive.'), self._plugins = [] try: preprocess_options(args, { - # option: (callback, takearg) - 'rcfile': (self.cb_set_rcfile, True), - 'load-plugins': (self.cb_add_plugins, True), - }) + # option: (callback, takearg) + 'init-hooks': (cb_init_hook, True), + 'rcfile': (self.cb_set_rcfile, True), + 'load-plugins': (self.cb_add_plugins, True), + }) except ArgumentPreprocessingError, ex: - print >> sys.stderr, 'Argument %s expects a value.' % (ex.args[0],) + print >> sys.stderr, ex sys.exit(32) self.linter = linter = self.LinterClass(( @@ -916,8 +923,9 @@ group are mutually exclusive.'), 'help' : 'Specify a configuration file.'}), ('init-hook', - {'action' : 'callback', 'type' : 'string', 'metavar': '<code>', - 'callback' : cb_init_hook, 'level': 1, + {'action' : 'callback', 'callback' : lambda *args: 1, + 'type' : 'string', 'metavar': '<code>', + 'level': 1, 'help' : 'Python code to execute, usually for sys.path \ manipulation such as pygtk.require().'}), @@ -1043,11 +1051,11 @@ are done by default'''}), sys.exit(self.linter.msg_status) def cb_set_rcfile(self, name, value): - """callback for option preprocessing (i.e. before optik parsing)""" + """callback for option preprocessing (i.e. before option parsing)""" self._rcfile = value def cb_add_plugins(self, name, value): - """callback for option preprocessing (i.e. before optik parsing)""" + """callback for option preprocessing (i.e. before option parsing)""" self._plugins.extend(splitstrip(value)) def cb_error_mode(self, *args, **kwargs): @@ -1086,7 +1094,7 @@ are done by default'''}), self.linter.list_messages() sys.exit(0) -def cb_init_hook(option, optname, value, parser): +def cb_init_hook(optname, value): """exec arbitrary code to set sys.path for instance""" exec value |