def parse_content_disposition(header):
 attributes = {}
 attrs = ''
 if (';' in header):
  (header, attrs) = [x.strip() for x in header.split(';', 1)]
 m = True
 while m:
  m = ATTRIBUTES_RE.match(attrs)
  if m:
   attrs = attrs[len(m.group(0)):]
   attributes[m.group(1)] = m.group(2).strip('"')
 return (header, attributes)

def parse_content_disposition ( header ) : attributes = { } attrs = '' if ( ';' in header ) : ( header , attrs ) = [ x . strip ( ) for x in header . split ( ';' , 1 ) ] m = True while m : m = ATTRIBUTES_RE . match ( attrs ) if m : attrs = attrs [ len ( m . group ( 0 ) ) : ] attributes [ m . group ( 1 ) ] = m . group ( 2 ) . strip ( '"' ) return ( header , attributes )
given the value of a header like: content-disposition: form-data; name="somefile"; filename="test .