@@ -394,9 +394,11 @@ if __name__ == '__main__':
394394 parser .add_option ('--title' , dest = 'title' ,
395395 help = 'The title of the project.' ,
396396 default = '[project name]' )
397- parser .add_option ('--file' , dest = 'file' ,
397+ parser .add_option ('--file' , dest = 'file' , action = "append" ,
398398 help = 'The cppcheck xml output file to read defects '
399- 'from. Default is reading from stdin.' )
399+ 'from. You can combine results from several '
400+ 'xml reports i.e. "--file file1.xml --file file2.xml ..". '
401+ 'Default is reading from stdin.' )
400402 parser .add_option ('--report-dir' , dest = 'report_dir' ,
401403 help = 'The directory where the HTML report content is '
402404 'written.' )
@@ -423,21 +425,15 @@ if __name__ == '__main__':
423425 if options .source_dir :
424426 source_dir = options .source_dir
425427
426- # Get the stream that we read cppcheck errors from.
427- input_file = sys .stdin
428- if options .file :
429- if not os .path .exists (options .file ):
430- parser .error ('cppcheck xml file: %s not found.' % options .file )
431- input_file = io .open (options .file , 'r' )
432- else :
433- parser .error ('No cppcheck xml file specified. (--file=)' )
434-
435- # Parse the xml file and produce a simple list of errors.
428+ # Parse the xml from all files defined in file argument
429+ # or from stdin. If no input is provided, stdin is used
430+ # Produce a simple list of errors.
436431 print ('Parsing xml report.' )
437432 try :
438433 contentHandler = CppCheckHandler ()
439- xml_parse (input_file , contentHandler )
440- except XmlParseException as msg :
434+ for fname in options .file or [sys .stdin ]:
435+ xml_parse (fname , contentHandler )
436+ except (XmlParseException , ValueError ) as msg :
441437 print ('Failed to parse cppcheck xml file: %s' % msg )
442438 sys .exit (1 )
443439
0 commit comments