reddit: cleanup cachew wrapper a bit
This commit is contained in:
parent
6b548c24c1
commit
031b1278eb
1 changed files with 10 additions and 9 deletions
19
my/reddit.py
19
my/reddit.py
|
@ -66,13 +66,12 @@ logger = LazyLogger(__name__, level='debug')
|
||||||
|
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from .kython.kompress import CPath
|
|
||||||
def inputs() -> Sequence[Path]:
|
def inputs() -> Sequence[Path]:
|
||||||
files = get_files(config.export_path)
|
files = get_files(config.export_path)
|
||||||
# TODO Cpath better be automatic by get_files...
|
# TODO Cpath better be automatic by get_files...
|
||||||
res = list(map(CPath, files)); assert len(res) > 0
|
from .kython.kompress import CPath
|
||||||
# todo move the assert to get_files?
|
res = tuple(map(CPath, files))
|
||||||
return tuple(res)
|
return res
|
||||||
|
|
||||||
|
|
||||||
Sid = dal.Sid
|
Sid = dal.Sid
|
||||||
|
@ -83,25 +82,27 @@ Upvote = dal.Upvote
|
||||||
|
|
||||||
|
|
||||||
def _dal() -> dal.DAL:
|
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]:
|
def saved() -> Iterator[Save]:
|
||||||
return _dal().saved()
|
return _dal().saved()
|
||||||
|
|
||||||
|
|
||||||
@mcachew(hashf=lambda: inputs())
|
@cache
|
||||||
def comments() -> Iterator[Comment]:
|
def comments() -> Iterator[Comment]:
|
||||||
return _dal().comments()
|
return _dal().comments()
|
||||||
|
|
||||||
|
|
||||||
@mcachew(hashf=lambda: inputs())
|
@cache
|
||||||
def submissions() -> Iterator[Submission]:
|
def submissions() -> Iterator[Submission]:
|
||||||
return _dal().submissions()
|
return _dal().submissions()
|
||||||
|
|
||||||
|
|
||||||
@mcachew(hashf=lambda: inputs())
|
@cache
|
||||||
def upvoted() -> Iterator[Upvote]:
|
def upvoted() -> Iterator[Upvote]:
|
||||||
return _dal().upvoted()
|
return _dal().upvoted()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue