From e2ab01521822c8acbefe7f90310c90595e50c7c5 Mon Sep 17 00:00:00 2001 From: Klaus-Uwe Mitterer Date: Fri, 24 Apr 2015 23:33:42 +0200 Subject: [PATCH] Change return value of datecsv.getTweetsByDate() to a list of tweets rather than None Move CSV output function to tools.printCSV() --- datecsv.py | 9 +++------ tools.py | 7 ++++++- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/datecsv.py b/datecsv.py index 303c5e8..9a0b1da 100755 --- a/datecsv.py +++ b/datecsv.py @@ -3,7 +3,7 @@ import tools -import csv, sys, datetime +import sys, datetime def checkDate(date): try: @@ -71,11 +71,8 @@ def queryBuilder(strings = [], fr = "", to = ""): def getTweetsByDate(strings = [], path = tools.config.dbpath, fr = "", to = ""): db = tools.dbHelper(path) - tweets = db.executeQuery(queryBuilder(strings,fr,to)) - writer = csv.writer(sys.stdout) - - writer.writerows(tweets) + return db.executeQuery(queryBuilder(strings,fr,to)) if __name__ == "__main__": strings, fr, to = dateArgs() - getTweetsByDate(strings = strings, fr = fr, to = to) + tools.printCSV(getTweetsByDate(strings = strings, fr = fr, to = to)) diff --git a/tools.py b/tools.py index 21a29a6..aab8158 100644 --- a/tools.py +++ b/tools.py @@ -1,6 +1,6 @@ import config -import os, sqlite3, tweepy +import csv, os, sqlite3, sys, tweepy class dbObject: @@ -81,3 +81,8 @@ def parseArgs(argv): args += [a] return args, path + +def printCSV(inlist): + writer = csv.writer(sys.stdout) + writer.writerows(inlist) +