def cutoff(interval, slot):
    if not slot or not interval:
        raise ValueError('@cutoff_slot: wrong parameters')
    if slot[0] > slot[1]:
        raise ValueError('@cutoff_slot: slot[0] > slot[1]')
    if interval[0] > interval[1]:
        raise ValueError('@cutoff_slot: interval[0] > interval[1]')

    # backup copy for cutting off and not ruining the original outter objects
    interval_w = (
        interval[0] + py_timedelta(days=0), interval[1] + py_timedelta(days=0)
    )
    slot_w = (
        slot[0] + py_timedelta(days=0), slot[1] + py_timedelta(days=0)
    )

    # CASE A: discard, too late
    if slot_w[1] <= interval_w[0]:
        raise ValueError('@cutoff_slot: slot[1] <= interval[0]')
    # CASE E: discard, too early
    if slot_w[0] >= interval_w[1]:
        raise ValueError('@cutoff_slot: slot[0] >= interval[1]')

    if slot_w[0] >= interval_w[0]:
        # CASE C: no cutoff is necessary
        if slot_w[1] <= interval_w[1]:
            return slot_w
        else:
            # CASE D: cutting off the ending time of the slot
            return slot_w[0], interval_w[1]

    # CASE B: cutting off slot's starting time
    return interval_w[0], slot_w[1]
Get all the smartstack namespaces listed for a given service name.
dataset/ETHPy150Open satnet-project/server/services/common/slots.py/cutoff--crossover with--dataset/ETHPy150Open Yelp/paasta/paasta_tools/marathon_tools.py/get_all_namespaces_for_service