MCPcopy
hub / github.com/aws/aws-cli / seek

Method seek

awscli/s3transfer/utils.py:542–564  ·  view source on GitHub ↗
(self, where, whence=0)

Source from the content-addressed store, hash-verified

540 self._callbacks_enabled = False
541
542 def seek(self, where, whence=0):
543 if whence not in (0, 1, 2):
544 # Mimic io's error for invalid whence values
545 raise ValueError(f"invalid whence ({whence}, should be 0, 1 or 2)")
546
547 # Recalculate where based on chunk attributes so seek from file
548 # start (whence=0) is always used
549 where += self._start_byte
550 if whence == 1:
551 where += self._amount_read
552 elif whence == 2:
553 where += self._size
554
555 self._fileobj.seek(max(where, self._start_byte))
556 if self._callbacks is not None and self._callbacks_enabled:
557 # To also rewind the callback() for an accurate progress report
558 bounded_where = max(min(where - self._start_byte, self._size), 0)
559 bounded_amount_read = min(self._amount_read, self._size)
560 amount = bounded_where - bounded_amount_read
561 invoke_progress_callbacks(
562 self._callbacks, bytes_transferred=amount
563 )
564 self._amount_read = max(where - self._start_byte, 0)
565
566 def close(self):
567 if self._close_callbacks is not None and self._callbacks_enabled:

Callers 9

_open_if_neededMethod · 0.45
seekMethod · 0.45
from_filenameMethod · 0.45
_mainMethod · 0.45
seekableFunction · 0.45
file_checksumMethod · 0.45
_bundle_sizeMethod · 0.45

Calls 1

Tested by

no test coverage detected