• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2
3import plistlib
4
5def main():
6    from optparse import OptionParser, OptionGroup
7    parser = OptionParser("""\
8usage: %prog [options] <path>
9
10Utility for dumping Clang-style logged diagnostics.\
11""")
12    (opts, args) = parser.parse_args()
13
14    if len(args) != 1:
15        parser.error("invalid number of arguments")
16
17    path, = args
18
19    # Read the diagnostics log.
20    f = open(path)
21    try:
22        data = f.read()
23    finally:
24        f.close()
25
26    # Complete the plist (the log itself is just the chunks).
27    data = """\
28<?xml version="1.0" encoding="UTF-8"?>
29<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" \
30                       "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
31<plist version="1.0">
32<array>
33%s
34</array>
35</plist>""" % data
36
37    # Load the diagnostics.
38    diags = plistlib.readPlistFromString(data)
39
40    # Print out the diagnostics.
41    print
42    print "**** BUILD DIAGNOSTICS ****"
43    for i, file_diags in enumerate(diags):
44        file = file_diags.get('main-file')
45        print "*** %s ***" % file
46        for d in file_diags.get('diagnostics', ()):
47            print "%s:%s:%s: %s: %s" % (
48                d.get('filename'), d.get('line'), d.get('column'),
49                d.get('level'), d.get('message'))
50
51if __name__ == "__main__":
52    main()
53