From a5a896977fa2019d18770c76f115f862c51cf707 Mon Sep 17 00:00:00 2001 From: Taylor Wilsdon Date: Tue, 3 Mar 2026 17:36:21 -0500 Subject: [PATCH] refac --- gdocs/docs_helpers.py | 15 +++++++++++---- gdocs/managers/batch_operation_manager.py | 7 ++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/gdocs/docs_helpers.py b/gdocs/docs_helpers.py index b89b44a..2d29327 100644 --- a/gdocs/docs_helpers.py +++ b/gdocs/docs_helpers.py @@ -369,7 +369,10 @@ def create_update_paragraph_style_request( def create_find_replace_request( - find_text: str, replace_text: str, match_case: bool = False, tab_id: Optional[str] = None + find_text: str, + replace_text: str, + match_case: bool = False, + tab_id: Optional[str] = None, ) -> Dict[str, Any]: """ Create a replaceAllText request for Google Docs API. @@ -434,7 +437,9 @@ def create_insert_page_break_request( return {"insertPageBreak": {"location": location}} -def create_insert_doc_tab_request(title: str, index: int, parent_tab_id: Optional[str] = None) -> Dict[str, Any]: +def create_insert_doc_tab_request( + title: str, index: int, parent_tab_id: Optional[str] = None +) -> Dict[str, Any]: """ Create an addDocumentTab request for Google Docs API. @@ -556,7 +561,7 @@ def create_bullet_list_request( nesting_level: Nesting level (0-8, where 0 is top level). If None or 0, no tabs added. paragraph_start_indices: Optional paragraph start positions for ranges with multiple paragraphs. If omitted, only start_index is tab-prefixed. - tab_id: Optional ID of the tab to target + doc_tab_id: Optional ID of the tab to target Returns: List of request dictionaries (insertText for nesting tabs if needed, @@ -593,7 +598,9 @@ def create_bullet_list_request( for paragraph_start in paragraph_starts: adjusted_start = paragraph_start + inserted_char_count - requests.append(create_insert_text_request(adjusted_start, tabs, doc_tab_id)) + requests.append( + create_insert_text_request(adjusted_start, tabs, doc_tab_id) + ) inserted_char_count += nesting_level # Keep createParagraphBullets range aligned to the same logical content. diff --git a/gdocs/managers/batch_operation_manager.py b/gdocs/managers/batch_operation_manager.py index 0d559e5..5dbaca0 100644 --- a/gdocs/managers/batch_operation_manager.py +++ b/gdocs/managers/batch_operation_manager.py @@ -295,7 +295,9 @@ class BatchOperationManager: description = f"find/replace '{op['find_text']}' → '{op['replace_text']}'" elif op_type == "insert_doc_tab": - request = create_insert_doc_tab_request(op["title"], op["index"], op.get("parent_tab_id")) + request = create_insert_doc_tab_request( + op["title"], op["index"], op.get("parent_tab_id") + ) description = f"insert tab '{op['title']}' at {op['index']}" if op.get("parent_tab_id"): description += f" under parent tab {op['parent_tab_id']}" @@ -318,6 +320,9 @@ class BatchOperationManager: "insert_table", "insert_page_break", "find_replace", + "insert_doc_tab", + "delete_doc_tab", + "update_doc_tab", ] raise ValueError( f"Unsupported operation type '{op_type}'. Supported: {', '.join(supported_types)}"