Module: check_mk
Branch: master
Commit: 85155f344ef699a5b70a7529d842875b5e3db7e4
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=85155f344ef699…
Author: Óscar Nájera <on(a)mathias-kettner.de>
Date: Thu Sep 27 18:29:24 2018 +0200
Refactor filter
Change-Id: I5f4c14de74d2842dc809395b4bbe8fbae12676ad
---
cmk/gui/bi.py | 18 +++++++++---------
cmk/gui/plugins/dashboard/stats.py | 6 +++---
cmk/gui/views.py | 4 ++--
cmk/gui/visuals.py | 18 +++++++++---------
4 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/cmk/gui/bi.py b/cmk/gui/bi.py
index e6bcb39..1914c0f 100644
--- a/cmk/gui/bi.py
+++ b/cmk/gui/bi.py
@@ -3352,19 +3352,19 @@ def table(columns, add_headers, only_sites, limit, filters):
only_aggr_name = None
required_groups = tuple()
- for filter in filters:
- if filter.name == "aggr_group":
- val = filter.selected_group()
+ for filter_ in filters:
+ if filter_.name == "aggr_group":
+ val = filter_.selected_group()
if val:
only_group = val
- elif filter.name == "aggr_service":
- only_service = filter.service_spec()
- elif filter.name == "aggr_name":
- only_aggr_name = filter.value().get("aggr_name")
+ elif filter_.name == "aggr_service":
+ only_service = filter_.service_spec()
+ elif filter_.name == "aggr_name":
+ only_aggr_name = filter_.value().get("aggr_name")
# TODO: can be further improved by filtering aggr_name_regex
# See BITextFilter(Filter): filter_table(self, rows)
- elif filter.name == "aggr_group_tree":
- val = filter.value().get("aggr_group_tree")
+ elif filter_.name == "aggr_group_tree":
+ val = filter_.value().get("aggr_group_tree")
if val:
required_groups = tuple(val.split("/"))
diff --git a/cmk/gui/plugins/dashboard/stats.py b/cmk/gui/plugins/dashboard/stats.py
index d102d4c..3cc77e5 100644
--- a/cmk/gui/plugins/dashboard/stats.py
+++ b/cmk/gui/plugins/dashboard/stats.py
@@ -79,7 +79,7 @@ class DashletStats(Dashlet):
pie_right_aspect = 0.8
what = self._livestatus_table()
table = self._table()
- filter = self._filter()
+ filter_ = self._filter()
if what == 'hosts':
info = 'host'
@@ -90,12 +90,12 @@ class DashletStats(Dashlet):
use_filters = visuals.filters_of_visual(self._dashlet_spec, infos)
for filt in use_filters:
if filt.available() and not isinstance(filt, visuals.FilterSite):
- filter += filt.filter(info)
+ filter_ += filt.filter(info)
query = "GET %s\n" % what
for entry in table:
query += entry[3]
- query += filter
+ query += filter_
site = self._dashlet_spec['context'].get('siteopt',
{}).get('site')
if site:
diff --git a/cmk/gui/views.py b/cmk/gui/views.py
index 568c5dc..5289b60 100644
--- a/cmk/gui/views.py
+++ b/cmk/gui/views.py
@@ -1001,8 +1001,8 @@ def show_view(view, show_heading = False, show_buttons = True,
rows = []
# Apply non-Livestatus filters
- for filter in all_active_filters:
- rows = filter.filter_table(rows)
+ for filter_ in all_active_filters:
+ rows = filter_.filter_table(rows)
if html.var("mode") == "availability":
cmk.gui.plugins.views.availability.render_bi_availability(view_title(view),
rows)
diff --git a/cmk/gui/visuals.py b/cmk/gui/visuals.py
index c65cb0e..290e775 100644
--- a/cmk/gui/visuals.py
+++ b/cmk/gui/visuals.py
@@ -1007,9 +1007,9 @@ def filters_of_visual(visual, info_keys, show_all=False,
link_filters=None):
# Collect all available filters for these infos
all_possible_filters = []
- for _filter_name, filter in multisite_filters.items():
- if filter.info in info_keys:
- all_possible_filters.append(filter)
+ for _filter_name, filter_ in multisite_filters.items():
+ if filter_.info in info_keys:
+ all_possible_filters.append(filter_)
for info_key in info_keys:
if info_key in visual['single_infos']:
@@ -1034,12 +1034,12 @@ def filters_of_visual(visual, info_keys, show_all=False,
link_filters=None):
# add ubiquitary_filters that are possible for these infos
for fn in get_ubiquitary_filters():
# Disable 'wato_folder' filter, if WATO is disabled or there is a single
host view
- filter = get_filter(fn)
+ filter_ = get_filter(fn)
- if fn == "wato_folder" and (not filter.available() or 'host' in
visual['single_infos']):
+ if fn == "wato_folder" and (not filter_.available() or 'host'
in visual['single_infos']):
continue
- if not filter.info or filter.info in info_keys:
- filters.append(filter)
+ if not filter_.info or filter_.info in info_keys:
+ filters.append(filter_)
return list(set(filters)) # remove duplicates
@@ -1159,10 +1159,10 @@ class VisualFilterList(ListOfMultiple):
fspecs = {}
self._filters = {}
for info in self._infos:
- for fname, filter in filters_allowed_for_info(info).items():
+ for fname, filter_ in filters_allowed_for_info(info).items():
if fname not in fspecs and fname not in ignore:
fspecs[fname] = VisualFilter(fname,
- title = filter.title,
+ title = filter_.title,
)
self._filters[fname] = fspecs[fname]._filter