try: # if Anki is found, we are an Anki addon from anki.utils import joinFields, stripHTML from aqt.utils import showText from anki import notes from aqt import mw from aqt.utils import showInfo, tooltip from aqt.qt import * plugin = AnkiN2C2Plugin() plugin.setup() except ImportError as err: # not anki addon, run from command line import argparse parser = argparse.ArgumentParser() parser.add_argument("file", help="An odt file to convert to flashcards") parser.add_argument('-o', '--out', help="Filename to write to") parser.add_argument('-d', '--debug', help="Dump debug output to stdout", action="store_true") parser.add_argument('-j', '--json', help="Display contents as json in stdout", action="store_true") parser.add_argument('-t', '--text', help="Ignore formatting", action="store_true") args = parser.parse_args() if args.debug: print "Debug on" n2c2lib.debug.isDebug = args.debug app = NotesToCards() app.configure(args) app.execute()