aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Sommerseth <davids@redhat.com>2012-12-05 03:24:04 +0100
committerDavid Sommerseth <davids@redhat.com>2012-12-05 03:24:04 +0100
commit316b50b8c942238d21213a76c146c5fd6a6c95bc (patch)
tree9d73171782076e3356091445b17c34a398f4d625
parente396e0e6c4ec3e6c7378f759963cca86a71d6985 (diff)
downloadrteval-316b50b8c942238d21213a76c146c5fd6a6c95bc.tar.gz
Make MeasurementModules() objects iteratable
When iterating an MeasurementModules() object, it will loop through and return registered MeasurementProfile() objects. Signed-off-by: David Sommerseth <davids@redhat.com>
-rw-r--r--rteval/modules/measurement/__init__.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/rteval/modules/measurement/__init__.py b/rteval/modules/measurement/__init__.py
index ac16f77..10ec967 100644
--- a/rteval/modules/measurement/__init__.py
+++ b/rteval/modules/measurement/__init__.py
@@ -78,6 +78,7 @@ measurement profiles, based on their characteristics"""
self.__logger = logger
self.__measureprofiles = []
self.__modules_root = "modules.measurement"
+ self.__iter_item = None
def GetProfile(self, with_load, run_parallel):
@@ -135,3 +136,22 @@ measurement profiles, based on their characteristics"""
rep_n.addChild(mprep_n)
return rep_n
+
+
+ def __iter__(self):
+ "Initiates an iteration loop for MeasurementProfile objects"
+
+ self.__iter_item = len(self.__measureprofiles)
+ return self
+
+
+ def next(self):
+ """Internal Python iterating method, returns the next
+MeasurementProfile object to be processed"""
+
+ if self.__iter_item == 0:
+ self.__iter_item = None
+ raise StopIteration
+ else:
+ self.__iter_item -= 1
+ return self.__measureprofiles[self.__iter_item]