key_value_list_to_dict support list of tuples

Change-Id: Ief65c66ba5e662204111217bdb455ae4948cee85
Signed-off-by: Michael Walsh <micwalsh@us.ibm.com>
diff --git a/lib/var_funcs.py b/lib/var_funcs.py
index ceed9f8..2598bf6 100644
--- a/lib/var_funcs.py
+++ b/lib/var_funcs.py
@@ -272,7 +272,8 @@
                            process_indent=0,
                            **args):
     r"""
-    Convert a list containing key/value strings to a dictionary and return it.
+    Convert a list containing key/value strings or tuples to a dictionary and
+    return it.
 
     See docstring of parse_key_value function for details on key/value strings.
 
@@ -300,6 +301,26 @@
       [correction_time]:            0 milliseconds
       [sampling_period]:            0 seconds
 
+    For the following list:
+
+    headers:
+      headers[0]:
+        headers[0][0]:           content-length
+        headers[0][1]:           559
+      headers[1]:
+        headers[1][0]:           x-xss-protection
+        headers[1][1]:           1; mode=block
+
+    And the following call in python:
+
+    headers_dict = key_value_list_to_dict(headers)
+
+    The resulting headers_dict would look like this:
+
+    headers_dict:
+      [content-length]:          559
+      [x-xss-protection]:        1; mode=block
+
     Another example containing a sub-list (see process_indent description
     below):
 
@@ -333,7 +354,10 @@
                                     processed as such.  An entry may have a
                                     sub-dict or sub-list if 1) It has no value
                                     other than blank 2) There are entries
-                                    below it that are indented.
+                                    below it that are indented.  Note that
+                                    process_indent is not allowed for a list
+                                    of tuples (vs. a list of key/value
+                                    strings).
     **args                          Arguments to be interpreted by
                                     parse_key_value.  (See docstring of
                                     parse_key_value function for details).
@@ -346,7 +370,10 @@
 
     if not process_indent:
         for entry in list:
-            key, value = parse_key_value(entry, **args)
+            if type(entry) is tuple:
+                key, value = entry
+            else:
+                key, value = parse_key_value(entry, **args)
             result_dict[key] = value
         return result_dict