This commit is contained in:
Taylor Wilsdon
2026-02-01 12:07:00 -05:00
parent cfab4a59f7
commit 1197518473
2 changed files with 22 additions and 10 deletions

View File

@@ -1333,7 +1333,6 @@ async def export_doc_to_pdf(
# ============================================================================== # ==============================================================================
@server.tool() @server.tool()
@handle_http_errors("format_paragraph_style", service_type="docs") @handle_http_errors("format_paragraph_style", service_type="docs")
@require_google_service("docs", "docs_write") @require_google_service("docs", "docs_write")
@@ -1402,7 +1401,10 @@ async def format_paragraph_style(
fields.append("lineSpacing") fields.append("lineSpacing")
if indent_first_line is not None: if indent_first_line is not None:
paragraph_style["indentFirstLine"] = {"magnitude": indent_first_line, "unit": "PT"} paragraph_style["indentFirstLine"] = {
"magnitude": indent_first_line,
"unit": "PT",
}
fields.append("indentFirstLine") fields.append("indentFirstLine")
if indent_start is not None: if indent_start is not None:
@@ -1516,8 +1518,6 @@ async def apply_heading_style(
return f"Applied {heading_style} style to range {start_index}-{end_index} in document {document_id}. Link: {link}" return f"Applied {heading_style} style to range {start_index}-{end_index} in document {document_id}. Link: {link}"
# Create comment management tools for documents # Create comment management tools for documents
_comment_tools = create_comment_tools("document", "document_id") _comment_tools = create_comment_tools("document", "document_id")

View File

@@ -799,7 +799,9 @@ async def import_to_google_doc(
# Validate inputs # Validate inputs
source_count = sum(1 for x in [content, file_path, file_url] if x is not None) source_count = sum(1 for x in [content, file_path, file_url] if x is not None)
if source_count == 0: if source_count == 0:
raise ValueError("You must provide one of: 'content', 'file_path', or 'file_url'.") raise ValueError(
"You must provide one of: 'content', 'file_path', or 'file_url'."
)
if source_count > 1: if source_count > 1:
raise ValueError("Provide only one of: 'content', 'file_path', or 'file_url'.") raise ValueError("Provide only one of: 'content', 'file_path', or 'file_url'.")
@@ -856,7 +858,9 @@ async def import_to_google_doc(
# Regular path # Regular path
actual_path = file_path actual_path = file_path
else: else:
raise ValueError(f"file_path should be a local path or file:// URL, got: {file_path}") raise ValueError(
f"file_path should be a local path or file:// URL, got: {file_path}"
)
path_obj = Path(actual_path) path_obj = Path(actual_path)
if not path_obj.exists(): if not path_obj.exists():
@@ -870,7 +874,9 @@ async def import_to_google_doc(
# Re-detect format from actual file if not specified # Re-detect format from actual file if not specified
if not source_format: if not source_format:
source_mime_type = _detect_source_format(actual_path) source_mime_type = _detect_source_format(actual_path)
logger.info(f"[import_to_google_doc] Re-detected from path: {source_mime_type}") logger.info(
f"[import_to_google_doc] Re-detected from path: {source_mime_type}"
)
# Handle file_url (remote file) # Handle file_url (remote file)
elif file_url is not None: elif file_url is not None:
@@ -884,15 +890,21 @@ async def import_to_google_doc(
async with httpx.AsyncClient(follow_redirects=True) as client: async with httpx.AsyncClient(follow_redirects=True) as client:
resp = await client.get(file_url) resp = await client.get(file_url)
if resp.status_code != 200: if resp.status_code != 200:
raise Exception(f"Failed to fetch file from URL: {file_url} (status {resp.status_code})") raise Exception(
f"Failed to fetch file from URL: {file_url} (status {resp.status_code})"
)
file_data = resp.content file_data = resp.content
logger.info(f"[import_to_google_doc] Downloaded from URL: {len(file_data)} bytes") logger.info(
f"[import_to_google_doc] Downloaded from URL: {len(file_data)} bytes"
)
# Re-detect format from URL if not specified # Re-detect format from URL if not specified
if not source_format: if not source_format:
source_mime_type = _detect_source_format(file_url) source_mime_type = _detect_source_format(file_url)
logger.info(f"[import_to_google_doc] Re-detected from URL: {source_mime_type}") logger.info(
f"[import_to_google_doc] Re-detected from URL: {source_mime_type}"
)
# Upload with conversion # Upload with conversion
media = MediaIoBaseUpload( media = MediaIoBaseUpload(