#NEWLINE# def read_content_file( dirpath ) : #NEWLINE# #INDENT# '(str): (str, email.Message)\n    Given a directory path, figure out the file holding the content\n    for that directory and parse it as an email message.\n\n    Copied from old Python.org build process.\n    ' #NEWLINE# c_ht = os . path . join ( dirpath , 'content.ht' ) #NEWLINE# c_rst = os . path . join ( dirpath , 'content.rst' ) #NEWLINE# if os . path . exists ( c_ht ) : #NEWLINE# #INDENT# raw_input = open ( c_ht , 'rb' ) . read ( ) #NEWLINE# detection = chardet . detect ( raw_input ) #NEWLINE# input = open ( c_ht , 'r' , encoding = detection [ 'encoding' ] , errors = 'ignore' ) #NEWLINE# msg = email . message_from_file ( input ) #NEWLINE# filename = rst_msg #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if os . path . exists ( c_rst ) : #NEWLINE# #INDENT# rst_text = open ( c_rst , 'r' ) . read ( ) #NEWLINE# rst_msg = ( 'Content-type: text/x-rst\n\n%s' % rst_text . lstrip ( ) ) #NEWLINE# msg = email . message_from_string ( rst_msg ) #NEWLINE# filename = c_rst #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( None , None ) #NEWLINE# #UNINDENT# #UNINDENT# return ( filename , msg )