MCPcopy Index your code
hub / github.com/RustPython/RustPython / seek

Method seek

Lib/tarfile.py:520–531  ·  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

518 return self.pos
519
520 def seek(self, pos=0):
521 """Set the stream's file pointer to pos. Negative seeking
522 is forbidden.
523 """
524 if pos - self.pos >= 0:
525 blocks, remainder = divmod(pos - self.pos, self.bufsize)
526 for i in range(blocks):
527 self.read(self.bufsize)
528 self.read(remainder)
529 else:
530 raise StreamError("seeking backwards is not allowed")
531 return self.pos
532
533 def read(self, size):
534 """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 3

readMethod · 0.95
StreamErrorClass · 0.85
divmodFunction · 0.50

Tested by

no test coverage detected