Try to read from a url, file or string. Parameters ---------- obj : str, unicode, path object, or file-like object Returns ------- raw_text : str
(
obj: FilePath | BaseBuffer,
encoding: str | None,
storage_options: StorageOptions | None,
)
| 115 | |
| 116 | |
| 117 | def _read( |
| 118 | obj: FilePath | BaseBuffer, |
| 119 | encoding: str | None, |
| 120 | storage_options: StorageOptions | None, |
| 121 | ) -> str | bytes: |
| 122 | """ |
| 123 | Try to read from a url, file or string. |
| 124 | |
| 125 | Parameters |
| 126 | ---------- |
| 127 | obj : str, unicode, path object, or file-like object |
| 128 | |
| 129 | Returns |
| 130 | ------- |
| 131 | raw_text : str |
| 132 | """ |
| 133 | try: |
| 134 | with get_handle( |
| 135 | obj, "r", encoding=encoding, storage_options=storage_options |
| 136 | ) as handles: |
| 137 | return handles.handle.read() |
| 138 | except OSError as err: |
| 139 | if not is_url(obj): |
| 140 | raise FileNotFoundError( |
| 141 | f"[Errno {errno.ENOENT}] {os.strerror(errno.ENOENT)}: {obj}" |
| 142 | ) from err |
| 143 | raise |
| 144 | |
| 145 | |
| 146 | class _HtmlFrameParser: |
no test coverage detected