|
9 | 9 | from enum import Enum |
10 | 10 | from functools import cache |
11 | 11 | from pathlib import Path |
12 | | -from typing import TYPE_CHECKING, Any |
| 12 | +from typing import TYPE_CHECKING |
13 | 13 | from urllib.parse import urlparse |
14 | 14 | from urllib.request import url2pathname |
15 | 15 |
|
@@ -184,20 +184,6 @@ def _block_with_uploaded_file( |
184 | 184 | return block |
185 | 185 |
|
186 | 186 |
|
187 | | -@beartype |
188 | | -def _block_from_details( |
189 | | - *, |
190 | | - details: dict[str, Any], |
191 | | - session: Session, |
192 | | -) -> Block: |
193 | | - """ |
194 | | - Create a Block from a serialized block details, recursively processing |
195 | | - children. |
196 | | - """ |
197 | | - block = Block.wrap_obj_ref(UnoObjAPIBlock.model_validate(obj=details)) |
198 | | - return _block_with_uploaded_file(block=block, session=session) |
199 | | - |
200 | | - |
201 | 187 | @beartype |
202 | 188 | class _ParentType(Enum): |
203 | 189 | """ |
@@ -305,9 +291,13 @@ def main( |
305 | 291 | existing_page_block.delete() |
306 | 292 |
|
307 | 293 | block_objs_to_upload = [ |
308 | | - _block_from_details(details=details, session=session) |
| 294 | + Block.wrap_obj_ref(UnoObjAPIBlock.model_validate(obj=details)) |
309 | 295 | for details in blocks[delete_start_index:] |
310 | 296 | ] |
311 | | - page.append(blocks=block_objs_to_upload) |
| 297 | + block_objs_with_uploaded_files = [ |
| 298 | + _block_with_uploaded_file(block=block, session=session) |
| 299 | + for block in block_objs_to_upload |
| 300 | + ] |
| 301 | + page.append(blocks=block_objs_with_uploaded_files) |
312 | 302 |
|
313 | 303 | click.echo(message=f"Updated existing page: '{title}' ({page.url})") |
0 commit comments