move stuff from kobuddy

This commit is contained in:
Dima Gerasimov 2019-10-09 23:31:21 +01:00
parent a4e1deb458
commit bb5d0f765d

View file

@ -1,8 +1,32 @@
from typing import Callable, Union, List
from my_configuration import paths
from my_configuration.repos.kobuddy.src.kobuddy import *
set_databases(paths.kobuddy.export_dir)
# TODO maybe type over T?
_Predicate = Callable[[str], bool]
Predicatish = Union[str, _Predicate]
def from_predicatish(p: Predicatish) -> _Predicate:
if isinstance(p, str):
def ff(s):
return s == p
return ff
else:
return p
def by_annotation(predicatish: Predicatish, **kwargs) -> List[Highlight]:
pred = from_predicatish(predicatish)
res: List[Highlight] = []
for h in get_highlights(**kwargs):
if pred(h.annotation):
res.append(h)
return res
def get_todos():
def with_todo(ann):
if ann is None: