Find the target member of a symlink or hardlink member in the archive.
(self, tarinfo)
| 2965 | raise OSError("bad operation for mode %r" % self.mode) |
| 2966 | |
| 2967 | def _find_link_target(self, tarinfo): |
| 2968 | """Find the target member of a symlink or hardlink member in the |
| 2969 | archive. |
| 2970 | """ |
| 2971 | if tarinfo.issym(): |
| 2972 | # Always search the entire archive. |
| 2973 | linkname = "/".join(filter(None, (os.path.dirname(tarinfo.name), tarinfo.linkname))) |
| 2974 | limit = None |
| 2975 | else: |
| 2976 | # Search the archive before the link, because a hard link is |
| 2977 | # just a reference to an already archived file. |
| 2978 | linkname = tarinfo.linkname |
| 2979 | limit = tarinfo |
| 2980 | |
| 2981 | member = self._getmember(linkname, tarinfo=limit, normalize=True) |
| 2982 | if member is None: |
| 2983 | raise KeyError("linkname %r not found" % linkname) |
| 2984 | return member |
| 2985 | |
| 2986 | def __iter__(self): |
| 2987 | """Provide an iterator object. |
no test coverage detected