From 9b6e857bbbd0e59092c00d0eb25cb1ae4384e356 Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Sun, 4 Aug 2019 16:23:25 +0100 Subject: [PATCH] fix yielding --- emfit/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/emfit/__init__.py b/emfit/__init__.py index dcd7486..da1d831 100755 --- a/emfit/__init__.py +++ b/emfit/__init__.py @@ -296,7 +296,7 @@ def dir_hash(path: Path): @cachew(db_path=Path('/L/data/.cache/emfit.cache'), hashf=dir_hash) -def iter_datas(path: Path) -> Iterator[Emfit]: +def iter_datas_cached(path: Path) -> Iterator[Emfit]: for f in sorted(path.glob('*.json')): sid = f.stem if sid in EXCLUDED: @@ -306,8 +306,12 @@ def iter_datas(path: Path) -> Iterator[Emfit]: yield from Emfit.make(em) +def iter_datas(path=PATH) -> Iterator[Emfit]: + yield from iter_datas_cached(path) + + def get_datas() -> List[Emfit]: - return list(sorted(iter_datas(PATH), key=lambda e: e.start)) + return list(sorted(iter_datas(), key=lambda e: e.start)) # TODO move away old entries if there is a diff??