[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] Function that will transform an object into a listiterable



commit c5513ba318ed75a78f010ad32702d55d4e0516e6
Author: Arturo Filastò <art@xxxxxxxxx>
Date:   Sat Jan 12 14:53:13 2013 +0100

    Function that will transform an object into a listiterable
    
    Will return the iterable if it's an iterable
---
 ooni/managers.py |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/ooni/managers.py b/ooni/managers.py
index ec47ca7..c4b4d2a 100644
--- a/ooni/managers.py
+++ b/ooni/managers.py
@@ -1,7 +1,16 @@
 import itertools
+from twisted.internet import defer
 
-from .ratelimiting import StaticRateLimiter
-from .measurements import Measurement, NetTest
+def makeIterable(item):
+    """
+    Takes as argument or an iterable and if it's not an iterable object then it
+    will return a listiterator.
+    """
+    try:
+        iterable = iter(item)
+    except TypeError:
+        iterable = iter([item])
+    return iterable
 
 class TaskManager(object):
     retries = 2



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits