|
1 | 1 | from __future__ import annotations |
2 | 2 |
|
3 | 3 | import sys |
| 4 | +from collections.abc import Iterator |
4 | 5 | from typing import TYPE_CHECKING |
5 | 6 | from typing import Any |
6 | 7 |
|
| 8 | +from upath import UnsupportedOperation |
7 | 9 | from upath._chain import DEFAULT_CHAIN_PARSER |
8 | 10 | from upath._flavour import upath_strip_protocol |
9 | 11 | from upath.core import UPath |
|
13 | 15 | from typing import Literal |
14 | 16 |
|
15 | 17 | if sys.version_info >= (3, 11): |
| 18 | + from typing import Self |
16 | 19 | from typing import Unpack |
17 | 20 | else: |
| 21 | + from typing_extensions import Self |
18 | 22 | from typing_extensions import Unpack |
19 | 23 |
|
20 | 24 | from upath._chain import FSSpecChainParser |
@@ -166,3 +170,35 @@ def __init__( |
166 | 170 | super().__init__( |
167 | 171 | *args, protocol=protocol, chain_parser=chain_parser, **storage_options |
168 | 172 | ) |
| 173 | + |
| 174 | + def iterdir(self) -> Iterator[Self]: |
| 175 | + try: |
| 176 | + yield from super().iterdir() |
| 177 | + except NotImplementedError: |
| 178 | + raise UnsupportedOperation |
| 179 | + |
| 180 | + def touch(self, mode: int = 0o666, exist_ok: bool = True) -> None: |
| 181 | + raise UnsupportedOperation |
| 182 | + |
| 183 | + def mkdir( |
| 184 | + self, |
| 185 | + mode: int = 0o777, |
| 186 | + parents: bool = False, |
| 187 | + exist_ok: bool = False, |
| 188 | + ) -> None: |
| 189 | + raise UnsupportedOperation |
| 190 | + |
| 191 | + def unlink(self, missing_ok: bool = False) -> None: |
| 192 | + raise UnsupportedOperation |
| 193 | + |
| 194 | + def write_bytes(self, data: bytes) -> int: |
| 195 | + raise UnsupportedOperation("DataPath does not support writing") |
| 196 | + |
| 197 | + def write_text( |
| 198 | + self, |
| 199 | + data: str, |
| 200 | + encoding: str | None = None, |
| 201 | + errors: str | None = None, |
| 202 | + newline: str | None = None, |
| 203 | + ) -> int: |
| 204 | + raise UnsupportedOperation("DataPath does not support writing") |
0 commit comments