|
1 | 1 | """Functions to handle all operations on the PDF's.""" |
2 | 2 |
|
| 3 | +from __future__ import annotations |
| 4 | + |
3 | 5 | import multiprocessing as mp |
4 | 6 | import os |
5 | 7 | import sys |
@@ -52,12 +54,16 @@ class PDFHandler: |
52 | 54 | """ |
53 | 55 |
|
54 | 56 | def __init__( |
55 | | - self, filepath: Union[StrByteType, Path], pages="1", password=None, debug=False |
| 57 | + self, |
| 58 | + filepath: StrByteType | Path | str, |
| 59 | + pages="1", |
| 60 | + password=None, |
| 61 | + debug=False, |
56 | 62 | ): |
57 | 63 | self.debug = debug |
58 | 64 | if is_url(filepath): |
59 | | - filepath = download_url(filepath) |
60 | | - self.filepath: Union[StrByteType, Path] = filepath |
| 65 | + filepath = download_url(str(filepath)) |
| 66 | + self.filepath: StrByteType | Path | str = filepath |
61 | 67 |
|
62 | 68 | if isinstance(filepath, str) and not filepath.lower().endswith(".pdf"): |
63 | 69 | raise NotImplementedError("File format not supported") |
@@ -114,7 +120,7 @@ def _get_pages(self, pages): |
114 | 120 | result.extend(range(p["start"], p["end"] + 1)) |
115 | 121 | return sorted(set(result)) |
116 | 122 |
|
117 | | - def _save_page(self, filepath: Union[StrByteType, Path], page, temp): |
| 123 | + def _save_page(self, filepath: StrByteType | Path, page, temp): |
118 | 124 | """Saves specified page from PDF into a temporary directory. |
119 | 125 |
|
120 | 126 | Parameters |
|
0 commit comments