ask to continue import if DB is not empty

This commit is contained in:
Martin Zimmermann 2013-11-11 12:02:49 +01:00
parent 5ca3137ddd
commit 162fe78aa6

View File

@ -9,6 +9,11 @@ import textwrap
from time import mktime, strptime from time import mktime, strptime
from collections import defaultdict from collections import defaultdict
try:
input = raw_input
except NameError:
pass
try: try:
from urlparse import urlparse from urlparse import urlparse
except ImportError: except ImportError:
@ -43,6 +48,10 @@ def insert(db, thread, posts):
def disqus(db, xmlfile): def disqus(db, xmlfile):
if db.execute("SELECT * FROM comments").fetchone():
if input("Isso DB is not empty! Continue? [y/N]: ") not in ("y", "Y"):
raise SystemExit("Abort.")
tree = ElementTree.parse(xmlfile) tree = ElementTree.parse(xmlfile)
res = defaultdict(list) res = defaultdict(list)