11def statusCutsToRange(dbconn,foldername,since,until,tag,statusreq):
12 """Return a RangeList giving the good IOV range corresponding to the
13 specified set of daetector status cuts, using the given DB and folder"""
14 range=RangeList(since,until)
15 reqs=DetStatusReq()
16 reqs.setFromString(statusreq)
17 folder=dbconn.getFolder(foldername)
18 # loop over all requested status cuts
19 for (ichan,req) in reqs.getDict().items():
20 itr=folder.browseObjects(since,until,cool.ChannelSelection(ichan),tag)
21 lastiov=since
22 while itr.goToNext():
23 obj=itr.currentRef()
24 status=obj.payload()['Code']
25 if (lastiov<obj.since()):
26 # veto gaps where no status data was provided - assume bad
27 range.vetoRange(lastiov,obj.since())
28 if (status<req):
29 range.vetoRange(obj.since(),obj.until())
30 lastiov=obj.until()
31 # veto final gap (if any)
32 range.vetoRange(lastiov,until)
33 itr.close()
34 return range
35