INNER CODE UNIT · Python

process_file

existence-master/Sentient · src/server/mcp_hub/file_management/main.py:72

        def process_file():
            try:
                # Convert the Path object to a string. This is all that's needed.
                path_for_textract = str(safe_path)
                
                # On Windows, you might need to handle paths differently for some tools,
                # but doubling the slashes is incorrect. Let's try passing it directly.
                # If issues persist with specific file types, we might need a more nuanced fix,
                # but this is the correct first step.

                extracted_bytes = textract.process(path_for_textract)
                return extracted_bytes.decode('utf-8', errors='ignore')
            except Exception as e:
                return f"Error extracting text from file: {str(e)}"

        content = await asyncio.to_thread(process_file)

        return {"status": "success", "result": content}

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…