def findMultipartPostBoundary(post):
 retVal = None
 done = set()
 candidates = []
 for match in re.finditer('(?m)^--(.+?)(--)?$', (post or '')):
  _ = match.group(1).strip().strip('-')
  if (_ in done):
   continue
  else:
   candidates.append((post.count(_), _))
   done.add(_)
 if candidates:
  candidates.sort(key=(lambda _: _[0]), reverse=True)
  retVal = candidates[0][1]
 return retVal

def findMultipartPostBoundary ( post ) : retVal = None done = set ( ) candidates = [ ] for match in re . finditer ( '(?m)^--(.+?)(--)?$' , ( post or '' ) ) : _ = match . group ( 1 ) . strip ( ) . strip ( '-' ) if ( _ in done ) : continue else : candidates . append ( ( post . count ( _ ) , _ ) ) done . add ( _ ) if candidates : candidates . sort ( key = ( lambda _ : _ [ 0 ] ) , reverse = True ) retVal = candidates [ 0 ] [ 1 ] return retVal
finds value for a boundary parameter in given multipart post body .