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

Method _extract_member

Lib/tarfile.py:2582–2631  ·  view source on GitHub ↗

Extract the filtered TarInfo object tarinfo to a physical file called targetpath. filter_function is only used when extracting a *different* member (e.g. as fallback to creating a symlink)

(self, tarinfo, targetpath, set_attrs=True,
                        numeric_owner=False, *, filter_function=None,
                        extraction_root=None)

Source from the content-addressed store, hash-verified

2580 return None
2581
2582 def _extract_member(self, tarinfo, targetpath, set_attrs=True,
2583 numeric_owner=False, *, filter_function=None,
2584 extraction_root=None):
2585 """Extract the filtered TarInfo object tarinfo to a physical
2586 file called targetpath.
2587
2588 filter_function is only used when extracting a *different*
2589 member (e.g. as fallback to creating a symlink)
2590 """
2591 # Fetch the TarInfo object for the given name
2592 # and build the destination pathname, replacing
2593 # forward slashes to platform specific separators.
2594 targetpath = targetpath.rstrip("/")
2595 targetpath = targetpath.replace("/", os.sep)
2596
2597 # Create all upper directories.
2598 upperdirs = os.path.dirname(targetpath)
2599 if upperdirs and not os.path.exists(upperdirs):
2600 # Create directories that are not part of the archive with
2601 # default permissions.
2602 os.makedirs(upperdirs, exist_ok=True)
2603
2604 if tarinfo.islnk() or tarinfo.issym():
2605 self._dbg(1, "%s -> %s" % (tarinfo.name, tarinfo.linkname))
2606 else:
2607 self._dbg(1, tarinfo.name)
2608
2609 if tarinfo.isreg():
2610 self.makefile(tarinfo, targetpath)
2611 elif tarinfo.isdir():
2612 self.makedir(tarinfo, targetpath)
2613 elif tarinfo.isfifo():
2614 self.makefifo(tarinfo, targetpath)
2615 elif tarinfo.ischr() or tarinfo.isblk():
2616 self.makedev(tarinfo, targetpath)
2617 elif tarinfo.islnk() or tarinfo.issym():
2618 self.makelink_with_filter(
2619 tarinfo, targetpath,
2620 filter_function=filter_function,
2621 extraction_root=extraction_root)
2622 elif tarinfo.type not in SUPPORTED_TYPES:
2623 self.makeunknown(tarinfo, targetpath)
2624 else:
2625 self.makefile(tarinfo, targetpath)
2626
2627 if set_attrs:
2628 self.chown(tarinfo, targetpath, numeric_owner)
2629 if not tarinfo.issym():
2630 self.chmod(tarinfo, targetpath)
2631 self.utime(tarinfo, targetpath)
2632
2633 #--------------------------------------------------------------------------
2634 # Below are the different file methods. They are called via

Callers 2

_extract_oneMethod · 0.95
makelink_with_filterMethod · 0.95

Calls 15

_dbgMethod · 0.95
makefileMethod · 0.95
makedirMethod · 0.95
makefifoMethod · 0.95
makedevMethod · 0.95
makelink_with_filterMethod · 0.95
makeunknownMethod · 0.95
chownMethod · 0.95
chmodMethod · 0.95
utimeMethod · 0.95
islnkMethod · 0.80
issymMethod · 0.80

Tested by

no test coverage detected