File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -154,7 +154,7 @@ def main(
154154 (page ,) = pages_matching_title
155155 else :
156156 page = session .create_page (parent = parent , title = title )
157- sys .stdout .write (f"Created new page: { title } ({ page .url } )\n " )
157+ sys .stdout .write (f"Created new page: ' { title } ' ({ page .url } )\n " )
158158
159159 if icon :
160160 page .icon = Emoji (emoji = icon )
@@ -164,8 +164,18 @@ def main(
164164 for details in blocks
165165 ]
166166
167- for child in page .children :
168- child .delete ()
169-
170- page .append (blocks = block_objs )
171- sys .stdout .write (f"Updated existing page: { title } ({ page .url } )\n " )
167+ match_until_index = 0
168+ for index , existing_page_block in enumerate (iterable = page .children ):
169+ if index < len (blocks ) and existing_page_block == block_objs [index ]:
170+ match_until_index = index
171+ else :
172+ break
173+
174+ sys .stdout .write (
175+ f"Matching blocks until index { match_until_index } for page '{ title } '\n "
176+ )
177+ for existing_page_block in page .children [match_until_index + 1 :]:
178+ existing_page_block .delete ()
179+
180+ page .append (blocks = block_objs [match_until_index + 1 :])
181+ sys .stdout .write (f"Updated existing page: '{ title } ' ({ page .url } )\n " )
You can’t perform that action at this time.
0 commit comments