class_docstr: ImageResource handling utility.
  
  Represents a request for reading or saving an image resource. This
  object wraps information to that request and acts as an interface
  for the plugins to several resources; it allows the user to read
  from filenames, files, http, zipfiles, raw bytes, etc., but offer
  a simple interface to the plugins via ``get_file()`` and
  ``get_local_filename()``.
  
  For each read/write operation a single Request instance is used and passed
  to the can_read/can_write method of a format, and subsequently to
  the Reader/Writer class. This allows rudimentary passing of
  information between different formats and between a format and
  associated reader/writer.
  
  Parameters
  ----------
  uri : {str, bytes, file}
      The resource to load the image from.
  mode : str
      The first character is "r" or "w", indicating a read or write
      request. The second character is used to indicate the kind of data:
      "i" for an image, "I" for multiple images, "v" for a volume,
      "V" for multiple volumes, "?" for don't care.
class_docstr_tok: ["ImageResource","handling","utility",".","Represents","a","request","for","reading","or","saving","an","image","resource",".","This","object","wraps","information","to","that","request","and","acts","as","an","interface","for","the","plugins","to","several","resources",";","it","allows","the","user","to","read","from","filenames",",","files",",","http",",","zipfiles",",","raw","bytes",",","etc.",",","but","offer","a","simple","interface","to","the","plugins","via","``","get_file","(",")","``","and","``","get_local_filename","(",")","``",".","For","each","read\/write","operation","a","single","Request","instance","is","used","and","passed","to","the","can_read\/can_write","method","of","a","format",",","and","subsequently","to","the","Reader\/Writer","class",".","This","allows","rudimentary","passing","of","information","between","different","formats","and","between","a","format","and","associated","reader\/writer",".","Parameters","--","--","--","--","--","uri",":","{","str",",","bytes",",","file","}","The","resource","to","load","the","image","from",".","mode",":","str","The","first","character","is","``","r","''","or","``","w","''",",","indicating","a","read","or","write","request",".","The","second","character","is","used","to","indicate","the","kind","of","data",":","``","i","''","for","an","image",",","``","I","''","for","multiple","images",",","``","v","''","for","a","volume",",","``","V","''","for","multiple","volumes",",","``","?","''","for","do","n't","care","."]
docstr: get_file()
  Get a file object for the resource associated with this request.
  If this is a reading request, the file is in read mode,
  otherwise in write mode. This method is not thread safe. Plugins
  should not close the file when done.
  
  This is the preferred way to read/write the data. But if a
  format cannot handle file-like objects, they should use
  ``get_local_filename()``.
docstr_tok: ["get_file","(",")","Get","a","file","object","for","the","resource","associated","with","this","request",".","If","this","is","a","reading","request",",","the","file","is","in","read","mode",",","otherwise","in","write","mode",".","This","method","is","not","thread","safe",".","Plugins","should","not","close","the","file","when","done",".","This","is","the","preferred","way","to","read\/write","the","data",".","But","if","a","format","can","not","handle","file-like","objects",",","they","should","use","``","get_local_filename","(",")","``","."]
code: def get_file(self):
      """get_file()
      Get a file object for the resource associated with this request.
      If this is a reading request, the file is in read mode,
      otherwise in write mode. This method is not thread safe. Plugins
      should not close the file when done.
  
      This is the preferred way to read/write the data. But if a
      format cannot handle file-like objects, they should use
      ``get_local_filename()``.
      """
      want_to_write = self.mode.io_mode is IOMode.write
  
      # Is there already a file?
      # Either _uri_type == URI_FILE, or we already opened the file,
      # e.g. by using firstbytes
      if self._file is not None:
          return self._file
  
      if self._uri_type == URI_BYTES:
          if want_to_write:
              # Create new file object, we catch the bytes in finish()
              self._file = BytesIO()
              self._file_is_local = True
          else:
              self._file = BytesIO(self._bytes)
  
      elif self._uri_type == URI_FILENAME:
          if want_to_write:
              self._file = open(self.filename, "wb")
          else:
              self._file = open(self.filename, "rb")
  
      elif self._uri_type == URI_ZIPPED:
          # Get the correct filename
          filename, name = self._filename_zip
          if want_to_write:
              # Create new file object, we catch the bytes in finish()
              self._file = BytesIO()
              self._file_is_local = True
          else:
              # Open zipfile and open new file object for specific file
              self._zipfile = zipfile.ZipFile(filename, "r")
              self._file = self._zipfile.open(name, "r")
              self._file = SeekableFileObject(self._file)
  
      elif self._uri_type in [URI_HTTP or URI_FTP]:
          assert (
              not want_to_write
          )  # This should have been tested in init
          timeout = os.getenv("IMAGEIO_REQUEST_TIMEOUT")
          if timeout is None or not timeout.isdigit():
              timeout = 5
          self._file = urlopen(self.filename, timeout=float(timeout))
          self._file = SeekableFileObject(self._file)
  
      return self._file
  
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 9 for calling the Request obj's underlying member method code with example usage: obj.get_file() and returns: self, self