MCPcopy Create free account
hub / github.com/ActiveState/code / seek

Method seek

recipes/Python/173071_ReseekFile/recipe-173071.py:24–38  ·  view source on GitHub ↗

offset, whence = 0 Seek to a given byte position. Only supports whence == 0 and offset == the initial value of ReseekFile.tell() (which is usually 0, but not always.)

(self, offset, whence = 0)

Source from the content-addressed store, hash-verified

22 self._use_buffer = 1
23
24 def seek(self, offset, whence = 0):
25 """offset, whence = 0
26
27 Seek to a given byte position. Only supports whence == 0
28 and offset == the initial value of ReseekFile.tell() (which
29 is usually 0, but not always.)
30 """
31 if whence != 0:
32 raise TypeError("Unexpected whence value of %s; expecting 0" % \
33 (whence,))
34 if offset != self.beginning:
35 raise TypeError("Unexpected offset value of %r; expecting '%s'" % \
36 (offset, self.beginning))
37 self.buffer_file.seek(0)
38 self.at_beginning = 1
39
40 def tell(self):
41 """the current position of the file

Callers 6

mainFunction · 0.45
parseMethod · 0.45
recipe-157035.pyFile · 0.45
WritePagesMethod · 0.45
readlineMethod · 0.45
__init__Method · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected