parameters: (self, file_path)
docstring: Loads file_path into the in-memory resource map.
docstring_summary: Loads file_path into the in-memory resource map.
docstring_tokens: Loads file_path into the in - memory resource map .
function: def AddFileToResourceMap(self, file_path):
      """Loads file_path into the in-memory resource map."""
      file_path = os.path.realpath(file_path)
      if file_path in self.resource_map:
        return
  
      with open(file_path, 'rb') as fd:
        response = fd.read()
        fs = os.fstat(fd.fileno())
      content_type = mimetypes.guess_type(file_path)[0]
      zipped = False
      if content_type in ['text/html', 'text/css', 'application/javascript']:
        zipped = True
        sio = StringIO.StringIO()
        gzf = gzip.GzipFile(fileobj=sio, compresslevel=9, mode='wb')
        gzf.write(response)
        gzf.close()
        response = sio.getvalue()
        sio.close()
      self.resource_map[file_path] = {
          'content-type': content_type,
          'content-length': len(response),
          'last-modified': fs.st_mtime,
          'response': response,
          'zipped': zipped
      }
  
      index = 'index.html'
      if os.path.basename(file_path) == index:
        dir_path = os.path.dirname(file_path)
        self.resource_map[dir_path] = self.resource_map[file_path]
function_tokens: def AddFileToResourceMap ( self , file_path ) : file_path = os . path . realpath ( file_path ) if file_path in self . resource_map : return with open ( file_path , 'rb' ) as fd : response = fd . read ( ) fs = os . fstat ( fd . fileno ( ) ) content_type = mimetypes . guess_type ( file_path ) [ 0 ] zipped = False if content_type in [ 'text/html' , 'text/css' , 'application/javascript' ] : zipped = True sio = StringIO . StringIO ( ) gzf = gzip . GzipFile ( fileobj = sio , compresslevel = 9 , mode = 'wb' ) gzf . write ( response ) gzf . close ( ) response = sio . getvalue ( ) sio . close ( ) self . resource_map [ file_path ] = { 'content-type' : content_type , 'content-length' : len ( response ) , 'last-modified' : fs . st_mtime , 'response' : response , 'zipped' : zipped } index = 'index.html' if os . path . basename ( file_path ) == index : dir_path = os . path . dirname ( file_path ) self . resource_map [ dir_path ] = self . resource_map [ file_path ]