rrdweb/rrd.py
branchoo-graphs
changeset 19 58df27d54d2e
parent 5 e716718482c3
--- a/rrdweb/rrd.py	Sat Jan 30 23:44:28 2010 +0200
+++ b/rrdweb/rrd.py	Sun Jan 31 01:32:48 2010 +0200
@@ -63,6 +63,22 @@
 
     return out
 
+def normalize_args (args) :
+    """
+        Flatten the given nested iterables list into a flat one
+    """
+
+    for arg in args :
+        # naasty type-checks :)
+        if isinstance(arg, (list, tuple, types.GeneratorType)) :
+            # recurse -> flatten
+            for subarg in normalize_args(arg) :
+                yield subarg
+
+        else :
+            # flat
+            yield str(arg)
+
 def run_cmd (func, pre_args, opts, post_args) :
     """
         Run the given rrdtool.* function, formatting the given positional arguments and options.
@@ -75,8 +91,8 @@
     opt_args = [item for items in opt_items for item in items]
 
     # positional arguments
-    pre_args = [str(arg) for arg in pre_args]
-    post_args = [str(arg) for arg in post_args]
+    pre_args = normalize_args(pre_args)
+    post_args = normalize_args(post_args)
 
     # full arguments
     args = pre_args + opt_args + post_args