cppcheck-htmlreport: Support for multiple input files and fixed stdin… (#2822)
This commit is contained in:
parent
5b78c64420
commit
82047ea282
|
@ -394,9 +394,11 @@ if __name__ == '__main__':
|
||||||
parser.add_option('--title', dest='title',
|
parser.add_option('--title', dest='title',
|
||||||
help='The title of the project.',
|
help='The title of the project.',
|
||||||
default='[project name]')
|
default='[project name]')
|
||||||
parser.add_option('--file', dest='file',
|
parser.add_option('--file', dest='file', action="append",
|
||||||
help='The cppcheck xml output file to read defects '
|
help='The cppcheck xml output file to read defects '
|
||||||
'from. Default is reading from stdin.')
|
'from. You can combine results from several '
|
||||||
|
'xml reports i.e. "--file file1.xml --file file2.xml ..". '
|
||||||
|
'Default is reading from stdin.')
|
||||||
parser.add_option('--report-dir', dest='report_dir',
|
parser.add_option('--report-dir', dest='report_dir',
|
||||||
help='The directory where the HTML report content is '
|
help='The directory where the HTML report content is '
|
||||||
'written.')
|
'written.')
|
||||||
|
@ -423,21 +425,15 @@ if __name__ == '__main__':
|
||||||
if options.source_dir:
|
if options.source_dir:
|
||||||
source_dir = options.source_dir
|
source_dir = options.source_dir
|
||||||
|
|
||||||
# Get the stream that we read cppcheck errors from.
|
# Parse the xml from all files defined in file argument
|
||||||
input_file = sys.stdin
|
# or from stdin. If no input is provided, stdin is used
|
||||||
if options.file:
|
# Produce a simple list of errors.
|
||||||
if not os.path.exists(options.file):
|
|
||||||
parser.error('cppcheck xml file: %s not found.' % options.file)
|
|
||||||
input_file = io.open(options.file, 'r')
|
|
||||||
else:
|
|
||||||
parser.error('No cppcheck xml file specified. (--file=)')
|
|
||||||
|
|
||||||
# Parse the xml file and produce a simple list of errors.
|
|
||||||
print('Parsing xml report.')
|
print('Parsing xml report.')
|
||||||
try:
|
try:
|
||||||
contentHandler = CppCheckHandler()
|
contentHandler = CppCheckHandler()
|
||||||
xml_parse(input_file, contentHandler)
|
for fname in options.file or [sys.stdin]:
|
||||||
except XmlParseException as msg:
|
xml_parse(fname, contentHandler)
|
||||||
|
except (XmlParseException, ValueError) as msg:
|
||||||
print('Failed to parse cppcheck xml file: %s' % msg)
|
print('Failed to parse cppcheck xml file: %s' % msg)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue