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

Method _proc_sparse

Lib/tarfile.py:1443–1469  ·  view source on GitHub ↗

Process a GNU sparse header plus extra headers.

(self, tarfile)

Source from the content-addressed store, hash-verified

1441 return next
1442
1443 def _proc_sparse(self, tarfile):
1444 """Process a GNU sparse header plus extra headers.
1445 """
1446 # We already collected some sparse structures in frombuf().
1447 structs, isextended, origsize = self._sparse_structs
1448 del self._sparse_structs
1449
1450 # Collect sparse structures from extended header blocks.
1451 while isextended:
1452 buf = tarfile.fileobj.read(BLOCKSIZE)
1453 pos = 0
1454 for i in range(21):
1455 try:
1456 offset = nti(buf[pos:pos + 12])
1457 numbytes = nti(buf[pos + 12:pos + 24])
1458 except ValueError:
1459 break
1460 if offset and numbytes:
1461 structs.append((offset, numbytes))
1462 pos += 24
1463 isextended = bool(buf[504])
1464 self.sparse = structs
1465
1466 self.offset_data = tarfile.fileobj.tell()
1467 tarfile.offset = self.offset_data + self._block(self.size)
1468 self.size = origsize
1469 return self
1470
1471 def _proc_pax(self, tarfile):
1472 """Process an extended or global header as described in

Callers 1

_proc_memberMethod · 0.95

Calls 5

_blockMethod · 0.95
ntiFunction · 0.85
readMethod · 0.45
appendMethod · 0.45
tellMethod · 0.45

Tested by

no test coverage detected