def parse_options_header(value):
 def _tokenize(string):
  for match in _option_header_piece_re.finditer(string):
   (key, value) = match.groups()
   key = unquote_header_value(key)
   if (value is not None):
    value = unquote_header_value(value)
   (yield (key, value))
 if (not value):
  return ('', {})
 parts = _tokenize((';' + value))
 name = next(parts)[0]
 extra = dict(parts)
 return (name, extra)

def parse_options_header ( value ) : def _tokenize ( string ) : for match in _option_header_piece_re . finditer ( string ) : ( key , value ) = match . groups ( ) key = unquote_header_value ( key ) if ( value is not None ) : value = unquote_header_value ( value ) ( yield ( key , value ) ) if ( not value ) : return ( '' , { } ) parts = _tokenize ( ( ';' + value ) ) name = next ( parts ) [ 0 ] extra = dict ( parts ) return ( name , extra )
parse a content-type like header into a tuple with the content type and the options: .