class_docstr: A readonly wrapper file object that add support for seeking, even if
  the wrapped file object does not. The allows us to stream from http and
  still use Pillow.
class_docstr_tok: ["A","readonly","wrapper","file","object","that","add","support","for","seeking",",","even","if","the","wrapped","file","object","does","not",".","The","allows","us","to","stream","from","http","and","still","use","Pillow","."]
code: def seek(self, i, mode=0):
      # Mimic BytesIO behavior
  
      # Get the absolute new position
      i = int(i)
      if mode == 0:
          if i < 0:
              raise ValueError("negative seek value " + str(i))
          real_i = i
      elif mode == 1:
          real_i = max(0, self._i + i)  # negative ok here
      elif mode == 2:
          if not self._have_all:
              self.read()
          real_i = max(0, len(self._buffer) + i)
      else:
          raise ValueError(
              "invalid whence (%s, should be 0, 1 or 2)" % i
          )
  
      # Read some?
      if real_i <= len(self._buffer):
          pass  # no need to read
      elif not self._have_all:
          assert (
              real_i > self._i
          )  # if we don't have all, _i cannot be > _buffer
          self.read(real_i - self._i)  # sets self._i
  
      self._i = real_i
      return self._i
  
imports: import os
  from io import BytesIO
  import zipfile
  import tempfile
  import shutil
  import enum
  import warnings
  from ..core import urlopen, get_remote_file
  from pathlib import Path
  from urllib.parse import urlparse
  from typing import Optional
label_desc: Use image node_id 4 for calling the SeekableFileObject obj's underlying member method code with example usage: obj.seek(i, mode) and returns: self