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)
| 2599 | return None |
| 2600 | |
| 2601 | def _extract_member(self, tarinfo, targetpath, set_attrs=True, |
| 2602 | numeric_owner=False, *, filter_function=None, |
| 2603 | extraction_root=None): |
| 2604 | """Extract the filtered TarInfo object tarinfo to a physical |
| 2605 | file called targetpath. |
| 2606 | |
| 2607 | filter_function is only used when extracting a *different* |
| 2608 | member (e.g. as fallback to creating a symlink) |
| 2609 | """ |
| 2610 | # Fetch the TarInfo object for the given name |
| 2611 | # and build the destination pathname, replacing |
| 2612 | # forward slashes to platform specific separators. |
| 2613 | targetpath = targetpath.rstrip("/") |
| 2614 | targetpath = targetpath.replace("/", os.sep) |
| 2615 | |
| 2616 | # Create all upper directories. |
| 2617 | upperdirs = os.path.dirname(targetpath) |
| 2618 | if upperdirs and not os.path.exists(upperdirs): |
| 2619 | # Create directories that are not part of the archive with |
| 2620 | # default permissions. |
| 2621 | os.makedirs(upperdirs, exist_ok=True) |
| 2622 | |
| 2623 | if tarinfo.islnk() or tarinfo.issym(): |
| 2624 | self._dbg(1, "%s -> %s" % (tarinfo.name, tarinfo.linkname)) |
| 2625 | else: |
| 2626 | self._dbg(1, tarinfo.name) |
| 2627 | |
| 2628 | if tarinfo.isreg(): |
| 2629 | self.makefile(tarinfo, targetpath) |
| 2630 | elif tarinfo.isdir(): |
| 2631 | self.makedir(tarinfo, targetpath) |
| 2632 | elif tarinfo.isfifo(): |
| 2633 | self.makefifo(tarinfo, targetpath) |
| 2634 | elif tarinfo.ischr() or tarinfo.isblk(): |
| 2635 | self.makedev(tarinfo, targetpath) |
| 2636 | elif tarinfo.islnk() or tarinfo.issym(): |
| 2637 | self.makelink_with_filter( |
| 2638 | tarinfo, targetpath, |
| 2639 | filter_function=filter_function, |
| 2640 | extraction_root=extraction_root) |
| 2641 | elif tarinfo.type not in SUPPORTED_TYPES: |
| 2642 | self.makeunknown(tarinfo, targetpath) |
| 2643 | else: |
| 2644 | self.makefile(tarinfo, targetpath) |
| 2645 | |
| 2646 | if set_attrs: |
| 2647 | self.chown(tarinfo, targetpath, numeric_owner) |
| 2648 | if not tarinfo.issym(): |
| 2649 | self.chmod(tarinfo, targetpath) |
| 2650 | self.utime(tarinfo, targetpath) |
| 2651 | |
| 2652 | #-------------------------------------------------------------------------- |
| 2653 | # Below are the different file methods. They are called via |