summaryrefslogtreecommitdiffstats
path: root/Monitoring/MonitoringService/DataProcessing/DataIndex.py
diff options
context:
space:
mode:
Diffstat (limited to 'Monitoring/MonitoringService/DataProcessing/DataIndex.py')
-rw-r--r--Monitoring/MonitoringService/DataProcessing/DataIndex.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/Monitoring/MonitoringService/DataProcessing/DataIndex.py b/Monitoring/MonitoringService/DataProcessing/DataIndex.py
new file mode 100644
index 0000000..84d8390
--- /dev/null
+++ b/Monitoring/MonitoringService/DataProcessing/DataIndex.py
@@ -0,0 +1,39 @@
+'''
+Created on Dec 31, 2012
+
+@author: steger
+'''
+from DataProcessing.DataReader import DataReader
+
+class DataIndex(DataReader):
+ '''
+ classdocs
+ '''
+
+ def __init__(self, datasource, key):
+ '''
+ Constructor
+ '''
+ DataReader.__init__(self, datasource)
+ self.indexmap = {}
+ self.extract(cellrequest = key)
+
+ def buildindex(self):
+ i = len(self.indexmap)
+ for k in self:
+ self.indexmap[tuple(k)] = i
+ i += 1
+
+ def __getitem__(self, k):
+ if self.sourceCleared.isSet():
+ self.sourceCleared.clear()
+ self.indexmap.clear()
+ self.buildindex()
+ try:
+ iter(k)
+ except TypeError:
+ k = (k,)
+ if not self.indexmap.has_key(k) and self.sourceExpanded.isSet():
+ self.sourceExpanded.clear()
+ self.buildindex()
+ return self.source._rawrecords[ self.indexmap[k] ] \ No newline at end of file