Module: check_mk
Branch: master
Commit: c3d61ce4a34620e77fb10e65af4222607ad312dc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c3d61ce4a34620…
Author: Moritz Kiemer <mo(a)mathias-kettner.de>
Date: Wed Jul 4 15:51:15 2018 +0200
wmi.include: Improve Table object
Inherit table from object, so we can determine its
instance. Also add __eq__ and __ne__ methods, so that
we can compare it in testing.
Change-Id: Ia83a475f1c60330144eba03eb55c33cc7ab28831
---
checks/wmi.include | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/checks/wmi.include b/checks/wmi.include
index e2cb069..16036bf 100644
--- a/checks/wmi.include
+++ b/checks/wmi.include
@@ -57,7 +57,7 @@ def parse_wmi_table(info, key="Name"):
# the table can also contain the sample time where the metrics were read,
# otherwise the caller will have to assume the sampletime is one of the
# metrics
- class Table:
+ class Table(object):
TOTAL_NAMES = ["_Total", "", "__Total__",
"_Global"]
@@ -89,10 +89,16 @@ def parse_wmi_table(info, key="Name"):
self.__row_lookup = {}
self.__rows = []
-
def __repr__(self):
return repr((self.__headers, self.__rows))
+ def __eq__(self, other):
+ if isinstance(other, self.__class__):
+ return self.__dict__ == other.__dict__
+ return False
+
+ def __ne__(self, other):
+ return not self == other
def add_row(self, row):
row = row[:]
@@ -104,7 +110,6 @@ def parse_wmi_table(info, key="Name"):
self.__row_lookup[key] = len(self.__rows)
self.__rows.append(row)
-
def get(self, row, column):
if isinstance(row, int):
row_index = row