blob: d91f08c4e871933bfb515cccb1902f261ead12fb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
#!/usr/bin/env python
import sys, os.path, optparse
sys.path.append(sys.path[0]+"/source")
import globals, expatimpl
def main ():
parser = optparse.OptionParser()
parser.set_defaults(output=None)
parser.add_option("-o", "--output", dest="output", help="write output to FILE", metavar="FILE")
options, args = parser.parse_args()
if len(args) == 0:
parser.print_help()
sys.exit(1)
fd = sys.stdout
if options.output != None:
if os.path.isdir(options.output):
globals.error("cannot create output file: " + optiont.output)
sys.exit(1)
fd = open(options.output, 'w')
filesParsed = 0
for fpath in args:
if not os.path.isfile(fpath):
globals.error(fpath + " is not a valid file. Skipping.")
continue
# globals.info("processing " + fpath)
file = open(fpath, 'r')
strm = file.read()
file.close()
p = expatimpl.Parser(strm)
p.parse()
p.printSummary(fd)
p.prettyPrint(fd)
filesParsed += 1
globals.info("%d files have been processed"%filesParsed)
if fd != sys.stdout:
fd.close()
if __name__ == '__main__':
main()
|