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