Find the target member of a symlink or hardlink member in the archive.
(self, tarinfo)
| 2705 | raise OSError("bad operation for mode %r" % self.mode) |
| 2706 | |
| 2707 | def _find_link_target(self, tarinfo): |
| 2708 | """Find the target member of a symlink or hardlink member in the |
| 2709 | archive. |
| 2710 | """ |
| 2711 | if tarinfo.issym(): |
| 2712 | # Always search the entire archive. |
| 2713 | linkname = "/".join(filter(None, (os.path.dirname(tarinfo.name), tarinfo.linkname))) |
| 2714 | limit = None |
| 2715 | else: |
| 2716 | # Search the archive before the link, because a hard link is |
| 2717 | # just a reference to an already archived file. |
| 2718 | linkname = tarinfo.linkname |
| 2719 | limit = tarinfo |
| 2720 | |
| 2721 | member = self._getmember(linkname, tarinfo=limit, normalize=True) |
| 2722 | if member is None: |
| 2723 | raise KeyError("linkname %r not found" % linkname) |
| 2724 | return member |
| 2725 | |
| 2726 | def __iter__(self): |
| 2727 | """Provide an iterator object. |
no test coverage detected