Spaces:
Sleeping
Sleeping
Download docstream/core/extractor_v2.py from DevilBits/auto-swe-agent-ui: direct link, hf CLI and curl.
- Browser
- Download file 473 Bytes
-
https://huggingface.co/spaces/DevilBits/auto-swe-agent-ui/resolve/main/docstream/core/extractor_v2.py
- Command line
-
hf download hf://spaces/DevilBits/auto-swe-agent-ui/docstream/core/extractor_v2.py
-
curl -L -o extractor_v2.py https://huggingface.co/spaces/DevilBits/auto-swe-agent-ui/resolve/main/docstream/core/extractor_v2.py
473 Bytes
| import fitz | |
| class ExtractionError(Exception): | |
| pass | |
| def extract_structured(file_path, password=None): | |
| doc = fitz.Document(file_path) | |
| if doc.is_encrypted: | |
| if password is None: | |
| raise ExtractionError( | |
| "PDF is password protected. Pass password= to extract()" | |
| ) | |
| if not doc.authenticate(password): | |
| raise ExtractionError("Incorrect password for PDF.") | |
| # rest of the function implementation... | |