Spaces:
Sleeping
Sleeping
Download docstream/core/extractor.py from DevilBits/auto-swe-agent-ui: direct link, hf CLI and curl.
- Browser
- Download file 522 Bytes
-
https://huggingface.co/spaces/DevilBits/auto-swe-agent-ui/resolve/main/docstream/core/extractor.py
- Command line
-
hf download hf://spaces/DevilBits/auto-swe-agent-ui/docstream/core/extractor.py
-
curl -L -o extractor.py https://huggingface.co/spaces/DevilBits/auto-swe-agent-ui/resolve/main/docstream/core/extractor.py
522 Bytes
| import fitz | |
| from docstream.core.extractor_v2 import ExtractionError | |
| class PDFExtractor: | |
| def __init__(self, file_path, password=None): | |
| self.file_path = file_path | |
| self.password = password | |
| self.doc = fitz.Document(file_path) | |
| if self.doc.is_encrypted: | |
| if self.password: | |
| self.doc.authenticate(self.password) | |
| else: | |
| raise ExtractionError( | |
| "PDF is password protected. Pass password= to extract()" | |
| ) | |