def _get_report_contents(filename, last_line_only=False):
 file_not_found_message = 'The following log file could not be found: {file}'.format(file=filename)
 if os.path.isfile(filename):
  with open(filename, 'r') as report_file:
   if last_line_only:
    lines = report_file.readlines()
    for line in reversed(lines):
     if (line != '\n'):
      return line
   else:
    return report_file.read()
 else:
  raise BuildFailure(file_not_found_message)

def _get_report_contents ( filename , last_line_only = False ) : file_not_found_message = 'The following log file could not be found: {file}' . format ( file = filename ) if os . path . isfile ( filename ) : with open ( filename , 'r' ) as report_file : if last_line_only : lines = report_file . readlines ( ) for line in reversed ( lines ) : if ( line != '\n' ) : return line else : return report_file . read ( ) else : raise BuildFailure ( file_not_found_message )
returns the contents of the given file .