Esempio n. 1
0
 def _get_line_parts(start1, start2, end1, end2, run1, run2, fill_char):
     start_end = [end2, start2, start1, end1]
     result = []
     if run1 and (start2 or end2):
         result.append("├")
     elif run2 and (start1 or end1):
         result.append("┤")
     elif any(start_end):
         result.append(get_separator(*map(bool, start_end)))
     elif run1 or run2:
         result.append(UD)
     else:
         result.append(fill_char)
     return result
Esempio n. 2
0
    def _get_dt_line(
        self,
        dt,
        is_tick,
        starting_events,
        running_events,
        ending_events,
        rooms,
        col_width,
        cards_by_id,
    ):
        line_parts = [f"{dt:%H:%M} --" if is_tick else " " * 8]
        fill_char = "-" if is_tick else " "

        room = rooms[0]
        start, run, end = (
            starting_events[room],
            running_events[room],
            ending_events[room],
        )

        if start or end:
            line_parts.append(
                get_separator(bool(end), bool(start), False, False) +
                LR * col_width)
        elif run:
            line_parts.append(UD + next(cards_by_id[run.pk]))
        else:
            line_parts.append(fill_char * (col_width + 1))

        for loc1, loc2 in zip(rooms[:-1], rooms[1:]):
            start1, run1, end1 = (
                starting_events[loc1],
                running_events[loc1],
                ending_events[loc1],
            )
            start2, run2, end2 = (
                starting_events[loc2],
                running_events[loc2],
                ending_events[loc2],
            )
            line_parts += self._get_line_parts(start1,
                                               start2,
                                               end1,
                                               end2,
                                               run1,
                                               run2,
                                               fill_char=fill_char)
            if run2:
                line_parts.append(next(cards_by_id[run2.pk]))
            elif start2 or end2:
                line_parts.append(LR * col_width)
            else:
                line_parts.append(fill_char * col_width)

        room = rooms[-1]
        start, run, end = (
            starting_events[room],
            running_events[room],
            ending_events[room],
        )

        if start or end:
            line_parts.append(
                get_separator(False, False, bool(start), bool(end)))
        elif run:
            line_parts.append(UD)
        else:
            line_parts.append(fill_char)
        return "".join(line_parts)
Esempio n. 3
0
def test_get_separatro(args, expected):
    assert get_separator(*args) == expected