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 24 of file runregparse.py.

References merge_intervals().

Referenced by searchrun().

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

Definition at line 50 of file runregparse.py.

References hpstanc_transforms.max.

Referenced by invert_intervals(), and searchrun().

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

Definition at line 71 of file runregparse.py.

Referenced by searchrun().

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

Definition at line 65 of file runregparse.py.

Referenced by searchrun().

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

Definition at line 75 of file runregparse.py.

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

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