summaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorDan Goldsmith <djgoldsmith@googlemail.com>2014-04-11 16:22:29 +0100
committerDan Goldsmith <djgoldsmith@googlemail.com>2014-04-11 16:22:29 +0100
commitfe36ec0486cfc9aba10d8d87b0f42077ad1e78db (patch)
tree046fbf0baf2ae392120ed930aeafe63a6df83cb2 /utils.py
parent3804162e9a3f0e320867ffb45e09a43f9d0156c2 (diff)
parent3965c47e53a1c06c709048d932fe01dcf947c032 (diff)
downloadpylint-fe36ec0486cfc9aba10d8d87b0f42077ad1e78db.tar.gz
Merge with trunk
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py34
1 files changed, 25 insertions, 9 deletions
diff --git a/utils.py b/utils.py
index 59e22a5..e1cb3a8 100644
--- a/utils.py
+++ b/utils.py
@@ -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.
"""some various utilities and helper classes, most of them used in the
main pylint class
"""
@@ -247,7 +247,7 @@ class MessagesHandlerMixIn(object):
self._alternative_names[old_symbol] = msg
self._msgs_by_category.setdefault(msg.msgid[0], []).append(msg.msgid)
- def disable(self, msgid, scope='package', line=None):
+ def disable(self, msgid, scope='package', line=None, ignore_unknown=False):
"""don't output message of the given id"""
assert scope in ('package', 'module')
# handle disable=all by disabling all categories
@@ -272,8 +272,15 @@ class MessagesHandlerMixIn(object):
if msgid.lower().startswith('rp'):
self.disable_report(msgid)
return
- # msgid is a symbolic or numeric msgid.
- msg = self.check_message_id(msgid)
+
+ try:
+ # msgid is a symbolic or numeric msgid.
+ msg = self.check_message_id(msgid)
+ except UnknownMessage:
+ if ignore_unknown:
+ return
+ raise
+
if scope == 'module':
assert line > 0
try:
@@ -290,7 +297,7 @@ class MessagesHandlerMixIn(object):
self.config.disable_msg = [mid for mid, val in msgs.iteritems()
if not val]
- def enable(self, msgid, scope='package', line=None):
+ def enable(self, msgid, scope='package', line=None, ignore_unknown=False):
"""reenable message of the given id"""
assert scope in ('package', 'module')
catid = category_id(msgid)
@@ -309,8 +316,15 @@ class MessagesHandlerMixIn(object):
if msgid.lower().startswith('rp'):
self.enable_report(msgid)
return
- # msgid is a symbolic or numeric msgid.
- msg = self.check_message_id(msgid)
+
+ try:
+ # msgid is a symbolic or numeric msgid.
+ msg = self.check_message_id(msgid)
+ except UnknownMessage:
+ if ignore_unknown:
+ return
+ raise
+
if scope == 'module':
assert line > 0
try:
@@ -400,6 +414,8 @@ class MessagesHandlerMixIn(object):
"""
msg_info = self.check_message_id(msg_descr)
msgid = msg_info.msgid
+ # backward compatibility, message may not have a symbol
+ symbol = msg_info.symbol or msgid
# Fatal messages and reports are special, the node/scope distinction
# does not apply to them.
if msgid[0] not in _SCOPE_EXEMPT:
@@ -427,9 +443,9 @@ class MessagesHandlerMixIn(object):
self.stats[msg_cat] += 1
self.stats['by_module'][self.current_name][msg_cat] += 1
try:
- self.stats['by_msg'][msg_info.symbol] += 1
+ self.stats['by_msg'][symbol] += 1
except KeyError:
- self.stats['by_msg'][msg_info.symbol] = 1
+ self.stats['by_msg'][symbol] = 1
# expand message ?
msg = msg_info.msg
if args: