From c45e4eb98665368e2ab9ee183b565f27ad35b8c7 Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani Date: Tue, 9 Feb 2021 19:34:57 -0500 Subject: [PATCH] Fix pickle implementation --- lightcards/deck.py | 3 +++ lightcards/display.py | 2 +- lightcards/progress.py | 5 +---- lightcards/runner.py | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lightcards/deck.py b/lightcards/deck.py index f5ad583..110c5b4 100644 --- a/lightcards/deck.py +++ b/lightcards/deck.py @@ -15,6 +15,9 @@ class Card: if len(inp) >= 2: self.back = inp[1] + def __str__(self): + return f"{self.front}, {self.back}" + def unStar(self): self.starred = False diff --git a/lightcards/display.py b/lightcards/display.py index 133b719..a130728 100644 --- a/lightcards/display.py +++ b/lightcards/display.py @@ -48,7 +48,7 @@ class Display: if self.obj.getIdx() + 1 == len(self.stack): self.obj.setIdx(0) - progress.dump(self.stack, runner.get_orig()) + progress.dump(self.stack, runner.get_orig()[1]) sys.exit(0) def ntotal(self): diff --git a/lightcards/progress.py b/lightcards/progress.py index 297895d..3be0247 100644 --- a/lightcards/progress.py +++ b/lightcards/progress.py @@ -6,15 +6,12 @@ import os import pickle import shutil -global dired dired = f"{os.path.expanduser('~')}/.cache/lightcards/" def name_gen(stra): """Generate hash of stack for name of pickle file""" - hasher = hashlib.md5() - hasher.update(str(stra).encode("utf-8")) - return hasher.hexdigest() + return hashlib.md5(str([str(x) for x in stra]).encode("utf-8")).hexdigest() def make_dirs(dired): diff --git a/lightcards/runner.py b/lightcards/runner.py index 83a71b0..0d01ca1 100644 --- a/lightcards/runner.py +++ b/lightcards/runner.py @@ -56,7 +56,7 @@ def show(args, stack, headers): # Check for caches idx = Status() - cache = progress.dive(get_orig()) + cache = progress.dive(get_orig()[1]) if cache: (stack) = cache -- 2.39.2