MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / open

Method open

tools/python-3.11.9-amd64/Lib/zipfile.py:2423–2441  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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)

Callers 3

read_textMethod · 0.95
read_bytesMethod · 0.95
__init__Method · 0.45

Calls 3

is_dirMethod · 0.95
existsMethod · 0.95
_extract_text_encodingFunction · 0.85

Tested by

no test coverage detected