Module: check_mk
Branch: master
Commit: b0966808891507e8d5110d1bd90ad8aaccd4d025
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b0966808891507…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Mon May 14 12:32:31 2018 +0200
Move filter_operators to smaller scope.
Change-Id: I705d20b02b929529261eb71176cd4ab89ce95576
---
cmk/ec/main.py | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/cmk/ec/main.py b/cmk/ec/main.py
index a080583..30d746c 100644
--- a/cmk/ec/main.py
+++ b/cmk/ec/main.py
@@ -247,19 +247,6 @@ def convert_history_line(values):
values[28] = unsplit(values[28])
-filter_operators = {
- "=": (lambda a, b: a == b),
- ">": (lambda a, b: a > b),
- "<": (lambda a, b: a < b),
- ">=": (lambda a, b: a >= b),
- "<=": (lambda a, b: a <= b),
- "~": (lambda a, b: cmk.regex.regex(b).search(a)),
- "=~": (lambda a, b: a.lower() == b.lower()),
- "~~": (lambda a, b: cmk.regex.regex(b.lower()).search(a.lower())),
- "in": (lambda a, b: a in b),
-}
-
-
#.
# .--Helper functions----------------------------------------------------.
# | _ _ _ |
@@ -3222,6 +3209,18 @@ class Query(object):
class QueryGET(Query):
+ filter_operators = {
+ "=": (lambda a, b: a == b),
+ ">": (lambda a, b: a > b),
+ "<": (lambda a, b: a < b),
+ ">=": (lambda a, b: a >= b),
+ "<=": (lambda a, b: a <= b),
+ "~": (lambda a, b: cmk.regex.regex(b).search(a)),
+ "=~": (lambda a, b: a.lower() == b.lower()),
+ "~~": (lambda a, b: cmk.regex.regex(b.lower()).search(a.lower())),
+ "in": (lambda a, b: a in b),
+ }
+
def _from_raw_query(self, status_server):
super(QueryGET, self)._from_raw_query(status_server)
self._parse_table(status_server)
@@ -3297,7 +3296,7 @@ class QueryGET(Query):
else:
argument = convert(argument)
- operator_function = filter_operators.get(operator_name)
+ operator_function = self._filter_operators.get(operator_name)
if not operator_function:
raise MKClientError("Unknown filter operator '%s'" %
operator_name)