return classes in reverse sorting order if desired

This commit is contained in:
Marcus Stoegbauer 2019-07-03 22:54:08 +02:00
parent 92a96343e1
commit a029c096c8

View File

@ -8,7 +8,7 @@ Created by Marcus Stoegbauer on 2013-01-10.
""" """
import platform import platform
from operator import itemgetter
class Checks(object): class Checks(object):
def __init__(self): def __init__(self):
@ -23,7 +23,7 @@ class Checks(object):
# def getShortHostname # def getShortHostname
def __classes_for_host__(self): def __classes_for_host__(self, reverse=False):
"""docstring for __classesForHost""" """docstring for __classesForHost"""
classes = [] classes = []
for c in dir(self): for c in dir(self):
@ -32,7 +32,7 @@ class Checks(object):
ret = getattr(self, c)() ret = getattr(self, c)()
if type(ret) == tuple and len(ret) == 3: if type(ret) == tuple and len(ret) == 3:
classes.append(ret) classes.append(ret)
return map(lambda k: (k[1], k[2]), sorted(classes, key=lambda k: k[0])) return map(lambda k: (k[1], k[2]), sorted(classes, key=itemgetter(0), reverse=reverse))
def header(self): def header(self):
"""docstring for header""" """docstring for header"""