move stuff from kobuddy
This commit is contained in:
parent
a4e1deb458
commit
bb5d0f765d
1 changed files with 24 additions and 0 deletions
|
@ -1,8 +1,32 @@
|
||||||
|
from typing import Callable, Union, List
|
||||||
|
|
||||||
from my_configuration import paths
|
from my_configuration import paths
|
||||||
from my_configuration.repos.kobuddy.src.kobuddy import *
|
from my_configuration.repos.kobuddy.src.kobuddy import *
|
||||||
|
|
||||||
set_databases(paths.kobuddy.export_dir)
|
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 get_todos():
|
||||||
def with_todo(ann):
|
def with_todo(ann):
|
||||||
if ann is None:
|
if ann is None:
|
||||||
|
|
Loading…
Add table
Reference in a new issue