diff options
author | David Sommerseth <davids@redhat.com> | 2012-12-05 03:24:04 +0100 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2012-12-05 03:24:04 +0100 |
commit | 316b50b8c942238d21213a76c146c5fd6a6c95bc (patch) | |
tree | 9d73171782076e3356091445b17c34a398f4d625 /rteval/modules | |
parent | e396e0e6c4ec3e6c7378f759963cca86a71d6985 (diff) | |
download | rteval-316b50b8c942238d21213a76c146c5fd6a6c95bc.tar.gz rteval-316b50b8c942238d21213a76c146c5fd6a6c95bc.tar.xz rteval-316b50b8c942238d21213a76c146c5fd6a6c95bc.zip |
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>
Diffstat (limited to 'rteval/modules')
-rw-r--r-- | rteval/modules/measurement/__init__.py | 20 |
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] |