From 3e821ca7fd2f3abc199d3327228394f5ea84fa71 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Sun, 21 Feb 2021 18:53:51 +0000 Subject: [PATCH] my.github.ghexport: get rid of custom cache_dir --- my/github/ghexport.py | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/my/github/ghexport.py b/my/github/ghexport.py index f4007cd..c88a6e0 100644 --- a/my/github/ghexport.py +++ b/my/github/ghexport.py @@ -17,16 +17,12 @@ class github(user_config): ''' Uses [[https://github.com/karlicoss/ghexport][ghexport]] outputs. ''' - # path[s]/glob to the exported JSON data + export_path: Paths + '''path[s]/glob to the exported JSON data''' - # path to a cache directory - # if omitted, will use /tmp - cache_dir: Optional[PathIsh] = None ### -# TODO perhaps using /tmp in case of None isn't ideal... maybe it should be treated as if cache is off - from ..core.cfg import make_config, Attrs def migration(attrs: Attrs) -> Attrs: export_dir = 'export_dir' @@ -46,10 +42,9 @@ except ModuleNotFoundError as e: ############################ -from pathlib import Path from typing import Tuple, Iterable, Dict, Sequence -from ..core import get_files +from ..core import get_files, Path from ..core.common import mcachew from .common import Event, parse_dt, Results @@ -64,9 +59,10 @@ def _dal() -> dal.DAL: return dal.DAL(sources) -# TODO hmm. not good, need to be lazier?... -@mcachew(config.cache_dir, hashf=lambda dal: dal.sources) -def events(dal=_dal()) -> Results: +# todo cachew: hmm. not good, need to be lazier?... +@mcachew(depends_on=lambda: inputs()) +def events() -> Results: + dal = _dal() for d in dal.events(): if isinstance(d, Exception): yield d @@ -74,8 +70,8 @@ def events(dal=_dal()) -> Results: yield _parse_event(d) -def stats(): - from ..core import stat +from ..core import stat, Stats +def stats() -> Stats: return { **stat(events), }