code: def guess_mimetype (filename, read=None):
      
      mime, encoding = None, None
      if mimedb:
          mime, encoding = mimedb.guess_type(filename, strict=False)
      basename = os.path.basename(filename)
      # Special case for Safari Bookmark files
      if not mime and basename == 'Bookmarks.plist':
          return 'application/x-plist+safari'
      # Special case for Google Chrome Bookmark files.
      if not mime and basename == 'Bookmarks':
          mime = 'text/plain'
      # Some mime types can be differentiated further with content reading.
      if mime in ("text/plain", "application/xml", "text/xml") and read is not None:
          read_mime = guess_mimetype_read(read)
          if read_mime is not None:
              mime = read_mime
      if not mime:
          mime = "application/octet-stream"
      elif ";" in mime:
          # split off not needed extension info
          mime = mime.split(';')[0]
      return mime.strip().lower()
docs: Return MIME type of file, or 'application/octet-stream' if it could
      not be determined.