def getBlackedOutSchedulableTime(self, start, end): """ Of the hours in the given range that are schedulable, how many have been blacked out? Returns tuple of hours (scheduble but ignoring blackouts , scheduable but blacked out) Returns tuple of (scheduable but ignoring blackouts total , scheduable but blacked out total , [2-tuple of scheduable-but-ignoring-blackouts range)] , [[2-tuple of scheduable-but-blacked-out-range]]) """ nss1 = self.get_time_not_schedulable(start, end, blackouts=False) nss = self.trim_events(nss1, start, end) # now convert the non-schedulable time ranges to the # time that IS schedulable: schedulable = self.compliment_events(nss, start, end) # how much time is that? hrsSchedulable = sum([TimeAgent.timedelta2minutes(s[1] - s[0]) / 60.0 for s in schedulable]) # now, for each chunk of schedulable time, how much is # blacked out? hrsBlackedOut = 0.0 bss = [] # print "schedulable loop:" for s in schedulable: bs = self.project.get_blackout_times(s[0], s[1]) # but these blackout times might not match to the schedulable # end points, so we may need to truncate them bs = self.trim_events(bs, s[0], s[1]) if len(bs) != 0: bss.append(bs) bsTime = sum([TimeAgent.timedelta2minutes(b[1] - b[0]) / 60.0 for b in bs]) hrsBlackedOut += bsTime # return a summary of what we've found return (hrsSchedulable, hrsBlackedOut, schedulable, bss)