#NEWLINE# def parse_file( self , file_path ) : #NEWLINE# #INDENT# ' Parse vim script file and return the AST. ' #NEWLINE# with file_path . open ( mode = 'rb' ) as f : #NEWLINE# #INDENT# bytes_seq = f . read ( ) #NEWLINE# is_empty = ( len ( bytes_seq ) == 0 ) #NEWLINE# if is_empty : #NEWLINE# #INDENT# return self . parse ( '' ) #NEWLINE# #UNINDENT# encoding_hint = chardet . detect ( bytes_seq ) #NEWLINE# encoding = encoding_hint [ 'encoding' ] #NEWLINE# if ( not encoding ) : #NEWLINE# #INDENT# raise EncodingDetectionError ( file_path ) #NEWLINE# #UNINDENT# decoded = bytes_seq . decode ( encoding ) #NEWLINE# decoded_and_lf_normalized = decoded . replace ( '\r\n' , '\n' ) #NEWLINE# return self . parse ( decoded_and_lf_normalized )