code: def parseAcceptHeader(value):
      
      chunks = [chunk.strip() for chunk in value.split(',')]
      accept = []
      for chunk in chunks:
          parts = [s.strip() for s in chunk.split(';')]
  
          mtype = parts.pop(0)
          if '/' not in mtype:
              # This is not a MIME type, so ignore the bad data
              continue
  
          main, sub = mtype.split('/', 1)
  
          for ext in parts:
              if '=' in ext:
                  k, v = ext.split('=', 1)
                  if k == 'q':
                      try:
                          q = float(v)
                          break
                      except ValueError:
                          # Ignore poorly formed q-values
                          pass
          else:
              q = 1.0
  
          accept.append((q, main, sub))
  
      accept.sort()
      accept.reverse()
      return [(main, sub, q) for (q, main, sub) in accept]
docs: Parse an accept header, ignoring any accept-extensions
  
      returns a list of tuples containing main MIME type, MIME subtype,
      and quality markdown.
  
      str -> [(str, str, float)]