summaryrefslogtreecommitdiff
path: root/utils.py
diff options
context:
space:
mode:
authorEmile Anclin <emile.anclin@logilab.fr>2010-11-10 12:23:26 +0100
committerEmile Anclin <emile.anclin@logilab.fr>2010-11-10 12:23:26 +0100
commit93f28b31dd189dcb5bdf77d7ef52c71f7db9d96c (patch)
treef47ab1704e0685f1104bc497b3a88747bb450e8e /utils.py
parentb28a425831baed036fc082048be9035209fb5581 (diff)
downloadpylint-93f28b31dd189dcb5bdf77d7ef52c71f7db9d96c.tar.gz
py3k: fix sort_msgs: cmp keyword does not exist anymore
Diffstat (limited to 'utils.py')
-rw-r--r--utils.py19
1 files changed, 10 insertions, 9 deletions
diff --git a/utils.py b/utils.py
index 2e685bb..faedfc0 100644
--- a/utils.py
+++ b/utils.py
@@ -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"""