[libvirt] [test-API][PATCH 3/5] Update add_option_value function in parser

Wayne Sun gsun at redhat.com
Thu Oct 13 11:30:24 UTC 2011


  * Option should be added to the last dictionary in caselist.
    The old function will cause problem when multiple dictionaries in
    caselist have same testkey.
---
 parser.py |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/parser.py b/parser.py
index 8d41776..085a1f2 100644
--- a/parser.py
+++ b/parser.py
@@ -125,13 +125,11 @@ class CaseFileParser(object):
 
     def add_option_value(self, caselist, casename, option, value):
         """ Add option to the data list. """
-        for dictionary in caselist:
-            testkey = dictionary.keys()[0]
-            if casename == testkey:
-                if not dictionary[testkey].has_key(option):
-                    dictionary[testkey][option] = value
-            else:
-                continue
+        dictionary = caselist[-1]
+        testkey = dictionary.keys()[0]
+        if casename == testkey:
+            if not dictionary[testkey].has_key(option):
+                dictionary[testkey][option] = value
 
     def debug_print(self, str1, str2=""):
         """Nicely print two strings and an arrow.  For internal use."""
-- 
1.7.1




More information about the libvir-list mailing list