Commit e4dd8361 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki Committed by Jérome Perrin

py2/py3: cmp() and sort(cmp=...) do not exist in Python 3.

parent fcdc0aab
...@@ -348,12 +348,8 @@ class Alarm(XMLObject, PeriodicityMixin): ...@@ -348,12 +348,8 @@ class Alarm(XMLObject, PeriodicityMixin):
result_list = [x for x in active_process.getResultList() if x is not None] result_list = [x for x in active_process.getResultList() if x is not None]
attachment_list = [] attachment_list = []
if len(result_list): if len(result_list):
def sort_result_list(a, b): # Here we assume that severity type is int or float and summary type is same for all entries.
result = - cmp(a.severity, b.severity) result_list.sort(key=lambda e: (-e.severity, e.summary))
if result == 0:
result = cmp(a.summary, b.summary)
return result
result_list.sort(sort_result_list)
rendered_alarm_result_list = ['%02i summary: %s\n%s\n----' % rendered_alarm_result_list = ['%02i summary: %s\n%s\n----' %
(int(getattr(x, 'severity', 0)), getattr(x, 'summary', ''), getattr(x, 'detail', '')) (int(getattr(x, 'severity', 0)), getattr(x, 'summary', ''), getattr(x, 'detail', ''))
for x in result_list] for x in result_list]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment