ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/yiiyama/Toolset/scripts/fjr2json.py
(Generate patch)

Comparing UserCode/yiiyama/Toolset/scripts/fjr2json.py (file contents):
Revision 1.4 by yiiyama, Mon Oct 22 12:27:19 2012 UTC vs.
Revision 1.5 by yiiyama, Tue Oct 23 08:54:28 2012 UTC

# Line 27 | Line 27 | for f in filenames:
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  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines