move fetchiter from webapp to dedup.utils
authorHelmut Grohne <helmut@subdivi.de>
Sat, 2 Mar 2013 20:24:18 +0000 (21:24 +0100)
committerHelmut Grohne <helmut@subdivi.de>
Sat, 2 Mar 2013 20:24:18 +0000 (21:24 +0100)
dedup/utils.py [new file with mode: 0644]
webapp.py

diff --git a/dedup/utils.py b/dedup/utils.py
new file mode 100644 (file)
index 0000000..2fae9fd
--- /dev/null
@@ -0,0 +1,7 @@
+def fetchiter(cursor):
+    rows = cursor.fetchmany()
+    while rows:
+        for row in rows:
+            yield row
+        rows = cursor.fetchmany()
+
index dd1f99a..4a586dd 100755 (executable)
--- a/webapp.py
+++ b/webapp.py
@@ -9,6 +9,8 @@ from werkzeug.exceptions import HTTPException, NotFound
 from werkzeug.routing import Map, Rule, RequestRedirect
 from werkzeug.wrappers import Request, Response
 
+from dedup.utils import fetchiter
+
 hash_functions = [
         ("sha512", "sha512"),
         ("image_sha512", "image_sha512"),
@@ -140,13 +142,6 @@ index_template = jinjaenv.from_string(
 </ul>
 {% endblock %}""")
 
-def fetchiter(cursor):
-    rows = cursor.fetchmany()
-    while rows:
-        for row in rows:
-            yield row
-        rows = cursor.fetchmany()
-
 def encode_and_buffer(iterator):
     buff = b""
     for elem in iterator: