Example #1
0
def test_colored():
    assert colored('test', 'light cyan') == '\33[1;36mtest\x1b[0m'
    assert colored('täst', 'white') == '\33[37mtäst\x1b[0m'
    assert colored('täst', 'white', 'dark green') == '\x1b[37m\x1b[42mtäst\x1b[0m'
    assert colored('täst', 'light magenta', 'dark green', True) == '\x1b[1;35m\x1b[42mtäst\x1b[0m'
    assert colored('täst', 'light magenta', 'dark green', False) == '\x1b[95m\x1b[42mtäst\x1b[0m'
    assert colored('täst', 'light magenta', 'light green', True) == '\x1b[1;35m\x1b[42mtäst\x1b[0m'
    assert colored('täst', 'light magenta', 'light green', False) == '\x1b[95m\x1b[102mtäst\x1b[0m'
    assert colored('täst', '5', '20') == '\x1b[38;5;5m\x1b[48;5;20mtäst\x1b[0m'
    assert colored('täst', '#F0F', '#00AABB') == \
        '\x1b[38;2;255;0;255m\x1b[48;2;0;170;187mtäst\x1b[0m'
Example #2
0
def test_colored():
    assert colored('test', 'light cyan') == '\33[1;36mtest\x1b[0m'
    assert colored('täst', 'white') == '\33[37mtäst\x1b[0m'
    assert colored('täst', 'white', 'dark green') == '\x1b[37m\x1b[42mtäst\x1b[0m'
    assert colored('täst', 'light magenta', 'dark green', True) == '\x1b[1;35m\x1b[42mtäst\x1b[0m'
    assert colored('täst', 'light magenta', 'dark green', False) == '\x1b[95m\x1b[42mtäst\x1b[0m'
    assert colored('täst', 'light magenta', 'light green', True) == '\x1b[1;35m\x1b[42mtäst\x1b[0m'
    assert colored('täst', 'light magenta', 'light green', False) == '\x1b[95m\x1b[102mtäst\x1b[0m'
    assert colored('täst', '5', '20') == '\x1b[38;5;5m\x1b[48;5;20mtäst\x1b[0m'
    assert colored('täst', '#F0F', '#00AABB') == \
        '\x1b[38;2;255;0;255m\x1b[48;2;0;170;187mtäst\x1b[0m'
Example #3
0
def get_summary(collection, conf, locale, dates=None, firstweekday=0, days=None, events=None, width=45,
               week=False, full=False, show_all_days=False, bold_for_light_color=True,):
    """returns a list of events scheduled for all days in daylist

    included are header "rows"
    :param collection:
    :type collection: khalendar.CalendarCollection
    :param dates: a list of all dates for which the events should be return,
                    including what should be printed as a header
    :type collection: list(str)
    :param show_all_days: True if all days must be shown, event without event
    :type show_all_days: Boolean
    :returns: a list to be printed as the agenda for the given days
    :rtype: list(str)

    """
    from datetime import date, timedelta
    from click import style, echo

    event_column = list()

    if days is None:
        days = 2

    if dates is None or len(dates) == 0:
        dates = [date.today()]
    else:
        try:
            dates = [
                guessdatetimefstr([day], locale)[0].date()
                if not isinstance(day, date) else day
                for day in dates
            ]
        except InvalidDate as error:
            logging.fatal(error)
            sys.exit(1)

    if week:
        dates = [d - timedelta((d.weekday() - firstweekday) % 7)
                 for d in dates]
        days = 7

    if days is not None:
        daylist = [day + timedelta(days=one)
                   for one in range(days) for day in dates]
        daylist.sort()

    last_day = None
    for day in daylist:
        if last_day is None or day.month != last_day.month:
            event_column.append(style(day.strftime("%B"), bold=True))

        last_day = day
        events = sorted(collection.get_events_on(day))
        if is_holiday(day):
            prefix = style(day.strftime("%d*%a: "), bold=True)
        else:
            prefix = style(day.strftime("%d %a: "), bold=False)
        if not events:
            event_column.append(prefix)
            continue
        for event in events:
            lines = list()
            items = event.format(conf['view']['agenda_event_format'], day).splitlines()
            for item in items:
                lines += textwrap.wrap(item, width)
            lines = [colored(line, event.color, bold_for_light_color=bold_for_light_color) for line in lines]
            event_column.append(prefix + lines[0])
            prefix = " " * 8
            event_column += [prefix + line for line in lines[1:]]

    if event_column == []:
        event_column = [style('No events', bold=True)]
    return event_column
Example #4
0
def test_colored():
    assert colored('test', 'light cyan') == '\33[1;36mtest\x1b[0m'
    assert colored(u'täst', 'white') == u'\33[37mtäst\x1b[0m'
Example #5
0
def test_colored():
    assert colored('test', 'light cyan') == '\33[1;36mtest\x1b[0m'
    assert colored('täst', 'white') == '\33[37mtäst\x1b[0m'