Find the target member of a symlink or hardlink member in the archive.
(self, tarinfo)
| 2940 | raise OSError("bad operation for mode %r" % self.mode) |
| 2941 | |
| 2942 | def _find_link_target(self, tarinfo): |
| 2943 | """Find the target member of a symlink or hardlink member in the |
| 2944 | archive. |
| 2945 | """ |
| 2946 | if tarinfo.issym(): |
| 2947 | # Always search the entire archive. |
| 2948 | linkname = "/".join(filter(None, (os.path.dirname(tarinfo.name), tarinfo.linkname))) |
| 2949 | limit = None |
| 2950 | else: |
| 2951 | # Search the archive before the link, because a hard link is |
| 2952 | # just a reference to an already archived file. |
| 2953 | linkname = tarinfo.linkname |
| 2954 | limit = tarinfo |
| 2955 | |
| 2956 | member = self._getmember(linkname, tarinfo=limit, normalize=True) |
| 2957 | if member is None: |
| 2958 | raise KeyError("linkname %r not found" % linkname) |
| 2959 | return member |
| 2960 | |
| 2961 | def __iter__(self): |
| 2962 | """Provide an iterator object. |
no test coverage detected