Module: check_mk
Branch: master
Commit: c8cf15481eda5918897dcee18df56a48878a25a3
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c8cf15481eda59…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Dec 13 09:00:07 2018 +0100
Nuked one more table.begin()/end() pair.
table.end()'s return value has been unused since 2015 (77d6eeec4), so we can
simplify things a bit and use open_table() in one more place.
Change-Id: Iffa56c4787d600b46af348f0ee9e8b94a670c0aa
---
cmk/gui/plugins/views/availability.py | 100 +++++++++++++++++-----------------
cmk/gui/table.py | 7 +--
2 files changed, 50 insertions(+), 57 deletions(-)
diff --git a/cmk/gui/plugins/views/availability.py
b/cmk/gui/plugins/views/availability.py
index 4da0c91..f727c77 100644
--- a/cmk/gui/plugins/views/availability.py
+++ b/cmk/gui/plugins/views/availability.py
@@ -456,57 +456,55 @@ def render_availability_table(group_title, availability_table, what,
avoptions):
# TODO: If summary line is activated, then sorting should now move that line to the
# top. It should also stay at the bottom. This would require an extension to the
# table.py module.
- table.begin(
- "av_items",
- av_table["title"],
- css="availability",
- searchable=False,
- limit=None,
- omit_headers="omit_headers" in avoptions["labelling"])
-
- show_urls, show_timeline = False, False
- for row in av_table["rows"]:
- table.row()
-
- # Column with icons
- timeline_url = None
- if row["urls"]:
- show_urls = True
- table.cell("", css="buttons")
- for image, tooltip, url in row["urls"]:
- html.icon_button(url, tooltip, image)
- if image == "timeline":
- timeline_url = url
-
- # Column with host/service or aggregate name
- for title, (name, url) in zip(av_table["object_titles"],
row["object"]):
- table.cell(title, html.render_a(name, url))
-
- if "timeline" in row:
- show_timeline = True
- table.cell(_("Timeline"), css="timeline")
- html.open_a(href=timeline_url)
- render_timeline_bar(row["timeline"], "inline")
- html.close_a()
-
- # Columns with the actual availability data
- for (title, help_txt), (text, css) in zip(av_table["cell_titles"],
row["cells"]):
- table.cell(title, text, css=css, help_txt=help_txt)
-
- if "summary" in av_table:
- table.row(css="summary", fixed=True)
- if show_urls:
- table.cell("", "") # Empty cell in URLs column
- table.cell("", _("Summary"), css="heading")
- for _x in xrange(1, len(av_table["object_titles"])):
- table.cell("", "") # empty cells, of more object titles
than one
- if show_timeline:
- table.cell("", "")
-
- for (title, help_txt), (text, css) in zip(av_table["cell_titles"],
av_table["summary"]):
- table.cell(title, text, css="heading " + css, help_txt=help_txt)
-
- return table.end() # returns Table data if fetch == True
+ with table.open_table(
+ "av_items",
+ av_table["title"],
+ css="availability",
+ searchable=False,
+ limit=None,
+ omit_headers="omit_headers" in avoptions["labelling"]):
+
+ show_urls, show_timeline = False, False
+ for row in av_table["rows"]:
+ table.row()
+
+ # Column with icons
+ timeline_url = None
+ if row["urls"]:
+ show_urls = True
+ table.cell("", css="buttons")
+ for image, tooltip, url in row["urls"]:
+ html.icon_button(url, tooltip, image)
+ if image == "timeline":
+ timeline_url = url
+
+ # Column with host/service or aggregate name
+ for title, (name, url) in zip(av_table["object_titles"],
row["object"]):
+ table.cell(title, html.render_a(name, url))
+
+ if "timeline" in row:
+ show_timeline = True
+ table.cell(_("Timeline"), css="timeline")
+ html.open_a(href=timeline_url)
+ render_timeline_bar(row["timeline"], "inline")
+ html.close_a()
+
+ # Columns with the actual availability data
+ for (title, help_txt), (text, css) in zip(av_table["cell_titles"],
row["cells"]):
+ table.cell(title, text, css=css, help_txt=help_txt)
+
+ if "summary" in av_table:
+ table.row(css="summary", fixed=True)
+ if show_urls:
+ table.cell("", "") # Empty cell in URLs column
+ table.cell("", _("Summary"), css="heading")
+ for _x in xrange(1, len(av_table["object_titles"])):
+ table.cell("", "") # empty cells, of more object
titles than one
+ if show_timeline:
+ table.cell("", "")
+
+ for (title, help_txt), (text, css) in zip(av_table["cell_titles"],
av_table["summary"]):
+ table.cell(title, text, css="heading " + css,
help_txt=help_txt)
def render_timeline_bar(timeline_layout, style):
diff --git a/cmk/gui/table.py b/cmk/gui/table.py
index 14bdcd5..97b09ce 100644
--- a/cmk/gui/table.py
+++ b/cmk/gui/table.py
@@ -75,7 +75,7 @@ def groupheader(title):
def end():
assert tables
table = tables.pop()
- return table.end()
+ table.end()
def update_headinfo(num_rows):
@@ -214,11 +214,6 @@ class Table(object):
self.finish_previous()
html.unplug()
- # Output-Format "fetch" simply means that all data is being
- # returned as Python-values to be rendered somewhere else.
- if self.options["output_format"] == "fetch":
- return self.headers, self.rows
-
if not self.rows and self.options["omit_if_empty"]:
return