From: Armaan Bhojwani Date: Wed, 10 Feb 2021 00:34:57 +0000 (-0500) Subject: Fix pickle implementation X-Git-Tag: v0.6.0~30 X-Git-Url: https://git.armaanb.net/?p=lightcards.git;a=commitdiff_plain;h=c45e4eb98665368e2ab9ee183b565f27ad35b8c7 Fix pickle implementation --- 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