def ReadFile(filename, logger=None):
 try:
  with open(filename, 'rb') as fd:
   encoding = tokenize.detect_encoding(fd.readline)[0]
 except IOError as err:
  if logger:
   logger(err)
  raise
 try:
  with py3compat.open_with_encoding(filename, mode='r', encoding=encoding, newline='') as fd:
   lines = fd.readlines()
  line_ending = file_resources.LineEnding(lines)
  source = ('\n'.join((line.rstrip('\r\n') for line in lines)) + '\n')
  return (source, line_ending, encoding)
 except IOError as err:
  if logger:
   logger(err)
  raise

def ReadFile ( filename , logger = None ) : try : with open ( filename , 'rb' ) as fd : encoding = tokenize . detect_encoding ( fd . readline ) [ 0 ] except IOError as err : if logger : logger ( err ) raise try : with py3compat . open_with_encoding ( filename , mode = 'r' , encoding = encoding , newline = '' ) as fd : lines = fd . readlines ( ) line_ending = file_resources . LineEnding ( lines ) source = ( '\n' . join ( ( line . rstrip ( '\r\n' ) for line in lines ) ) + '\n' ) return ( source , line_ending , encoding ) except IOError as err : if logger : logger ( err ) raise
read the contents of the file .