#NEWLINE# def write_table_in_format( template_format , outfile , template_values , show_table ) : #NEWLINE# #INDENT# Template = ( tempita . HTMLTemplate if ( template_format == 'html' ) else tempita . Template ) #NEWLINE# template_file = TEMPLATE_FILE_NAME . format ( format = template_format ) #NEWLINE# try : #NEWLINE# #INDENT# template_content = __loader__ . get_data ( template_file ) . decode ( TEMPLATE_ENCODING ) #NEWLINE# #UNINDENT# except NameError : #NEWLINE# #INDENT# with open ( template_file , mode = 'r' ) as f : #NEWLINE# #INDENT# template_content = f . read ( ) #NEWLINE# #UNINDENT# #UNINDENT# template = Template ( template_content , namespace = TEMPLATE_NAMESPACE ) #NEWLINE# result = template . substitute ( ** template_values ) #NEWLINE# if ( not outfile ) : #NEWLINE# #INDENT# print ( result , end = '' ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# with open ( outfile , 'w' ) as file : #NEWLINE# #INDENT# file . write ( result ) #NEWLINE# #UNINDENT# if show_table : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# with open ( os . devnull , 'w' ) as devnull : #NEWLINE# #INDENT# subprocess . Popen ( [ 'xdg-open' , outfile ] , stdout = devnull , stderr = devnull ) #NEWLINE# #UNINDENT# #UNINDENT# except OSError : #NEWLINE# #INDENT# pass