Allow gethandles.py and makedb.py to use external config file
This commit is contained in:
parent
f23bc8dce7
commit
87a4add95f
|
@ -1,9 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import operator, re, sqlite3
|
||||
import config, operator, re, sqlite3
|
||||
|
||||
def getTweets(database_filename = "Database.db"):
|
||||
def getTweets(database_filename = config.dbpath):
|
||||
sql_conn = sqlite3.connect(database_filename)
|
||||
cur = sql_conn.cursor()
|
||||
|
||||
|
@ -23,6 +23,5 @@ def getTweets(database_filename = "Database.db"):
|
|||
return handles
|
||||
|
||||
if __name__ == "__main__":
|
||||
data = sorted(list(getTweets().items()), key=operator.itemgetter(1), reverse=True)
|
||||
for handle, tweets in data:
|
||||
for handle, tweets in sorted(list(getTweets().items()), key=operator.itemgetter(1), reverse=True):
|
||||
print(handle + "," + str(tweets))
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os, sqlite3, sys
|
||||
import config, os, sqlite3, sys
|
||||
|
||||
def makeDB(path="Database.db"):
|
||||
def makeDB(path=config.dbpath):
|
||||
if os.path.isfile(path):
|
||||
raise IOError(path + " already exists. If you want to recreate it, please delete it first, or provide a different file name.")
|
||||
|
||||
|
|
Loading…
Reference in a new issue