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

Method _proc_gnulong

Lib/tarfile.py:1416–1441  ·  view source on GitHub ↗

Process the blocks that hold a GNU longname or longlink member.

(self, tarfile)

Source from the content-addressed store, hash-verified

1414 return self
1415
1416 def _proc_gnulong(self, tarfile):
1417 """Process the blocks that hold a GNU longname
1418 or longlink member.
1419 """
1420 buf = tarfile.fileobj.read(self._block(self.size))
1421
1422 # Fetch the next header and process it.
1423 try:
1424 next = self._fromtarfile(tarfile, dircheck=False)
1425 except HeaderError as e:
1426 raise SubsequentHeaderError(str(e)) from None
1427
1428 # Patch the TarInfo object from the next header with
1429 # the longname information.
1430 next.offset = self.offset
1431 if self.type == GNUTYPE_LONGNAME:
1432 next.name = nts(buf, tarfile.encoding, tarfile.errors)
1433 elif self.type == GNUTYPE_LONGLINK:
1434 next.linkname = nts(buf, tarfile.encoding, tarfile.errors)
1435
1436 # Remove redundant slashes from directories. This is to be consistent
1437 # with frombuf().
1438 if next.isdir():
1439 next.name = next.name.removesuffix("/")
1440
1441 return next
1442
1443 def _proc_sparse(self, tarfile):
1444 """Process a GNU sparse header plus extra headers.

Callers 1

_proc_memberMethod · 0.95

Calls 8

_blockMethod · 0.95
_fromtarfileMethod · 0.95
strFunction · 0.85
ntsFunction · 0.85
readMethod · 0.45
isdirMethod · 0.45
removesuffixMethod · 0.45

Tested by

no test coverage detected