From f75887e26e4260fe37f2f7b29984400bcbe728e6 Mon Sep 17 00:00:00 2001 From: Thomas Sileo Date: Sun, 2 Feb 2020 17:43:19 +0100 Subject: [PATCH] docstore: improve pointers support --- blobstash/docstore/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/blobstash/docstore/__init__.py b/blobstash/docstore/__init__.py index 209a5ef..b804a88 100644 --- a/blobstash/docstore/__init__.py +++ b/blobstash/docstore/__init__.py @@ -238,12 +238,24 @@ class DocsQueryIterator(BasePaginationIterator): def _fill_pointers(doc, pointers): """Replace the pointer by actual object representation.""" + if not isinstance(doc, dict): + return + for k, v in doc.items(): if isinstance(v, str): if v.startswith("@filetree/ref:"): doc[k] = Attachment(v, Node.from_resp(pointers[v])) elif isinstance(v, dict): _fill_pointers(v, pointers) + elif isinstance(v, list): + doc[k] = [ + Attachment(item, Node.from_resp(pointers[item])) + if isinstance(item, str) and item.startswith("@filetree/ref:") + else item + for item in v + ] + for item in doc[k]: + _fill_pointers(item, pointers) class Collection: -- 2.45.2