diff --git a/my/hypothesis.py b/my/hypothesis.py index 16b48cd..46e00bc 100644 --- a/my/hypothesis.py +++ b/my/hypothesis.py @@ -3,50 +3,41 @@ """ from . import init -from .common import PathIsh - -import my.config.repos.hypexport as hypexport -from my.config.repos.hypexport import dal +from .common import get_files +from .error import Res, sort_res_by +import my.config.repos.hypexport.dal as hypexport from my.config import hypothesis as config -export_path: PathIsh = config.export_path ### from typing import List -from .common import get_files, cproperty, group_by_key -from .error import Res, sort_res_by - - - # TODO weird. not sure why e.g. from dal import Highlight doesn't work.. -Highlight = dal.Highlight -DAL = dal.DAL -Page = dal.Page +Highlight = hypexport.Highlight +Page = hypexport.Page # TODO eh. not sure if I should rename everything to dao/DAO or not... -def dao() -> DAL: - sources = get_files(export_path, '*.json') - model = DAL(sources) - return model +def _dal() -> hypexport.DAL: + sources = get_files(config.export_path, '*.json') + return hypexport.DAL(sources) -def get_highlights() -> List[Res[Highlight]]: - return sort_res_by(dao().highlights(), key=lambda h: h.created) +def highlights() -> List[Res[Highlight]]: + return sort_res_by(_dal().highlights(), key=lambda h: h.created) # TODO eh. always provide iterators? although sort_res_by could be neat too... -def get_pages() -> List[Res[Page]]: - return sort_res_by(dao().pages(), key=lambda h: h.created) +def pages() -> List[Res[Page]]: + return sort_res_by(_dal().pages(), key=lambda h: h.created) # TODO move to side tests? def test(): - get_pages() - get_highlights() + list(pages()) + list(highlights()) def _main(): @@ -55,3 +46,6 @@ def _main(): if __name__ == '__main__': _main() + +get_highlights = highlights # TODO deprecate +get_pages = pages # TODO deprecate