add --dry-run option to import command

This commit is contained in:
Martin Zimmermann 2013-11-11 11:57:31 +01:00
parent a8cd418b5e
commit 5ca3137ddd

View File

@ -42,6 +42,7 @@ import sys
import os
import socket
import logging
import tempfile
from os.path import dirname, join
from argparse import ArgumentParser
@ -205,6 +206,8 @@ def main():
imprt = subparser.add_parser('import', help="import Disqus XML export")
imprt.add_argument("dump", metavar="FILE")
imprt.add_argument("-n", "--dry-run", dest="dryrun", action="store_true",
help="perform a trial run with no changes made")
serve = subparser.add_parser("run", help="run server")
@ -212,8 +215,11 @@ def main():
conf = Config.load(args.conf)
if args.command == "import":
xxx = tempfile.NamedTemporaryFile()
dbpath = conf.get("general", "dbpath") if not args.dryrun else xxx.name
conf.set("guard", "enabled", "off")
migrate.disqus(db.SQLite3(conf.get('general', 'dbpath'), conf), args.dump)
migrate.disqus(db.SQLite3(dbpath, conf), args.dump)
sys.exit(0)
if conf.get("server", "listen").startswith("http://"):