MCPcopy Index your code
hub / github.com/RustPython/RustPython / extractall

Method extractall

Lib/tarfile.py:2388–2455  ·  view source on GitHub ↗

Extract all members from the archive to the current working directory and set owner, modification time and permissions on directories afterwards. 'path' specifies a different directory to extract to. 'members' is optional and must be a subset of the list r

(self, path=".", members=None, *, numeric_owner=False,
                   filter=None)

Source from the content-addressed store, hash-verified

2386 raise ValueError(f"filter {filter!r} not found") from None
2387
2388 def extractall(self, path=".", members=None, *, numeric_owner=False,
2389 filter=None):
2390 """Extract all members from the archive to the current working
2391 directory and set owner, modification time and permissions on
2392 directories afterwards. 'path' specifies a different directory
2393 to extract to. 'members' is optional and must be a subset of the
2394 list returned by getmembers(). If 'numeric_owner' is True, only
2395 the numbers for user/group names are used and not the names.
2396
2397 The 'filter' function will be called on each member just
2398 before extraction.
2399 It can return a changed TarInfo or None to skip the member.
2400 String names of common filters are accepted.
2401 """
2402 directories = []
2403
2404 filter_function = self._get_filter_function(filter)
2405 if members is None:
2406 members = self
2407
2408 for member in members:
2409 tarinfo, unfiltered = self._get_extract_tarinfo(
2410 member, filter_function, path)
2411 if tarinfo is None:
2412 continue
2413 if tarinfo.isdir():
2414 # For directories, delay setting attributes until later,
2415 # since permissions can interfere with extraction and
2416 # extracting contents can reset mtime.
2417 directories.append(unfiltered)
2418 self._extract_one(tarinfo, path, set_attrs=not tarinfo.isdir(),
2419 numeric_owner=numeric_owner,
2420 filter_function=filter_function)
2421
2422 # Reverse sort directories.
2423 directories.sort(key=lambda a: a.name, reverse=True)
2424
2425
2426 # Set correct owner, mtime and filemode on directories.
2427 for unfiltered in directories:
2428 try:
2429 # Need to re-apply any filter, to take the *current* filesystem
2430 # state into account.
2431 try:
2432 tarinfo = filter_function(unfiltered, path)
2433 except _FILTER_ERRORS as exc:
2434 self._log_no_directory_fixup(unfiltered, repr(exc))
2435 continue
2436 if tarinfo is None:
2437 self._log_no_directory_fixup(unfiltered,
2438 'excluded by filter')
2439 continue
2440 dirpath = os.path.join(path, tarinfo.name)
2441 try:
2442 lstat = os.lstat(dirpath)
2443 except FileNotFoundError:
2444 self._log_no_directory_fixup(tarinfo, 'missing')
2445 continue

Callers 2

_unpack_tarfileFunction · 0.45
mainFunction · 0.45

Calls 14

_get_filter_functionMethod · 0.95
_get_extract_tarinfoMethod · 0.95
_extract_oneMethod · 0.95
chownMethod · 0.95
utimeMethod · 0.95
chmodMethod · 0.95
reprFunction · 0.85
lstatMethod · 0.80
isdirMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected