Module: check_mk
Branch: master
Commit: 4079c36a15c15e3cd05fb18c5a801aafefc4416e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4079c36a15c15e…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Fri Dec 14 09:56:01 2018 +0100
Cleaned up werk sorting, no functional changes.
Change-Id: I573fd45448c985520ec4fb17b31225ac895c4744
---
cmk/gui/werks.py | 11 ++++-------
cmk/werks.py | 15 +++++++++++----
2 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/cmk/gui/werks.py b/cmk/gui/werks.py
index b34b576..d9244f8 100644
--- a/cmk/gui/werks.py
+++ b/cmk/gui/werks.py
@@ -196,8 +196,9 @@ def load_acknowledgements():
def unacknowledged_incompatible_werks():
- return werks_sorted_by_date(
- [werk for werk in g_werks.values() if werk["compatible"] ==
"incomp_unack"])
+ return cmk.werks.sort_by_date(werk #
+ for werk in g_werks.values()
+ if werk["compatible"] ==
"incomp_unack")
def num_unacknowledged_incompatible_werks():
@@ -328,7 +329,7 @@ def render_werks_table():
if werk_table_options["grouping"] == "version":
werklist = cmk.werks.sort_by_version_and_component(g_werks.values())
else:
- werklist = werks_sorted_by_date(g_werks.values())
+ werklist = cmk.werks.sort_by_date(g_werks.values())
for werk in werklist:
if werk_matches_options(werk, werk_table_options):
@@ -546,7 +547,3 @@ def insert_manpage_links(text):
part = '<a
href="wato.py?mode=check_manpage&check_type=%s">%s</a>' %
(part, part)
new_parts.append(part)
return " ".join(new_parts)
-
-
-def werks_sorted_by_date(werks):
- return sorted(werks, cmp=lambda a, b: -cmp(a["date"],
b["date"]))
diff --git a/cmk/werks.py b/cmk/werks.py
index 9e0b7e2..9025336 100644
--- a/cmk/werks.py
+++ b/cmk/werks.py
@@ -206,10 +206,17 @@ def write_werk_as_text(f, werk):
# sort by version and within one version by component
def sort_by_version_and_component(werks):
- return sorted(werks, key=lambda x: \
- (parse_check_mk_version(x["version"]),
werk_components().get(x["component"], x["component"]),
- x["class"] != "fix", x["class"] !=
"sec", x["title"]),
- reverse=True)
+ return sorted(werks,
+ key=lambda w: (parse_check_mk_version(w["version"]),
+ werk_components().get(w["component"],
w["component"]),
+ w["class"] != "fix",
+ w["class"] != "sec",
+ w["title"]),
+ reverse=True)
+
+
+def sort_by_date(werks):
+ return sorted(werks, key=lambda w: w["date"], reverse=True)
# Parses versions of Check_MK and converts them into comparable integers.