core: add helper for computing stats; use it in modules

This commit is contained in:
Dima Gerasimov 2020-06-04 22:19:34 +01:00
parent a94b64c273
commit 1cc4eb5d8d
10 changed files with 79 additions and 3 deletions

View file

@ -29,7 +29,7 @@ class github(user_config):
def dal_module(self):
rpath = self.ghexport
if rpath is not None:
from .core.common import import_dir
from ..core.common import import_dir
return import_dir(rpath, '.dal')
else:
import my.config.repos.ghexport.dal as dal
@ -81,6 +81,13 @@ def events(dal=_dal()) -> Results:
yield _parse_event(d)
def stats():
from ..core import stat
return {
**stat(events),
}
# TODO hmm. need some sort of abstract syntax for this...
# TODO split further, title too
def _get_summary(e) -> Tuple[str, Optional[str], Optional[str]]: