From 8a800e9b06f99dc6877a29d3d49ac29b9a56d62b Mon Sep 17 00:00:00 2001 From: Dima Gerasimov Date: Mon, 2 Dec 2019 09:03:46 +0000 Subject: [PATCH] handle changing comment --- my/instapaper.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/my/instapaper.py b/my/instapaper.py index 3775e77..4860fb9 100644 --- a/my/instapaper.py +++ b/my/instapaper.py @@ -80,6 +80,11 @@ def get_stuff(limit=0) -> Tuple[BDict, HDict]: def dkey(x): return lambda d: d[x] + def hl_key(h: Highlight): + d = h._asdict() + del d['note'] # it can change so we ignore it + return d + all_bks: BDict = OrderedDict() all_hls: HDict = OrderedDict() # TODO can restore url by bookmark id @@ -113,7 +118,8 @@ def get_stuff(limit=0) -> Tuple[BDict, HDict]: title=bk.title, ) prev = all_hls.get(hid, None) - assert prev is None or prev == h + # TODO right, if note changes it could change as well + assert prev is None or hl_key(prev) == hl_key(h), f'prev: {prev}, cur: {h}' all_hls[hid] = h return all_bks, all_hls