From 031b1278eb678e1beefa16b2ec8d080262b2664b Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Mon, 13 Jul 2020 21:33:59 +0100 Subject: [PATCH] reddit: cleanup cachew wrapper a bit --- my/reddit.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/my/reddit.py b/my/reddit.py index afc5bfb..c4f9d48 100755 --- a/my/reddit.py +++ b/my/reddit.py @@ -66,13 +66,12 @@ logger = LazyLogger(__name__, level='debug') from pathlib import Path -from .kython.kompress import CPath def inputs() -> Sequence[Path]: files = get_files(config.export_path) # TODO Cpath better be automatic by get_files... - res = list(map(CPath, files)); assert len(res) > 0 - # todo move the assert to get_files? - return tuple(res) + from .kython.kompress import CPath + res = tuple(map(CPath, files)) + return res Sid = dal.Sid @@ -83,25 +82,27 @@ Upvote = dal.Upvote def _dal() -> dal.DAL: - return dal.DAL(inputs()) + inp = list(inputs()) + return dal.DAL(inp) +cache = mcachew(hashf=inputs) # depends on inputs only -@mcachew(hashf=lambda: inputs()) +@cache def saved() -> Iterator[Save]: return _dal().saved() -@mcachew(hashf=lambda: inputs()) +@cache def comments() -> Iterator[Comment]: return _dal().comments() -@mcachew(hashf=lambda: inputs()) +@cache def submissions() -> Iterator[Submission]: return _dal().submissions() -@mcachew(hashf=lambda: inputs()) +@cache def upvoted() -> Iterator[Upvote]: return _dal().upvoted()