Open this entry as text or binary following the semantics of ``pathlib.Path.open()`` by passing arguments through to io.TextIOWrapper().
(self, mode='r', *args, pwd=None, **kwargs)
| 335 | return hash((self.root, self.at)) |
| 336 | |
| 337 | def open(self, mode='r', *args, pwd=None, **kwargs): |
| 338 | """ |
| 339 | Open this entry as text or binary following the semantics |
| 340 | of ``pathlib.Path.open()`` by passing arguments through |
| 341 | to io.TextIOWrapper(). |
| 342 | """ |
| 343 | if self.is_dir(): |
| 344 | raise IsADirectoryError(self) |
| 345 | zip_mode = mode[0] |
| 346 | if zip_mode == 'r' and not self.exists(): |
| 347 | raise FileNotFoundError(self) |
| 348 | stream = self.root.open(self.at, zip_mode, pwd=pwd) |
| 349 | if 'b' in mode: |
| 350 | if args or kwargs: |
| 351 | raise ValueError("encoding args invalid for binary operation") |
| 352 | return stream |
| 353 | # Text mode: |
| 354 | encoding, args, kwargs = _extract_text_encoding(*args, **kwargs) |
| 355 | return io.TextIOWrapper(stream, encoding, *args, **kwargs) |
| 356 | |
| 357 | def _base(self): |
| 358 | return pathlib.PurePosixPath(self.at) if self.at else self.filename |
no test coverage detected