in mozregression/build_range.py [0:0]
def mid_point(self, interrupt=None):
"""
Return the mid point of the range.
To find the mid point, the higher and lower limits of the range are
accessed. Note that this method may resize the build range if some
builds are invalids (we were not able to load build_info for some
index)
if `interrupt` is given, it should be a callable that takes no
arguments and returns True when you want to stop looking for the
mid_point. In this case, StopIteration will be raised. This is provided
because this methods may take a long time to finish, and callers may
want to end it at some point.
"""
while True:
if interrupt and interrupt():
raise StopIteration
size = len(self)
if size < 3:
# let's say that the middle point is 0 if there is not at least
# 2 points - still, fetch data if needed.
self._fetch(list(range(size)))
self.filter_invalid_builds()
return 0
mid = int(size / 2)
self._fetch((0, mid, size - 1))
# remove invalids
self.filter_invalid_builds()
if len(self) == size:
# nothing removed, so we found valid builds only
return int(mid)