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 | 1e44813300c240910bb62b09de8763b79444a2b9 (patch) | |
tree | b10d3aaa7e88ba6a090dd243aa1e8ff993d059b2 | |
parent | 6ffa27d605345cc96e15252175813a0925c7e7a0 (diff) | |
download | pylint-git-1e44813300c240910bb62b09de8763b79444a2b9.tar.gz |
py3k: fix sort_msgs: cmp keyword does not exist anymore
-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""" |