From 7c4864d4ccb40234138043b0aae3356f15eeacf5 Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Sat, 2 Mar 2013 21:24:18 +0100 Subject: move fetchiter from webapp to dedup.utils --- dedup/utils.py | 7 +++++++ webapp.py | 9 ++------- 2 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 dedup/utils.py diff --git a/dedup/utils.py b/dedup/utils.py new file mode 100644 index 0000000..2fae9fd --- /dev/null +++ b/dedup/utils.py @@ -0,0 +1,7 @@ +def fetchiter(cursor): + rows = cursor.fetchmany() + while rows: + for row in rows: + yield row + rows = cursor.fetchmany() + diff --git a/webapp.py b/webapp.py index dd1f99a..4a586dd 100755 --- 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( {% 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: -- cgit v1.2.3