diff options
author | sylvain thenault <sylvain.thenault@logilab.fr> | 2009-01-28 10:09:09 +0100 |
---|---|---|
committer | sylvain thenault <sylvain.thenault@logilab.fr> | 2009-01-28 10:09:09 +0100 |
commit | 9d061486e5a6266b0ebb885144088141b8b35f8f (patch) | |
tree | a7119355154e4d88c790be0cb59143b43efdbfc6 /utils.py | |
parent | acb3ee99b9c67e6985dad3a75309b3313c7c4614 (diff) | |
download | pylint-9d061486e5a6266b0ebb885144088141b8b35f8f.tar.gz |
change [en|dis]able-msg-cat options: only accept message categories
identified by their first letter (eg IRCWEF) without the need for comma
as separator
Diffstat (limited to 'utils.py')
-rw-r--r-- | utils.py | 39 |
1 files changed, 23 insertions, 16 deletions
@@ -1,5 +1,5 @@ -# Copyright (c) 2003-2008 Sylvain Thenault (thenault@gmail.com). -# Copyright (c) 2003-2008 LOGILAB S.A. (Paris, FRANCE). +# Copyright (c) 2003-2009 Sylvain Thenault (thenault@gmail.com). +# Copyright (c) 2003-2009 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 @@ -172,26 +172,33 @@ class MessagesHandlerMixIn: msgs[msg.msgid] = True # sync configuration object self.config.enable_msg = [mid for mid, val in msgs.items() if val] + + def _cat_ids(self, categories): + for catid in categories: + catid = catid.upper() + if not catid in MSG_TYPES: + raise Exception('Unknown category identifier %s' % catid) + yield catid - def disable_message_category(self, msg_cat_id, scope='package', line=None): + def disable_message_category(self, categories, scope='package', line=None): """don't output message in the given category""" assert scope in ('package', 'module') - msg_cat_id = msg_cat_id[0].upper() - if scope == 'module': - self.add_message('I0011', line=line, args=msg_cat_id) - self._module_msg_cats_state[msg_cat_id] = False - else: - self._msg_cats_state[msg_cat_id] = False + for catid in self._cat_ids(categories): + if scope == 'module': + self.add_message('I0011', line=line, args=catid) + self._module_msg_cats_state[catid] = False + else: + self._msg_cats_state[catid] = False - def enable_message_category(self, msg_cat_id, scope='package', line=None): + def enable_message_category(self, categories, scope='package', line=None): """reenable message of the given category""" assert scope in ('package', 'module') - msg_cat_id = msg_cat_id[0].upper() - if scope == 'module': - self.add_message('I0012', line=line, args=msg_cat_id) - self._module_msg_cats_state[msg_cat_id] = True - else: - self._msg_cats_state[msg_cat_id] = True + for catid in self._cat_ids(categories): + if scope == 'module': + self.add_message('I0012', line=line, args=catid) + self._module_msg_cats_state[catid] = True + else: + self._msg_cats_state[catid] = True def check_message_id(self, msg_id): """raise UnknownMessage if the message id is not defined""" |