From e5ee1f8520f9122b70466ab407e41cdd5eb83935 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Sat, 13 Feb 2021 16:38:29 -0500 Subject: [PATCH] Implement cache config option --- lightcards/display.py | 8 ++++++-- lightcards/runner.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lightcards/display.py b/lightcards/display.py index 8f739e6..ae3534d 100644 --- a/lightcards/display.py +++ b/lightcards/display.py @@ -207,7 +207,7 @@ class Menu(Panel): shuffle(self.outer.stack) self.menu_print("Stack shuffled!") elif key in self.outer.config["menu_open_file"]: - progress.dump(self.outer.stack, runner.get_orig()[1]) + self.outer.dump() curses.endwin() os.system(f"$EDITOR {self.outer.input_file}"), (self.outer.headers, self.outer.stack) = parse.parse_html( @@ -291,13 +291,17 @@ class Display: else: self.disp_card() + def dump(self): + if self.config["cache"]: + progress.dump(self.stack, runner.get_orig()[1]) + def leave(self): """Pickle stack and confirm before quitting""" self.quit_obj.disp() if self.obj.index + 1 == len(self.stack): self.obj.index = 0 - progress.dump(self.stack, runner.get_orig()[1]) + self.dump() sys.exit(0) def nstarred(self): diff --git a/lightcards/runner.py b/lightcards/runner.py index 73e2758..3b8737c 100644 --- a/lightcards/runner.py +++ b/lightcards/runner.py @@ -71,7 +71,7 @@ def show(args, stack, headers, conf): # Check for caches idx = Status() cache = progress.dive(get_orig()[1]) - if cache: + if cache and conf["cache"]: (stack) = cache # Manipulate deck -- 2.39.2