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

Method seek

Lib/tarfile.py:518–529  ·  view source on GitHub ↗

Set the stream's file pointer to pos. Negative seeking is forbidden.

(self, pos=0)

Source from the content-addressed store, hash-verified

516 return self.pos
517
518 def seek(self, pos=0):
519 """Set the stream's file pointer to pos. Negative seeking
520 is forbidden.
521 """
522 if pos - self.pos >= 0:
523 blocks, remainder = divmod(pos - self.pos, self.bufsize)
524 for i in range(blocks):
525 self.read(self.bufsize)
526 self.read(remainder)
527 else:
528 raise StreamError("seeking backwards is not allowed")
529 return self.pos
530
531 def read(self, size):
532 """Return the next size number of bytes from the stream."""

Callers 6

readMethod · 0.45
__init__Method · 0.45
openMethod · 0.45
makefileMethod · 0.45
nextMethod · 0.45
is_tarfileFunction · 0.45

Calls 2

readMethod · 0.95
StreamErrorClass · 0.85

Tested by

no test coverage detected