diff --git a/README.org b/README.org index 8b73c4e..00a4509 100644 --- a/README.org +++ b/README.org @@ -246,7 +246,7 @@ Here's the (incomplete) list of the modules: | [[https://github.com/karlicoss/HPI/tree/master/my/photos/main.py][=my.photos.main=]] | Photos and videos on your filesystem, their GPS and timestamps | | [[https://github.com/karlicoss/HPI/tree/master/my/pinboard.py][=my.pinboard=]] | [[https://pinboard.in][Pinboard]] bookmarks | | [[https://github.com/karlicoss/HPI/tree/master/my/pocket.py][=my.pocket=]] | [[https://getpocket.com][Pocket]] bookmarks and highlights | -| [[https://github.com/karlicoss/HPI/tree/master/my/reading/polar.py][=my.reading.polar=]] | [[https://github.com/burtonator/polar-bookshelf][Polar]] articles and highlights | +| [[https://github.com/karlicoss/HPI/tree/master/my/polar.py][=my.polar=]] | [[https://github.com/burtonator/polar-bookshelf][Polar]] articles and highlights | | [[https://github.com/karlicoss/HPI/tree/master/my/reddit.py][=my.reddit=]] | Reddit data: saved items/comments/upvotes/etc. | | [[https://github.com/karlicoss/HPI/tree/master/my/rescuetime.py][=my.rescuetime=]] | Rescuetime (phone activity tracking) data. | | [[https://github.com/karlicoss/HPI/tree/master/my/roamresearch.py][=my.roamresearch=]] | [[https://roamresearch.com][Roam]] data | diff --git a/doc/MODULES.org b/doc/MODULES.org index 2a1bed8..4090e32 100644 --- a/doc/MODULES.org +++ b/doc/MODULES.org @@ -23,7 +23,7 @@ If you have some issues with the setup, see [[file:SETUP.org::#troubleshooting][ - [[#mytwittertwint][my.twitter.twint]] - [[#mytwitterarchive][my.twitter.archive]] - [[#mylastfm][my.lastfm]] - - [[#myreadingpolar][my.reading.polar]] + - [[#mypolar][my.polar]] - [[#myinstapaper][my.instapaper]] - [[#mygithubgdpr][my.github.gdpr]] - [[#mygithubghexport][my.github.ghexport]] @@ -79,7 +79,7 @@ modules = [ ('twint' , 'my.twitter.twint' ), ('twitter_archive', 'my.twitter.archive' ), ('lastfm' , 'my.lastfm' ), - ('polar' , 'my.reading.polar' ), + ('polar' , 'my.polar' ), ('instapaper' , 'my.instapaper' ), ('github' , 'my.github.gdpr' ), ('github' , 'my.github.ghexport' ), @@ -197,7 +197,7 @@ for cls, p in modules: """ export_path: Paths #+end_src -** [[file:../my/reading/polar.py][my.reading.polar]] +** [[file:../my/polar.py][my.polar]] [[https://github.com/burtonator/polar-bookshelf][Polar]] articles and highlights diff --git a/doc/SETUP.org b/doc/SETUP.org index 149843f..74aae02 100644 --- a/doc/SETUP.org +++ b/doc/SETUP.org @@ -229,7 +229,7 @@ Polar doesn't require any setup as it accesses the highlights on your filesystem You can try if it works with: -: python3 -c 'import my.reading.polar as polar; print(polar.get_entries())' +: python3 -c 'import my.polar as polar; print(polar.get_entries())' ** Google Takeout If you have zip Google Takeout archives, you can use HPI to access it: @@ -307,11 +307,11 @@ It's understandable from the app developer's perspective, but it makes things fr # todo hmm what if I could share deserialization with Polar app? -Here comes the HPI [[file:../my/reading/polar.py][polar module]]! +Here comes the HPI [[file:../my/polar.py][polar module]]! : |💾 ~/.polar (raw JSON data) | : ⇓⇓⇓ -: HPI (my.reading.polar) +: HPI (my.polar) : ⇓⇓⇓ : < python interface > diff --git a/my/reading/polar.py b/my/polar.py similarity index 95% rename from my/reading/polar.py rename to my/polar.py index f57a18d..2218c29 100755 --- a/my/reading/polar.py +++ b/my/polar.py @@ -19,7 +19,7 @@ if user_config is None: pass -from ..core import PathIsh +from .core import PathIsh from dataclasses import dataclass @dataclass class polar(user_config): @@ -30,7 +30,7 @@ class polar(user_config): defensive: bool = True # pass False if you want it to fail faster on errors (useful for debugging) -from ..core import make_config +from .core import make_config config = make_config(polar) # todo not sure where it keeps stuff on Windows? @@ -40,10 +40,10 @@ from datetime import datetime from typing import List, Dict, Iterable, NamedTuple, Sequence, Optional import json -from ..core import LazyLogger, Json -from ..core.common import isoparse -from ..error import Res, echain, sort_res_by -from ..core.konsume import wrap, Zoomable, Wdict +from .core import LazyLogger, Json +from .core.common import isoparse +from .error import Res, echain, sort_res_by +from .core.konsume import wrap, Zoomable, Wdict logger = LazyLogger(__name__) @@ -63,6 +63,7 @@ class Highlight(NamedTuple): selection: str comments: Sequence[Comment] tags: Sequence[str] + page: int # 1-indexed color: Optional[str] = None @@ -122,7 +123,7 @@ class Loader: # TODO want to ignore the whole subtree.. pi = meta['pageInfo'].zoom() - pi['num'].zoom() + page = pi['num'].zoom().value if 'dimensions' in pi: pi['dimensions'].consume_all() @@ -185,6 +186,7 @@ class Loader: selection=text, comments=tuple(comments), tags=tuple(htags), + page=page, color=color, ) h.consume() @@ -228,7 +230,7 @@ class Loader: def iter_entries() -> Iterable[Result]: - from ..core import get_files + from .core import get_files for d in get_files(config.polar_dir, glob='*/state.json'): loader = Loader(d) try: diff --git a/tests/extra/polar.py b/tests/extra/polar.py index b0611f9..0fddcf3 100644 --- a/tests/extra/polar.py +++ b/tests/extra/polar.py @@ -11,7 +11,7 @@ import pytest # type: ignore def test_hpi(prepare: str) -> None: - from my.reading.polar import get_entries + from my.polar import get_entries assert len(list(get_entries())) > 1 def test_orger(prepare: str, tmp_path: Path) -> None: @@ -45,7 +45,7 @@ def prepare(request): import my.config setattr(my.config, 'polar', user_config) - import my.reading.polar as polar + import my.polar as polar reload(polar) # TODO hmm... ok, need to document reload() yield dotpolar