Module: check_mk
Branch: master
Commit: 1ff3d7c9d97863f0ad7518ac2c7deaba7be8bf23
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1ff3d7c9d97863…
Author: Andreas Umbreit <au(a)mathias-kettner.de>
Date: Tue Mar 7 14:33:19 2017 +0100
Combined graphs: Moving AutomaticDict from global lib to web/htdocs/metrics.py
---
lib/containers.py | 48 ------------------------------------------------
web/htdocs/metrics.py | 17 ++++++++++++++++-
2 files changed, 16 insertions(+), 49 deletions(-)
diff --git a/lib/containers.py b/lib/containers.py
deleted file mode 100644
index f8ae783..0000000
--- a/lib/containers.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/python
-# -*- encoding: utf-8; py-indent-offset: 4 -*-
-# +------------------------------------------------------------------+
-# | ____ _ _ __ __ _ __ |
-# | / ___| |__ ___ ___| | __ | \/ | |/ / |
-# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
-# | | |___| | | | __/ (__| < | | | | . \ |
-# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
-# | |
-# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
-# +------------------------------------------------------------------+
-#
-# This file is part of Check_MK.
-# The official homepage is at
http://mathias-kettner.de/check_mk.
-#
-# check_mk is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License as published by
-# the Free Software Foundation in version 2. check_mk is distributed
-# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
-# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE. See the GNU General Public License for more de-
-# tails. You should have received a copy of the GNU General Public
-# License along with GNU Make; see the file COPYING. If not, write
-# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
-# Boston, MA 02110-1301 USA.
-
-# This file contains special containers needed for data representation
-
-from collections import OrderedDict
-
-# Dictionary class with the ability of appending items like provided
-# by a list.
-class AutomaticDict(OrderedDict):
-
- def __init__(self, list_identifier = None, start_index = None):
- OrderedDict.__init__(self)
- self._list_identifier = list_identifier or "item"
- self._item_index = start_index or 0
-
- def __getitem__(self, item):
- if item in self.keys():
- return OrderedDict.__getitem__(self, item)
- else:
- return self["%s_%i" %(self._list_identifier, item)]
-
- def append(self, item):
- self["%s_%i" %(self._list_identifier, self._item_index)] = item
- self._item_index += 1
diff --git a/web/htdocs/metrics.py b/web/htdocs/metrics.py
index f300256..70ce4d6 100644
--- a/web/htdocs/metrics.py
+++ b/web/htdocs/metrics.py
@@ -43,7 +43,6 @@ from lib import *
from valuespec import *
import livestatus
from cmk.regex import regex
-from cmk.containers import AutomaticDict
try:
import simplejson as json
@@ -63,6 +62,22 @@ except ImportError:
# Datastructures and functions needed before plugins can be loaded
loaded_with_language = False
+
+# Dictionary class with the ability of appending items like provided
+# by a list.
+class AutomaticDict(OrderedDict):
+
+ def __init__(self, list_identifier = None, start_index = None):
+ OrderedDict.__init__(self)
+ self._list_identifier = list_identifier or "item"
+ self._item_index = start_index or 0
+
+
+ def append(self, item):
+ self["%s_%i" %(self._list_identifier, self._item_index)] = item
+ self._item_index += 1
+
+
def load_plugins(force):
global loaded_with_language
if loaded_with_language == current_language and not force: