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:
parent
db852b3927
commit
821eb47c93
6 changed files with 51 additions and 9 deletions
|
@ -27,6 +27,7 @@ If you have some issues with the setup, see [[file:SETUP.org::#troubleshooting][
|
||||||
- [[#myinstapaper][my.instapaper]]
|
- [[#myinstapaper][my.instapaper]]
|
||||||
- [[#mygithubgdpr][my.github.gdpr]]
|
- [[#mygithubgdpr][my.github.gdpr]]
|
||||||
- [[#mygithubghexport][my.github.ghexport]]
|
- [[#mygithubghexport][my.github.ghexport]]
|
||||||
|
- [[#mykobo][my.kobo]]
|
||||||
:END:
|
:END:
|
||||||
|
|
||||||
* Intro
|
* Intro
|
||||||
|
@ -80,6 +81,7 @@ modules = [
|
||||||
('instapaper' , 'my.instapaper' ),
|
('instapaper' , 'my.instapaper' ),
|
||||||
('github' , 'my.github.gdpr' ),
|
('github' , 'my.github.gdpr' ),
|
||||||
('github' , 'my.github.ghexport' ),
|
('github' , 'my.github.ghexport' ),
|
||||||
|
('kobo' , 'my.kobo' ),
|
||||||
]
|
]
|
||||||
|
|
||||||
def indent(s, spaces=4):
|
def indent(s, spaces=4):
|
||||||
|
@ -261,3 +263,15 @@ for cls, p in modules:
|
||||||
# if omitted, will use /tmp
|
# if omitted, will use /tmp
|
||||||
cache_dir: Optional[PathIsh] = None
|
cache_dir: Optional[PathIsh] = None
|
||||||
#+end_src
|
#+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
|
||||||
|
|
5
my/books/kobo.py
Normal file
5
my/books/kobo.py
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
import warnings
|
||||||
|
|
||||||
|
warnings.warn('my.books.kobo is deprecated! Please use my.kobo instead!')
|
||||||
|
|
||||||
|
from ..kobo import *
|
|
@ -1,6 +1,7 @@
|
||||||
import warnings
|
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
|
from ..github.all import events, get_events
|
||||||
|
|
||||||
|
|
35
my/kobo.py
35
my/kobo.py
|
@ -1,18 +1,38 @@
|
||||||
"""
|
"""
|
||||||
[[https://uk.kobobooks.com/products/kobo-aura-one][Kobo]] e-ink reader: annotations and reading stats
|
[[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
|
# TODO require installing kobuddy, need to upload to pypi as well?
|
||||||
from my.config.repos.kobuddy.src.kobuddy import *
|
from dataclasses import dataclass
|
||||||
# hmm, explicit imports make pylint a bit happier..
|
from .core import Paths
|
||||||
from my.config.repos.kobuddy.src.kobuddy import Highlight, set_databases, get_highlights
|
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():
|
def stats():
|
||||||
from ..core import stat
|
from .core import stat
|
||||||
return {
|
return {
|
||||||
**stat(get_highlights),
|
**stat(get_highlights),
|
||||||
}
|
}
|
||||||
|
@ -20,6 +40,7 @@ def stats():
|
||||||
## TODO hmm. not sure if all this really belongs here?... perhaps orger?
|
## TODO hmm. not sure if all this really belongs here?... perhaps orger?
|
||||||
|
|
||||||
|
|
||||||
|
from typing import Callable, Union, List
|
||||||
# TODO maybe type over T?
|
# TODO maybe type over T?
|
||||||
_Predicate = Callable[[str], bool]
|
_Predicate = Callable[[str], bool]
|
||||||
Predicatish = Union[str, _Predicate]
|
Predicatish = Union[str, _Predicate]
|
||||||
|
|
|
@ -43,7 +43,8 @@ def kopen(path: PathIsh, *args, mode: str='rt', **kwargs) -> IO[str]:
|
||||||
ifile.seekable = lambda: False # type: ignore
|
ifile.seekable = lambda: False # type: ignore
|
||||||
ifile.read1 = ifile.read # type: ignore
|
ifile.read1 = ifile.read # type: ignore
|
||||||
# TODO pass all kwargs here??
|
# 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'}:
|
elif suf in {'.lz4'}:
|
||||||
import lz4.frame # type: ignore
|
import lz4.frame # type: ignore
|
||||||
return lz4.frame.open(str(pp), mode, *args, **kwargs)
|
return lz4.frame.open(str(pp), mode, *args, **kwargs)
|
||||||
|
|
Loading…
Add table
Reference in a new issue