cleanup hypothesis module
This commit is contained in:
parent
a521885aa0
commit
22e2d68e5d
1 changed files with 17 additions and 23 deletions
|
@ -3,50 +3,41 @@
|
||||||
"""
|
"""
|
||||||
from . import init
|
from . import init
|
||||||
|
|
||||||
from .common import PathIsh
|
from .common import get_files
|
||||||
|
from .error import Res, sort_res_by
|
||||||
import my.config.repos.hypexport as hypexport
|
|
||||||
from my.config.repos.hypexport import dal
|
|
||||||
|
|
||||||
|
import my.config.repos.hypexport.dal as hypexport
|
||||||
from my.config import hypothesis as config
|
from my.config import hypothesis as config
|
||||||
export_path: PathIsh = config.export_path
|
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
||||||
from typing import List
|
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..
|
# TODO weird. not sure why e.g. from dal import Highlight doesn't work..
|
||||||
Highlight = dal.Highlight
|
Highlight = hypexport.Highlight
|
||||||
DAL = dal.DAL
|
Page = hypexport.Page
|
||||||
Page = dal.Page
|
|
||||||
|
|
||||||
|
|
||||||
# TODO eh. not sure if I should rename everything to dao/DAO or not...
|
# TODO eh. not sure if I should rename everything to dao/DAO or not...
|
||||||
def dao() -> DAL:
|
def _dal() -> hypexport.DAL:
|
||||||
sources = get_files(export_path, '*.json')
|
sources = get_files(config.export_path, '*.json')
|
||||||
model = DAL(sources)
|
return hypexport.DAL(sources)
|
||||||
return model
|
|
||||||
|
|
||||||
|
|
||||||
def get_highlights() -> List[Res[Highlight]]:
|
def highlights() -> List[Res[Highlight]]:
|
||||||
return sort_res_by(dao().highlights(), key=lambda h: h.created)
|
return sort_res_by(_dal().highlights(), key=lambda h: h.created)
|
||||||
|
|
||||||
|
|
||||||
# TODO eh. always provide iterators? although sort_res_by could be neat too...
|
# TODO eh. always provide iterators? although sort_res_by could be neat too...
|
||||||
def get_pages() -> List[Res[Page]]:
|
def pages() -> List[Res[Page]]:
|
||||||
return sort_res_by(dao().pages(), key=lambda h: h.created)
|
return sort_res_by(_dal().pages(), key=lambda h: h.created)
|
||||||
|
|
||||||
|
|
||||||
# TODO move to side tests?
|
# TODO move to side tests?
|
||||||
def test():
|
def test():
|
||||||
get_pages()
|
list(pages())
|
||||||
get_highlights()
|
list(highlights())
|
||||||
|
|
||||||
|
|
||||||
def _main():
|
def _main():
|
||||||
|
@ -55,3 +46,6 @@ def _main():
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
_main()
|
_main()
|
||||||
|
|
||||||
|
get_highlights = highlights # TODO deprecate
|
||||||
|
get_pages = pages # TODO deprecate
|
||||||
|
|
Loading…
Add table
Reference in a new issue