CMS 3D CMS Logo

Functions
runregparse Namespace Reference

Functions

def invert_intervals (intervals, min_val=1, max_val=9999)
 
def merge_intervals (intervals)
 
def remove_extra_spaces (data)
 
def remove_html_tags (data)
 
def searchrun (runno)
 

Function Documentation

def runregparse.invert_intervals (   intervals,
  min_val = 1,
  max_val = 9999 
)

Definition at line 25 of file runregparse.py.

References merge_intervals().

Referenced by searchrun().

25 def invert_intervals(intervals,min_val=1,max_val=9999):
26  # first order and merge in case
27  if not intervals:
28  return []
29  intervals=merge_intervals(intervals)
30  intervals = sorted(intervals, key = lambda x: x[0])
31  result = []
32  if min_val==-1:
33  # defin min and max
34  (a,b)=intervals[0]
35  min_val=a
36  if max_val==-1:
37  (a,b)=intervals[len(intervals)-1]
38  max_val=b
39 
40  curr_min=min_val
41  for (x,y) in intervals:
42  if x>curr_min:
43  result.append((curr_min,x-1))
44  curr_min=y+1
45  if curr_min<max_val:
46  result.append((curr_min,max_val))
47 
48 # print min_val,max_val
49  return result
50 
def invert_intervals(intervals, min_val=1, max_val=9999)
Definition: runregparse.py:25
def merge_intervals(intervals)
Definition: runregparse.py:51
def runregparse.merge_intervals (   intervals)

Definition at line 51 of file runregparse.py.

References SiStripPI.max.

Referenced by invert_intervals(), and searchrun().

51 def merge_intervals(intervals):
52  if not intervals:
53  return []
54  intervals = sorted(intervals, key = lambda x: x[0])
55  result = []
56  (a, b) = intervals[0]
57  for (x, y) in intervals[1:]:
58  if x <= b:
59  b = max(b, y)
60  else:
61  result.append((a, b))
62  (a, b) = (x, y)
63  result.append((a, b))
64  return result
65 
def merge_intervals(intervals)
Definition: runregparse.py:51
def runregparse.remove_extra_spaces (   data)

Definition at line 72 of file runregparse.py.

Referenced by searchrun().

73  result= re.sub(r'\s', '', data)
74  return result
75 
def remove_extra_spaces(data)
Definition: runregparse.py:72
def runregparse.remove_html_tags (   data)

Definition at line 66 of file runregparse.py.

Referenced by searchrun().

66 def remove_html_tags(data):
67  p = re.compile(r'<.*?>')
68  newdata=p.sub('', data)
69  newdata=newdata.replace("&nbsp;","")
70  return newdata
71 
def remove_html_tags(data)
Definition: runregparse.py:66
def runregparse.searchrun (   runno)

Definition at line 76 of file runregparse.py.

References objects.autophobj.float, createfilelist.int, invert_intervals(), join(), merge_intervals(), edm.print(), remove_extra_spaces(), remove_html_tags(), and str.

76 def searchrun(runno):
77  global QF_Req,ls_temp_data,QF_ALL_SYS,EXCEPTION,EXRUN
78  intervallist=[]
79  selectls=""
80 
81  for line in ls_temp_data.split("\n"):
82  if runno in line:
83 # print line
84  try:
85  if "%%%BAD LS INFO BEGIN%%%" in line:
86  selectls=line.split("%%%BAD LS INFO BEGIN%%%")[1]
87  selectls=selectls.split("%%%BAD LS INFO END%%%")[0]
88  selectls=remove_html_tags(selectls)
89  selectls=remove_extra_spaces(selectls)
90  # print selectls
91  for tag in QF_ALL_SYS:
92  selectls=selectls.replace(tag+":","\n"+tag+":")
93  # print selectls
94 
95  for line in selectls.split("\n"):
96  try:
97  tag=line.split(":")[0]
98  intervals=line.split(":")[1]
99  except:
100  continue
101  if tag in QF_Req.keys():
102  if QF_Req[tag]=="GOOD":
103  for interval in intervals.split(","):
104  if "ALL" in interval:
105  lmin=1
106  lmax=9999
107  else:
108  strmin=interval.split('-')[0]
109  strmax=interval.split('-')[1]
110  lmin=int(strmin)
111  if "END" in strmax:
112  lmax=9999
113  else:
114  lmax=int(strmax)
115  intervallist.append((lmin,lmax))
116  except:
117  EXCEPTION=True
118  EXRUN=int(runno)
119  intervallist=merge_intervals(intervallist)
120  # print runno, intervallist
121  return intervallist
122 
123 
124 
125 #main starts here#
126 
127 QF_Req={}
128 GOODRUN={}
def merge_intervals(intervals)
Definition: runregparse.py:51
def remove_extra_spaces(data)
Definition: runregparse.py:72
def remove_html_tags(data)
Definition: runregparse.py:66
def searchrun(runno)
Definition: runregparse.py:76