X-Git-Url: https://git.armaanb.net/?a=blobdiff_plain;f=lightcards%2Frunner.py;h=69d5cbe09c1dd029d40e60b5af8a6f1fc8c1027a;hb=b50ac3096f5138870bd3bebb60e15b3f51e3e128;hp=08004db3bd68d4e261fb080c7c777c7ae94b0fd3;hpb=dc6c791fb09b9e5aab0eec970fdca707cd70dc47;p=lightcards.git diff --git a/lightcards/runner.py b/lightcards/runner.py index 08004db..69d5cbe 100644 --- a/lightcards/runner.py +++ b/lightcards/runner.py @@ -2,14 +2,14 @@ # Armaan Bhojwani 2021 import argparse -from curses import wrapper +import curses import os import pkg_resources from random import shuffle import sys from . import parse, progress -from .display import Display +from .display import Display, CursesError from .deck import Status @@ -55,14 +55,14 @@ def parse_args(): return parser.parse_args() -def show(args, stack, headers): +def show(args, stack, headers, input_file): """ Get objects from cache, manipulate deck according to passed arguments, and send it to the display functions """ # Purge caches if asked if args.purge: - progress.purge(stack) + progress.purge(get_orig()[1]) # Check for caches idx = Status() @@ -79,15 +79,11 @@ def show(args, stack, headers): stack.reverse() # Send to display - win = Display(stack, headers, idx, args.view) - wrapper(win.run) - - -def reparse(): - """Parse arguments and input file again""" - args = parse_args() - os.system(f"$EDITOR {args.inp[0]}"), - return parse.parse_html(parse.md2html(args.inp[0])) + win = Display(stack, headers, idx, args.view, input_file) + try: + curses.wrapper(win.run) + except curses.error as e: + raise CursesError() from e def get_orig(): @@ -96,10 +92,12 @@ def get_orig(): def main(args=sys.argv): + sys.tracebacklimit = 0 args = parse_args() global headers, stack - (headers, stack) = parse.parse_html(parse.md2html(args.inp[0])) - show(args, stack, headers) + input_file = args.inp[0] + (headers, stack) = parse.parse_html(parse.md2html(input_file)) + show(args, stack, headers, input_file) if __name__ == "__main__":