kobo: BREAKING changes. Use kobuddy module directly, rename export_dir to export_path.

Hopefully this makes a lot of sense in the first place, and not that many users, so deserves breaking.
This commit is contained in:
Dima Gerasimov 2020-06-04 22:43:10 +01:00
parent db852b3927
commit 821eb47c93
6 changed files with 51 additions and 9 deletions

View file

@ -27,6 +27,7 @@ If you have some issues with the setup, see [[file:SETUP.org::#troubleshooting][
- [[#myinstapaper][my.instapaper]]
- [[#mygithubgdpr][my.github.gdpr]]
- [[#mygithubghexport][my.github.ghexport]]
- [[#mykobo][my.kobo]]
:END:
* Intro
@ -80,6 +81,7 @@ modules = [
('instapaper' , 'my.instapaper' ),
('github' , 'my.github.gdpr' ),
('github' , 'my.github.ghexport' ),
('kobo' , 'my.kobo' ),
]
def indent(s, spaces=4):
@ -261,3 +263,15 @@ for cls, p in modules:
# if omitted, will use /tmp
cache_dir: Optional[PathIsh] = None
#+end_src
** [[file:../my/kobo.py][my.kobo]]
[[https://uk.kobobooks.com/products/kobo-aura-one][Kobo]] e-ink reader: annotations and reading stats
#+begin_src python
class kobo:
'''
Uses [[https://github.com/karlicoss/kobuddy#as-a-backup-tool][kobuddy]] outputs.
'''
# path[s]/glob to the exported databases
export_path: Paths
#+end_src

View file

5
my/books/kobo.py Normal file
View file

@ -0,0 +1,5 @@
import warnings
warnings.warn('my.books.kobo is deprecated! Please use my.kobo instead!')
from ..kobo import *

View file

@ -1,6 +1,7 @@
import warnings
warnings.warn('my.coding.github is deprecated! Please use my.github.all instead!', DeprecationWarning)
warnings.warn('my.coding.github is deprecated! Please use my.github.all instead!')
# todo why aren't DeprecationWarning shown by default??
from ..github.all import events, get_events

View file

@ -1,18 +1,38 @@
"""
[[https://uk.kobobooks.com/products/kobo-aura-one][Kobo]] e-ink reader: annotations and reading stats
"""
from typing import Callable, Union, List
from my.config import kobo as config
from my.config.repos.kobuddy.src.kobuddy import *
# hmm, explicit imports make pylint a bit happier..
from my.config.repos.kobuddy.src.kobuddy import Highlight, set_databases, get_highlights
# TODO require installing kobuddy, need to upload to pypi as well?
from dataclasses import dataclass
from .core import Paths
from my.config import kobo as user_config
@dataclass
class kobo(user_config):
'''
Uses [[https://github.com/karlicoss/kobuddy#as-a-backup-tool][kobuddy]] outputs.
'''
# path[s]/glob to the exported databases
export_path: Paths
from .core.cfg import make_config
config = make_config(kobo)
from .core import get_files
import kobuddy
# todo not sure about this glob..
kobuddy.DATABASES = list(get_files(config.export_path, glob='*.sqlite'))
#########################
# hmm, explicit imports make pylint a bit happier?
from kobuddy import Highlight, get_highlights
from kobuddy import *
set_databases(config.export_dir)
def stats():
from ..core import stat
from .core import stat
return {
**stat(get_highlights),
}
@ -20,6 +40,7 @@ def stats():
## TODO hmm. not sure if all this really belongs here?... perhaps orger?
from typing import Callable, Union, List
# TODO maybe type over T?
_Predicate = Callable[[str], bool]
Predicatish = Union[str, _Predicate]

View file

@ -43,7 +43,8 @@ def kopen(path: PathIsh, *args, mode: str='rt', **kwargs) -> IO[str]:
ifile.seekable = lambda: False # type: ignore
ifile.read1 = ifile.read # type: ignore
# TODO pass all kwargs here??
return io.TextIOWrapper(ifile, encoding=encoding)
# todo 'expected "BinaryIO"'??
return io.TextIOWrapper(ifile, encoding=encoding) # type: ignore[arg-type]
elif suf in {'.lz4'}:
import lz4.frame # type: ignore
return lz4.frame.open(str(pp), mode, *args, **kwargs)