27 |
|
except IOError: |
28 |
|
sys.stderr.write("Cannot open " + f + "\n") |
29 |
|
|
30 |
< |
# TODO could a file contain more than one run? |
31 |
< |
runPat = re.compile(r'\s*\{([0-9]+):[ ]\[([0-9, ]+)\]\}') |
30 |
> |
runPat = re.compile('\s*<Run[ ]ID[=]"([0-9]+)">') |
31 |
> |
lumiPat = re.compile('\s*<LumiSection[ ]ID[=]"([0-9]+)"/>') |
32 |
|
|
33 |
|
inRunBlock = False |
34 |
|
|
35 |
|
lumilist = dict() |
36 |
|
|
37 |
+ |
run = 0 |
38 |
|
for line in lines: |
39 |
< |
if '<Runs>' in line: |
40 |
< |
inRunBlock = True |
41 |
< |
continue |
39 |
> |
runMatch = runPat.match(line) |
40 |
> |
if runMatch: |
41 |
> |
run = int(runMatch.group(1)) |
42 |
> |
if run not in lumilist: |
43 |
> |
lumilist[run] = list() |
44 |
|
|
42 |
– |
if '</Runs>' in line: |
43 |
– |
inRunBlock = False |
45 |
|
continue |
46 |
|
|
47 |
< |
if inRunBlock: |
48 |
< |
matches = runPat.match(line) |
49 |
< |
if not matches: |
47 |
> |
if run != 0: |
48 |
> |
if '</Run>' in line: |
49 |
> |
run = 0 |
50 |
|
continue |
51 |
+ |
|
52 |
+ |
lumiMatch = lumiPat.match(line) |
53 |
+ |
if lumiMatch: |
54 |
+ |
lumilist[run].append(int(lumiMatch.group(1))) |
55 |
|
|
51 |
– |
run = int(matches.group(1)) |
52 |
– |
if run not in lumilist: |
53 |
– |
lumilist[run] = list() |
54 |
– |
|
55 |
– |
lumis = re.findall('[0-9]+', matches.group(2)) |
56 |
– |
for lumi in lumis: |
57 |
– |
lumilist[run].append(int(lumi)) |
56 |
|
|
57 |
|
jsonTxt = "{" |
58 |
|
|