From: Armaan Bhojwani Date: Mon, 1 Feb 2021 03:22:43 +0000 (-0500) Subject: Cache the stack and headers X-Git-Tag: v0.4.0~3 X-Git-Url: https://git.armaanb.net/?p=lightcards.git;a=commitdiff_plain;h=eec0373eb1745933e0ad618af7e79556427a4f6f;hp=e99950c3023a64f68cdc968e2759f45653d6b9af Cache the stack and headers --- diff --git a/lightcards/display.py b/lightcards/display.py index 1035d76..a1a2c21 100644 --- a/lightcards/display.py +++ b/lightcards/display.py @@ -25,6 +25,8 @@ class Display(): def leave(self): progress.dump(self.obj, "status", self.stack) + progress.dump(self.stack, "stack", self.stack) + progress.dump(self.headers, "headers", self.stack) sys.exit(0) def disp_bar(self): diff --git a/lightcards/lightcards.py b/lightcards/lightcards.py index d170b35..b4b4598 100644 --- a/lightcards/lightcards.py +++ b/lightcards/lightcards.py @@ -55,6 +55,14 @@ def show(args, stack, headers): else: idx = Status() + stackb = progress.dive("stack", stack) + if stackb and not args.purge: + stack = stackb + + headerb = progress.dive("headers", stack) + if headerb and not args.purge: + headers = headerb + if args.flip: for x in stack: x[0], x[1] = x[1], x[0] diff --git a/lightcards/progress.py b/lightcards/progress.py index f096da4..b721a49 100644 --- a/lightcards/progress.py +++ b/lightcards/progress.py @@ -20,9 +20,8 @@ def name_gen(stra): def dump(obj, typer, stra): dired = f"{os.path.expanduser('~')}/.cache/lightcards/{name_gen(stra)}/" - if os.path.exists(dired): - shutil.rmtree(dired) - os.makedirs(dired) + if not os.path.exists(dired): + os.makedirs(dired) pickle.dump(obj, open(f"{dired}/{typer}.p", "wb"))