#NEWLINE# def parse_output( output ) : #NEWLINE# #INDENT# "Return a list of Result from the supplied 'output'.\n\n    :output: string of the output from cppcheck\n    :returns: list of Result\n\n    " #NEWLINE# results = [ ] #NEWLINE# root = xml . etree . ElementTree . fromstring ( output ) #NEWLINE# error_list = root . find ( 'errors' ) #NEWLINE# if ( error_list is not None ) : #NEWLINE# #INDENT# for error in error_list . iterfind ( 'error' ) : #NEWLINE# #INDENT# path = None #NEWLINE# line_numbers = [ ] #NEWLINE# message = error . get ( 'verbose' ) #NEWLINE# severity = error . get ( 'severity' ) #NEWLINE# identity = error . get ( 'id' ) #NEWLINE# for line in error . iterfind ( 'location' ) : #NEWLINE# #INDENT# path = line . get ( 'file' ) #NEWLINE# line_numbers . append ( int ( line . get ( 'line' ) ) ) #NEWLINE# #UNINDENT# if ( message is None ) : #NEWLINE# #INDENT# raise Error ( 'could not find message: {}' . format ( error . items ( ) ) ) #NEWLINE# #UNINDENT# if ( severity is None ) : #NEWLINE# #INDENT# raise Error ( 'could not find severity: {}' . format ( error . items ( ) ) ) #NEWLINE# #UNINDENT# if ( identity is None ) : #NEWLINE# #INDENT# raise Error ( 'could not find identity: {}' . format ( error . items ( ) ) ) #NEWLINE# #UNINDENT# if ( path is None ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# results . append ( Result ( severity , line_numbers , path , line_numbers , message ) ) #NEWLINE# #UNINDENT# #UNINDENT# return results