def git_am_patch_split(f, encoding=None):
 encoding = (encoding or getattr(f, 'encoding', 'ascii'))
 contents = f.read()
 if ((type(contents) is bytes) and getattr(email.parser, 'BytesParser', None)):
  parser = email.parser.BytesParser()
  msg = parser.parsebytes(contents)
 else:
  parser = email.parser.Parser()
  msg = parser.parsestr(contents)
 return parse_patch_message(msg, encoding)

def git_am_patch_split ( f , encoding = None ) : encoding = ( encoding or getattr ( f , 'encoding' , 'ascii' ) ) contents = f . read ( ) if ( ( type ( contents ) is bytes ) and getattr ( email . parser , 'BytesParser' , None ) ) : parser = email . parser . BytesParser ( ) msg = parser . parsebytes ( contents ) else : parser = email . parser . Parser ( ) msg = parser . parsestr ( contents ) return parse_patch_message ( msg , encoding )
parse a git-am-style patch and split it up into bits .