Пример #1
0
    def get_time_not_schedulable(self, start, end, blackouts=True):
        """
        What is the set of time ([(start, end)]) in the given time window
        where this session is not schedulable?
        Here we consolidate all events so that we can use them to make
        calculations of the percentage of time available.
        """

        # WTF?
        if self.project is None:
            return []

        dts = set([])
        dts = dts.union(self.get_receiver_blackout_ranges(start, end))
        dts = dts.union(self.project.get_prescheduled_times(start, end))
        if blackouts:
            dts = dts.union(self.project.get_blackout_times(start, end))

        # the call to unions won't accept the None used
        # sometimes by get_receiver_blackout_range, so substitue in
        # the given boundries for these
        newDts = []
        for (s, e) in list(dts):
            if s is None:
                s = start
            if e is None:
                e = end
            newDts.append((s, e))

        return sorted(AnalogSet.unions(newDts))
Пример #2
0
 def compliment_events(self, events, start, end):
     """
     For a given set of datetime tuples of the form (start, end) which
     falls in the range of the given start, end, what is the
     complimentary set of events.  That is, what are the other events,
     togethor with the given events, which completely cover the given
     start, end range?
     """
     return AnalogSet.diffs([(start, end)], events)
Пример #3
0
    def isInWindow(self, period):
        "Does the given period overlap at all in window"
        return AnalogSet.overlaps((self.start_datetime(), self.end_datetime())
                                , (period.start, period.end()))

        return False