diff --git a/my/kython/konsume.py b/my/kython/konsume.py index 5fa9f3a..bdf9d4b 100644 --- a/my/kython/konsume.py +++ b/my/kython/konsume.py @@ -127,6 +127,7 @@ def wrap(j, throw=True) -> Iterator[Zoomable]: for c in children: if not c.this_consumed(): # TODO hmm. how does it figure out if it's consumed??? if throw: + # TODO need to keep a full path or something... raise UnconsumedError(f''' Expected {c} to be fully consumed by the parser. '''.lstrip()) @@ -175,6 +176,19 @@ def test_consume_all(): aaa['bbb'].consume_all() +def test_consume_few(): + import pytest + pytest.skip('Will think about it later..') + with wrap({ + 'important': 123, + 'unimportant': 'whatever' + }) as w: + w = cast(Wdict, w) + w['important'].zoom() + w.consume_all() + # TODO hmm, we want smth like this to work.. + + def test_zoom() -> None: import pytest # type: ignore with wrap({'aaa': 'whatever'}) as w: diff --git a/my/reading/polar.py b/my/reading/polar.py index 10d2e74..2db5e4d 100755 --- a/my/reading/polar.py +++ b/my/reading/polar.py @@ -101,7 +101,10 @@ class Loader: meta = cast(Wdict, meta) # TODO this should be destructive zoom? meta['notes'].zoom() # TODO ??? is it deliberate? - meta['pagemarks'].zoom() + + meta['pagemarks'].consume_all() + + if 'notes' in meta: # TODO something nicer? notes = meta['notes'].zoom() @@ -113,15 +116,17 @@ class Loader: highlights = meta['textHighlights'].zoom() # TODO could be useful to at least add a meta bout area highlights/screens - meta['areaHighlights'].zoom() + meta['areaHighlights'].consume_all() meta['screenshots'].zoom() meta['thumbnails'].zoom() if 'readingProgress' in meta: - meta['readingProgress'].zoom() + meta['readingProgress'].consume_all() - # TODO want to ignore the whold subtree.. + # TODO want to ignore the whole subtree.. pi = meta['pageInfo'].zoom() pi['num'].zoom() + if 'dimensions' in pi: + pi['dimensions'].consume_all() # TODO how to make it nicer? cmap: Dict[Hid, List[Comment]] = {} @@ -207,7 +212,7 @@ class Loader: filename = di['filename'] # TODO here title = di.get('title', None) tags_dict = di['tags'] - pm = j['pageMetas'] + pm = j['pageMetas'] # TODO FIXME handle this too # todo defensive? tags = tuple(t['label'] for t in tags_dict.values())