1 |
|
import re |
2 |
|
import sys |
3 |
+ |
from optparse import OptionParser |
4 |
|
|
5 |
+ |
parser = OptionParser() |
6 |
+ |
parser.add_option("-f", "--file", dest="filename", help="list of jfr files", metavar="FILE") |
7 |
+ |
|
8 |
+ |
(options, args) = parser.parse_args() |
9 |
+ |
|
10 |
+ |
filenames = [] |
11 |
|
lines = [] |
12 |
< |
for i in range(1, len(sys.argv)): |
13 |
< |
lines += file(sys.argv[i], "r").readlines() |
12 |
> |
|
13 |
> |
if options.filename: |
14 |
> |
filelist = file(options.filename, "r") |
15 |
> |
for f in filelist: |
16 |
> |
filenames.append(f.strip()) |
17 |
> |
|
18 |
> |
filelist.close() |
19 |
> |
else: |
20 |
> |
filenames = args |
21 |
> |
|
22 |
> |
for f in filenames: |
23 |
> |
try: |
24 |
> |
lines += file(f, "r").readlines() |
25 |
> |
except IOError: |
26 |
> |
sys.stderr.write("Cannot open " + f + "\n") |
27 |
|
|
28 |
|
# TODO could a file contain more than one run? |
29 |
|
runPat = re.compile(r'\s*\{([0-9]+):[ ]\[([0-9, ]+)\]\}') |