diff options
author | Emile Anclin <emile.anclin@logilab.fr> | 2010-11-10 12:23:26 +0100 |
---|---|---|
committer | Emile Anclin <emile.anclin@logilab.fr> | 2010-11-10 12:23:26 +0100 |
commit | 93f28b31dd189dcb5bdf77d7ef52c71f7db9d96c (patch) | |
tree | f47ab1704e0685f1104bc497b3a88747bb450e8e /utils.py | |
parent | b28a425831baed036fc082048be9035209fb5581 (diff) | |
download | pylint-93f28b31dd189dcb5bdf77d7ef52c71f7db9d96c.tar.gz |
py3k: fix sort_msgs: cmp keyword does not exist anymore
Diffstat (limited to 'utils.py')
-rw-r--r-- | utils.py | 19 |
1 files changed, 10 insertions, 9 deletions
@@ -56,17 +56,18 @@ MSG_TYPES_STATUS = { 'F' : 1 } +_MSG_ORDER = 'EWRCIF' + def sort_msgs(msgids): """sort message identifiers according to their category first""" - msg_order = 'EWRCIF' - def cmp_func(msgid1, msgid2): - """comparison function for two message identifiers""" - if msgid1[0] != msgid2[0]: - return cmp(msg_order.index(msgid1[0]), msg_order.index(msgid2[0])) - else: - return cmp(msgid1, msgid2) - msgids.sort(cmp_func) - return msgids + msgs = {} + for msg in msgids: + msgs.setdefault(msg[0], []).append(msg) + result = [] + for m_id in _MSG_ORDER: + if m_id in msgs: + result.extend( sorted(msgs[m_id]) ) + return result def get_module_and_frameid(node): """return the module name and the frame id in the module""" |