MCPcopy Index your code
hub / github.com/python/cpython / _find_link_target

Method _find_link_target

Lib/tarfile.py:2967–2984  ·  view source on GitHub ↗

Find the target member of a symlink or hardlink member in the archive.

(self, tarinfo)

Source from the content-addressed store, hash-verified

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.

Callers 2

extractfileMethod · 0.95
makelink_with_filterMethod · 0.95

Calls 5

_getmemberMethod · 0.95
issymMethod · 0.80
filterFunction · 0.70
joinMethod · 0.45
dirnameMethod · 0.45

Tested by

no test coverage detected