From 5ca3137ddd99e2802e026431e0f9aa5db2ceddf7 Mon Sep 17 00:00:00 2001 From: Martin Zimmermann Date: Mon, 11 Nov 2013 11:57:31 +0100 Subject: [PATCH] add --dry-run option to import command --- isso/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/isso/__init__.py b/isso/__init__.py index db3981b..d56bfbe 100644 --- a/isso/__init__.py +++ b/isso/__init__.py @@ -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://"):