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)
| 2421 | self.at = at |
| 2422 | |
| 2423 | def open(self, mode='r', *args, pwd=None, **kwargs): |
| 2424 | """ |
| 2425 | Open this entry as text or binary following the semantics |
| 2426 | of ``pathlib.Path.open()`` by passing arguments through |
| 2427 | to io.TextIOWrapper(). |
| 2428 | """ |
| 2429 | if self.is_dir(): |
| 2430 | raise IsADirectoryError(self) |
| 2431 | zip_mode = mode[0] |
| 2432 | if not self.exists() and zip_mode == 'r': |
| 2433 | raise FileNotFoundError(self) |
| 2434 | stream = self.root.open(self.at, zip_mode, pwd=pwd) |
| 2435 | if 'b' in mode: |
| 2436 | if args or kwargs: |
| 2437 | raise ValueError("encoding args invalid for binary operation") |
| 2438 | return stream |
| 2439 | # Text mode: |
| 2440 | encoding, args, kwargs = _extract_text_encoding(*args, **kwargs) |
| 2441 | return io.TextIOWrapper(stream, encoding, *args, **kwargs) |
| 2442 | |
| 2443 | def _base(self): |
| 2444 | return pathlib.PurePosixPath(self.at or self.root.filename) |
no test coverage detected