3 from .sugar
import IOVSet, TimestampType, define_iov_type
4 from collections
import defaultdict
15 gen = (
RUNIOV_VAL(lb.since, lb.until)
for lb
in lblb)
22 Assumes `iovs` ordered by channel, then by since.
24 empty_iovset_maker = iovs.empty_maker()
25 result = defaultdict(
lambda: empty_iovset_maker())
28 if iov.channel != last_channel:
29 last_channel = iov.channel
30 appender = result[last_channel].append
36 def from_LBLB_VAL(lblb):
37 return LBTIME_VAL(TimestampType(lblb.StartTime),
38 TimestampType(lblb.EndTime),
39 lblb.since.run, lblb.since.lumi)
41 LBTIME_VAL.from_LBLB_VAL = from_LBLB_VAL
43 lbtime_iovs = IOVSet(LBTIME_VAL.from_LBLB_VAL(iov)
for iov
in iovs)
45 if sorted(lbtime_iovs) != lbtime_iovs:
46 raise RuntimeError(
"lblb records are broken")
52 Consider a single result `iov`, and connect it to existing result iovs
53 before it if necessary
55 Also performs translation of channel names to channel IDs.
57 last_iov = output_iovs[-1]
if output_iovs
else None
59 if last_iov
and last_iov.connected_to(iov):
61 output_iovs[-1] = last_iov._replace(until=iov.until)
64 output_iovs.append(iov)
69 if previous
and previous.connected_to(iov):
70 previous = previous._replace(until=iov.until)
81 Input/Output: list of iovs
83 If an iov specifies an iterable for its channel, then expand it into
86 from six
import string_types
89 if not isinstance(iov.channel, string_types)
and hasattr(iov.channel,
"__iter__"):
91 result.append(iov._replace(channel=c))