def _parse_attrs(header):
 attributes = {}
 attrs = ''
 if ('; ' in header):
  (header, attrs) = 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_attrs ( header ) : attributes = { } attrs = '' if ( '; ' in header ) : ( header , attrs ) = 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 .