summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2013-09-25 08:47:05 +0200
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2013-09-25 08:47:05 +0200
commit7a190584cf6e783ae908cc2683a0e23212406493 (patch)
tree6172e4aedafae5053226772ad69e000458fca61e
parent73ec3c5e3a4870edc8e5c75b518b215e488a1274 (diff)
downloadpylint-7a190584cf6e783ae908cc2683a0e23212406493.tar.gz
[message handling] kill sort_msgs function, use sorted with key instead
-rw-r--r--test/unittest_lint.py10
-rw-r--r--utils.py14
2 files changed, 2 insertions, 22 deletions
diff --git a/test/unittest_lint.py b/test/unittest_lint.py
index a65eb01..2f388fd 100644
--- a/test/unittest_lint.py
+++ b/test/unittest_lint.py
@@ -32,16 +32,6 @@ from pylint.testutils import TestReporter
from pylint.reporters import text
from pylint import checkers
-class SortMessagesTC(TestCase):
-
- def test(self):
- l = ['E0501', 'E0503', 'F0002', 'I0201', 'W0540',
- 'R0202', 'F0203', 'R0220', 'W0321', 'I0001']
- self.assertEqual(sort_msgs(l), ['E0501', 'E0503',
- 'W0321', 'W0540',
- 'R0202', 'R0220',
- 'I0001', 'I0201',
- 'F0002', 'F0203',])
class GetNoteMessageTC(TestCase):
def test(self):
diff --git a/utils.py b/utils.py
index 1f51bdf..c9104cc 100644
--- a/utils.py
+++ b/utils.py
@@ -76,17 +76,6 @@ class WarningScope(object):
NODE = 'node-based-msg'
-def sort_msgs(msgids):
- """sort message identifiers according to their category first"""
- 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"""
frame = node.frame()
@@ -472,7 +461,8 @@ class MessagesHandlerMixIn(object):
title = ('%smessages' % prefix).capitalize()
print title
print '~' * len(title)
- for msgid in sort_msgs(msgs.iterkeys()):
+ for msgid in sorted(msgs.itervalues(),
+ key=lambda k: (_MSG_ORDER.index(k[0]), k)):
print self.get_message_help(msgid, False)
print
if reports: