Пример #1
0
def test_vertical_month():
    try:
        locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
        vert_str = vertical_month(month=12, year=2011,
                                  today=datetime.date(2011, 12, 12))
        assert vert_str == example1

        weno_str = vertical_month(month=12, year=2011,
                                  today=datetime.date(2011, 12, 12),
                                  weeknumber='right')
        assert weno_str == example_weno

        we_start_su_str = vertical_month(
            month=12, year=2011,
            today=datetime.date(2011, 12, 12),
            firstweekday=6)
        assert we_start_su_str == example_we_start_su
    except locale.Error as error:
        if str(error) == 'unsupported locale setting':
            pytest.xfail(
                'To get this test to run, you need to add `en_US.utf-8` to '
                'your locales. On Debian GNU/Linux 8 you do this by '
                'uncommenting `de_DE.utf-8 in /etc/locale.gen and then run '
                '`locale-gen` (as root).'
            )
    finally:
        locale.setlocale(locale.LC_ALL, 'C')
Пример #2
0
def test_vertical_month():
    try:
        locale.setlocale(locale.LC_ALL, 'en_US.UTF-8')
        vert_str = vertical_month(month=12, year=2011,
                                  today=dt.date(2011, 12, 12))
        assert vert_str == example1

        vert_str = vertical_month(month=12, year=2011,
                                  today=dt.date(2011, 12, 12),
                                  monthdisplay='firstfullweek')
        assert vert_str == example2

        weno_str = vertical_month(month=12, year=2011,
                                  today=dt.date(2011, 12, 12),
                                  weeknumber='right')
        assert weno_str == example_weno

        we_start_su_str = vertical_month(
            month=12, year=2011,
            today=dt.date(2011, 12, 12),
            firstweekday=6)
        assert we_start_su_str == example_we_start_su
    except locale.Error as error:
        if str(error) == 'unsupported locale setting':
            pytest.xfail(
                'To get this test to run, you need to add `en_US.utf-8` to '
                'your locales. On Debian GNU/Linux 8 you do this by '
                'uncommenting `de_DE.utf-8 in /etc/locale.gen and then run '
                '`locale-gen` (as root).'
            )
    finally:
        locale.setlocale(locale.LC_ALL, 'C')
Пример #3
0
def test_vertical_month():
    vert_str = vertical_month(month=12, year=2011,
                              today=datetime.date(2011, 12, 12))
    assert vert_str == example1

    weno_str = vertical_month(month=12, year=2011,
                              today=datetime.date(2011, 12, 12),
                              weeknumber=True)
    assert weno_str == example_weno

    we_start_su_str = vertical_month(
        month=12, year=2011,
        today=datetime.date(2011, 12, 12),
        firstweekday=6)
    assert we_start_su_str == example_we_start_su
Пример #4
0
    def __init__(self, collection, firstweekday=0, encoding='utf-8'):
        today = datetime.date.today()
        tomorrow = today + datetime.timedelta(days=1)
        daylist = [(today, 'Today:'), (tomorrow, 'Tomorrow:')]
        event_column = list()

        for day, dayname in daylist:
            # TODO unify allday and datetime events
            start = datetime.datetime.combine(day, datetime.time.min)
            end = datetime.datetime.combine(day, datetime.time.max)

            event_column.append(bstring(dayname))

            all_day_events = collection.get_allday_by_time_range(day)
            events = collection.get_datetime_by_time_range(start, end)

            for event in all_day_events:
                event_column.append(aux.colored(event.compact(day), event.color))
            events.sort(key=lambda e: e.start)
            for event in events:
                event_column.append(aux.colored(event.compact(day), event.color))

        calendar_column = calendar_display.vertical_month(
            firstweekday=firstweekday)

        # if the event column is longer than the calendar_column: increase
        # length of the former
        missing = len(event_column) - len(calendar_column)
        if missing > 0:
            calendar_column = calendar_column + missing * [25 * ' ']

        rows = ['     '.join(one) for one in izip_longest(calendar_column, event_column, fillvalue='')]
        print('\n'.join(rows).encode(encoding))
Пример #5
0
def calendar(collection, date=None, firstweekday=0, encoding='utf-8', locale=None,
             weeknumber=False, show_all_days=False, conf=None,
             hmethod='fg',
             default_color='',
             multiple='',
             color='',
             highlight_event_days=0,
             full=False,
             bold_for_light_color=True,
             **kwargs):
    if date is None:
        date = [datetime.datetime.today()]

    term_width, _ = get_terminal_size()
    lwidth = 25
    rwidth = term_width - lwidth - 4
    event_column = get_agenda(
        collection, locale, dates=date, width=rwidth,
        show_all_days=show_all_days, full=full, bold_for_light_color=bold_for_light_color,
        **kwargs)
    calendar_column = calendar_display.vertical_month(
        firstweekday=firstweekday, weeknumber=weeknumber,
        collection=collection,
        hmethod=hmethod,
        default_color=default_color,
        multiple=multiple,
        color=color,
        highlight_event_days=highlight_event_days,
        locale=locale,
        bold_for_light_color=bold_for_light_color)
    rows = merge_columns(calendar_column, event_column)
    # XXX: Generate this as a unicode in the first place, rather than
    # casting it.
    echo('\n'.join(rows).encode(encoding))
Пример #6
0
def calendar(collection, dates=None, firstweekday=0, locale=None,
             weeknumber=False, show_all_days=False, conf=None,
             hmethod='fg',
             default_color='',
             multiple='',
             color='',
             highlight_event_days=0,
             week=False,
             full=False,
             bold_for_light_color=True,
             **kwargs):
    if dates is None:
        dates = [datetime.today()]

    term_width, _ = get_terminal_size()
    lwidth = 25
    rwidth = term_width - lwidth - 4
    event_column = get_agenda(
        collection, locale, dates=dates, width=rwidth,
        show_all_days=show_all_days, week=week, full=full,
        bold_for_light_color=bold_for_light_color, **kwargs)
    calendar_column = calendar_display.vertical_month(
        firstweekday=firstweekday, weeknumber=weeknumber,
        collection=collection,
        hmethod=hmethod,
        default_color=default_color,
        multiple=multiple,
        color=color,
        highlight_event_days=highlight_event_days,
        locale=locale,
        bold_for_light_color=bold_for_light_color)
    rows = merge_columns(calendar_column, event_column)
    echo('\n'.join(rows))
Пример #7
0
def test_vertical_month():
    locale.setlocale(locale.LC_ALL, 'en_US.utf-8')
    vert_str = vertical_month(month=12, year=2011,
                              today=datetime.date(2011, 12, 12))
    assert vert_str == example1

    weno_str = vertical_month(month=12, year=2011,
                              today=datetime.date(2011, 12, 12),
                              weeknumber='right')
    assert weno_str == example_weno

    we_start_su_str = vertical_month(
        month=12, year=2011,
        today=datetime.date(2011, 12, 12),
        firstweekday=6)
    assert we_start_su_str == example_we_start_su
Пример #8
0
def test_vertical_month_unicode_weekdeays_gr():
    try:
        locale.setlocale(locale.LC_ALL, 'el_GR.UTF-8')
        vert_str = vertical_month(month=12,
                                  year=2011,
                                  today=dt.date(2011, 12, 12))
        # on some OSes, Greek locale's abbreviated day of the week and
        # month names have accents, on some they haven't
        if platform.system() == 'Darwin':
            assert strip_accents('\n'.join([line.lower() for line in vert_str])) == \
                '\n'.join(example_gr_darwin)
        else:
            assert strip_accents('\n'.join([line.lower() for line in vert_str])) == \
                '\n'.join(example_gr)
        '\n'.join(vert_str)  # issue 142/293
    except locale.Error as error:
        if str(error) == 'unsupported locale setting':
            pytest.xfail(
                'To get this test to run, you need to add `el_GR.UTF-8` to '
                'your locales. On Debian GNU/Linux 8 you do this by '
                'uncommenting `el_GR.UTF-8` in /etc/locale.gen and then run '
                '`locale-gen` (as root).')
        else:
            raise
    finally:
        locale.setlocale(locale.LC_ALL, 'C')
Пример #9
0
def test_vertical_month_unicode():
    try:
        locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
        vert_str = vertical_month(month=12, year=2011,
                                  today=dt.date(2011, 12, 12))
        # de_DE locale on at least Net and FreeBSD is different from the one
        # commonly used on linux systems
        if platform.system() == 'FreeBSD':
            assert vert_str == example_de_freebsd
        elif platform.system() == 'NetBSD':
            assert vert_str == example_de_netbsd
        else:
            assert vert_str == example_de

        '\n'.join(vert_str)  # issue 142
    except locale.Error as error:
        if str(error) == 'unsupported locale setting':
            pytest.xfail(
                'To get this test to run, you need to add `de_DE.utf-8` to '
                'your locales. On Debian GNU/Linux 8 you do this by '
                'uncommenting `de_DE.utf-8 in /etc/locale.gen and then run '
                '`locale-gen` (as root).'
            )
        else:
            raise
    finally:
        locale.setlocale(locale.LC_ALL, 'C')
Пример #10
0
def test_vertical_month_unicode():
    try:
        locale.setlocale(locale.LC_ALL, 'de_DE.UTF-8')
        vert_str = vertical_month(month=12, year=2011,
                                  today=dt.date(2011, 12, 12))
        # de_DE locale on at least Net and FreeBSD is different from the one
        # commonly used on linux systems
        if platform.system() == 'FreeBSD':
            assert vert_str == example_de_freebsd
        elif platform.system() == 'NetBSD':
            assert vert_str == example_de_netbsd
        else:
            assert vert_str == example_de

        '\n'.join(vert_str)  # issue 142
    except locale.Error as error:
        if str(error) == 'unsupported locale setting':
            pytest.xfail(
                'To get this test to run, you need to add `de_DE.utf-8` to '
                'your locales. On Debian GNU/Linux 8 you do this by '
                'uncommenting `de_DE.utf-8 in /etc/locale.gen and then run '
                '`locale-gen` (as root).'
            )
        else:
            raise
    finally:
        locale.setlocale(locale.LC_ALL, 'C')
Пример #11
0
    def __init__(self, collection, firstweekday=0, encoding='utf-8'):
        today = datetime.date.today()
        tomorrow = today + datetime.timedelta(days=1)
        daylist = [(today, 'Today:'), (tomorrow, 'Tomorrow:')]
        event_column = list()

        for day, dayname in daylist:
            # TODO unify allday and datetime events
            start = datetime.datetime.combine(day, datetime.time.min)
            end = datetime.datetime.combine(day, datetime.time.max)

            event_column.append(bstring(dayname))

            all_day_events = collection.get_allday_by_time_range(day)
            events = collection.get_datetime_by_time_range(start, end)

            for event in all_day_events:
                event_column.append(aux.colored(event.compact(day), event.color))
            events.sort(key=lambda e: e.start)
            for event in events:
                event_column.append(aux.colored(event.compact(day), event.color))

        calendar_column = calendar_display.vertical_month(
            firstweekday=firstweekday)

        # if the event column is longer than the calendar_column: increase
        # length of the former
        missing = len(event_column) - len(calendar_column)
        if missing > 0:
            calendar_column = calendar_column + missing * [25 * ' ']

        rows = ['     '.join(one) for one in izip_longest(calendar_column, event_column, fillvalue='')]
        print('\n'.join(rows).encode(encoding))
Пример #12
0
def calendar(collection, date=None, firstweekday=0, encoding='utf-8', locale=None,
             weeknumber=False, show_all_days=False, conf=None,
             hmethod='fg',
             default_color='',
             multiple='',
             color='',
             highlight_event_days=0,
             **kwargs):
    if date is None:
        date = [datetime.datetime.today()]

    term_width, _ = get_terminal_size()
    lwidth = 25
    rwidth = term_width - lwidth - 4
    event_column = get_agenda(
        collection, locale, dates=date, width=rwidth, show_all_days=show_all_days,
        **kwargs)
    calendar_column = calendar_display.vertical_month(
        firstweekday=firstweekday, weeknumber=weeknumber,
        collection=collection,
        hmethod=hmethod,
        default_color=default_color,
        multiple=multiple,
        color=color,
        highlight_event_days=highlight_event_days,
        locale=locale)
    rows = merge_columns(calendar_column, event_column)
    # XXX: Generate this as a unicode in the first place, rather than
    # casting it.
    echo('\n'.join(rows).encode(encoding))
Пример #13
0
    def __init__(self, collection, firstweekday=0, encoding='utf-8'):
        today = datetime.date.today()
        tomorrow = today + datetime.timedelta(days=1)
        daylist = [(today, 'Today:'), (tomorrow, 'Tomorrow:')]
        event_column = list()

        term_width, _ = get_terminal_size()
        lwidth = 25
        rwidth = term_width - lwidth - 4

        for day, dayname in daylist:
            # TODO unify allday and datetime events
            start = datetime.datetime.combine(day, datetime.time.min)
            end = datetime.datetime.combine(day, datetime.time.max)

            event_column.append(bstring(dayname))

            all_day_events = collection.get_allday_by_time_range(day)
            events = collection.get_datetime_by_time_range(start, end)
            for event in all_day_events:
                desc = textwrap.wrap(event.compact(day), rwidth)
                event_column.extend([colored(d, event.color) for d in desc])

            events.sort(key=lambda e: e.start)
            for event in events:
                desc = textwrap.wrap(event.compact(day), rwidth)
                event_column.extend([colored(d, event.color) for d in desc])

        calendar_column = calendar_display.vertical_month(
            firstweekday=firstweekday)

        rows = merge_columns(calendar_column, event_column)
        print('\n'.join(rows).encode(encoding))
Пример #14
0
def test_vertical_month():
    vert_str = vertical_month(month=12,
                              year=2011,
                              today=datetime.date(2011, 12, 12))
    assert vert_str == example1

    weno_str = vertical_month(month=12,
                              year=2011,
                              today=datetime.date(2011, 12, 12),
                              weeknumber=True)
    assert weno_str == example_weno

    we_start_su_str = vertical_month(month=12,
                                     year=2011,
                                     today=datetime.date(2011, 12, 12),
                                     firstweekday=6)
    assert we_start_su_str == example_we_start_su
Пример #15
0
def test_vertical_month():
    locale.setlocale(locale.LC_ALL, 'en_US.utf-8')
    vert_str = vertical_month(month=12,
                              year=2011,
                              today=datetime.date(2011, 12, 12))
    assert vert_str == example1

    weno_str = vertical_month(month=12,
                              year=2011,
                              today=datetime.date(2011, 12, 12),
                              weeknumber='right')
    assert weno_str == example_weno

    we_start_su_str = vertical_month(month=12,
                                     year=2011,
                                     today=datetime.date(2011, 12, 12),
                                     firstweekday=6)
    assert we_start_su_str == example_we_start_su
Пример #16
0
    def __init__(self, collection, date=[], firstweekday=0, encoding="utf-8", **kwargs):
        term_width, _ = get_terminal_size()
        lwidth = 25
        rwidth = term_width - lwidth - 4
        event_column = get_agenda(collection, dates=date, width=rwidth, **kwargs)
        calendar_column = calendar_display.vertical_month(firstweekday=firstweekday)

        rows = merge_columns(calendar_column, event_column)
        print("\n".join(rows).encode(encoding))
Пример #17
0
def calendar(collection, agenda_format=None, notstarted=False, once=False, daterange=None,
             day_format=None,
             locale=None,
             conf=None,
             firstweekday=0,
             weeknumber=False,
             monthdisplay='firstday',
             hmethod='fg',
             default_color='',
             multiple='',
             color='',
             highlight_event_days=0,
             full=False,
             bold_for_light_color=True,
             env=None,
             ):
    term_width, _ = get_terminal_size()
    lwidth = 27 if conf['locale']['weeknumbers'] == 'right' else 25
    rwidth = term_width - lwidth - 4

    try:
        start, end = start_end_from_daterange(
            daterange, locale,
            default_timedelta_date=conf['default']['timedelta'],
            default_timedelta_datetime=conf['default']['timedelta'],
        )
    except ValueError as error:
        raise FatalError(error)

    event_column = khal_list(
        collection,
        daterange,
        conf=conf,
        agenda_format=agenda_format,
        day_format=day_format,
        once=once,
        notstarted=notstarted,
        width=rwidth,
        env=env,
    )
    calendar_column = calendar_display.vertical_month(
        month=start.month,
        year=start.year,
        count=max(3, (end.year - start.year) * 12 + end.month - start.month + 1),
        firstweekday=firstweekday, weeknumber=weeknumber,
        monthdisplay=monthdisplay,
        collection=collection,
        hmethod=hmethod,
        default_color=default_color,
        multiple=multiple,
        color=color,
        highlight_event_days=highlight_event_days,
        locale=locale,
        bold_for_light_color=bold_for_light_color)
    return merge_columns(calendar_column, event_column, width=lwidth)
Пример #18
0
    def __init__(self, collection, date=[], firstweekday=0, encoding='utf-8',
                 **kwargs):
        term_width, _ = get_terminal_size()
        lwidth = 25
        rwidth = term_width - lwidth - 4
        event_column = get_agenda(collection, dates=date, width=rwidth,
                                  **kwargs)
        calendar_column = calendar_display.vertical_month(
            firstweekday=firstweekday)

        rows = merge_columns(calendar_column, event_column)
        echo('\n'.join(rows).encode(encoding))
Пример #19
0
    def __init__(self, collection, firstweekday=0, encoding='utf-8'):

        term_width, _ = get_terminal_size()
        lwidth = 25
        rwidth = term_width - lwidth - 4
        event_column = get_agenda(collection, rwidth)

        calendar_column = calendar_display.vertical_month(
            firstweekday=firstweekday)

        rows = merge_columns(calendar_column, event_column)
        print('\n'.join(rows).encode(encoding))
Пример #20
0
def calendar(collection, format=None, notstarted=False, once=False, daterange=None,
             day_format=None,
             locale=None,
             conf=None,
             firstweekday=0,
             weeknumber=False,
             hmethod='fg',
             default_color='',
             multiple='',
             color='',
             highlight_event_days=0,
             full=False,
             bold_for_light_color=True,
             **kwargs):
    td = None
    show_all_days = False
    if conf is not None:
        if format is None:
            format = conf['view']['agenda_event_format']
        if day_format is None:
            day_format = conf['view']['agenda_day_format']
        td = conf['default']['timedelta']
        show_all_days = conf['default']['show_all_days']

    term_width, _ = get_terminal_size()
    lwidth = 25
    rwidth = term_width - lwidth - 4
    start, end = start_end_from_daterange(daterange, locale, td)
    event_column = get_list_from_str(collection, format=format,
                                     day_format=day_format,
                                     start=start,
                                     end=end,
                                     locale=locale,
                                     once=once, notstarted=notstarted,
                                     default_timedelta=td, width=rwidth,
                                     show_all_days=show_all_days,
                                     **kwargs)
    calendar_column = calendar_display.vertical_month(
        month=start.month,
        year=start.year,
        count=max(3, (end.year - start.year) * 12 + end.month - start.month + 1),
        firstweekday=firstweekday, weeknumber=weeknumber,
        collection=collection,
        hmethod=hmethod,
        default_color=default_color,
        multiple=multiple,
        color=color,
        highlight_event_days=highlight_event_days,
        locale=locale,
        bold_for_light_color=bold_for_light_color)
    rows = merge_columns(calendar_column, event_column)
    echo('\n'.join(rows))
Пример #21
0
    def __init__(self, collection, date=[], firstweekday=0, encoding='utf-8',
                 weeknumber=False, show_all_days=False, **kwargs):
        term_width, _ = get_terminal_size()
        lwidth = 25
        rwidth = term_width - lwidth - 4
        event_column = get_agenda(
            collection, dates=date, width=rwidth, show_all_days=show_all_days,
            **kwargs)
        calendar_column = calendar_display.vertical_month(
            firstweekday=firstweekday, weeknumber=weeknumber)

        rows = merge_columns(calendar_column, event_column)
        # XXX: Generate this as a unicode in the first place, rather than
        # casting it.
        echo('\n'.join(rows).encode(encoding))
Пример #22
0
    def __init__(self, conf):
        super(Display, self).__init__(conf)
        today = datetime.date.today()
        tomorrow = today + datetime.timedelta(days=1)
        daylist = [(today, 'Today:'), (tomorrow, 'Tomorrow:')]
        event_column = list()
        for day, dayname in daylist:
            # TODO unify allday and datetime events
            start = datetime.datetime.combine(day, datetime.time.min)
            end = datetime.datetime.combine(day, datetime.time.max)

            event_column.append(bstring(dayname))
            all_day_events = list()
            events = list()
            for account in conf.sync.accounts:
                readonly = conf.accounts[account]['readonly']
                color = conf.accounts[account]['color']
                all_day_events += self.dbtool.get_allday_range(
                    day,
                    account_name=account,
                    color=color,
                    readonly=readonly,
                    unicode_symbols=conf.default.unicode_symbols,
                    show_deleted=False)
                events += self.dbtool.get_time_range(
                    start,
                    end,
                    account,
                    color=color,
                    readonly=readonly,
                    unicode_symbols=conf.default.unicode_symbols,
                    show_deleted=False)
            for event in all_day_events:
                event_column.append(aux.colored(event.compact(day), event.color))
            events.sort(key=lambda e: e.start)
            for event in events:
                event_column.append(aux.colored(event.compact(day), event.color))

        calendar_column = calendar_display.vertical_month()

        missing = len(event_column) - len(calendar_column)
        if missing > 0:
            calendar_column = calendar_column + missing * [25 * ' ']

        rows = ['     '.join(one) for one in izip_longest(calendar_column, event_column, fillvalue='')]
        print('\n'.join(rows).encode(conf.default.encoding))
Пример #23
0
def test_vertical_month_unicode():
    try:
        locale.setlocale(locale.LC_ALL, 'de_DE.utf-8')
    except locale.Error as error:
        if str(error) == 'unsupported locale setting':
            pytest.xfail(
                'To get this test to run, you need to add `de_DE.utf-8` to '
                'your locales. On Debian GNU/Linux 8 you do this by '
                'uncommenting `de_DE.utf-8 in /etc/locale.gen and then run '
                '`locale-gen` (as root).')
        else:
            raise

    vert_str = vertical_month(month=12,
                              year=2011,
                              today=datetime.date(2011, 12, 12))
    assert vert_str == example_de
    u'\n'.join(vert_str)  # issue 142
Пример #24
0
def test_vertical_month_unicode_weekdeays_gr():
    try:
        locale.setlocale(locale.LC_ALL, 'el_GR.UTF-8')
    except locale.Error as error:
        if str(error) == 'unsupported locale setting':
            pytest.xfail(
                'To get this test to run, you need to add `el_GR.UTF-8` to '
                'your locales. On Debian GNU/Linux 8 you do this by '
                'uncommenting `el_GR.UTF-8` in /etc/locale.gen and then run '
                '`locale-gen` (as root).'
            )
        else:
            raise

    vert_str = vertical_month(month=12, year=2011,
                              today=datetime.date(2011, 12, 12))
    assert [line.lower() for line in vert_str] == [line.lower() for line in example_gr]
    '\n'.join(vert_str)  # issue 142/293
Пример #25
0
def test_vertical_month_unicode():
    try:
        locale.setlocale(locale.LC_ALL, 'de_DE.utf-8')
    except locale.Error as error:
        if str(error) == 'unsupported locale setting':
            pytest.xfail(
                'To get this test to run, you need to add `de_DE.utf-8` to '
                'your locales. On Debian GNU/Linux 8 you do this by '
                'uncommenting `de_DE.utf-8 in /etc/locale.gen and then run '
                '`locale-gen` (as root).'
            )
        else:
            raise

    vert_str = vertical_month(month=12, year=2011,
                              today=datetime.date(2011, 12, 12))
    assert vert_str == example_de
    u'\n'.join(vert_str)  # issue 142
Пример #26
0
def test_vertical_month_abbr_fr():
    # see issue #653
    try:
        locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')
        vert_str = vertical_month(month=12, year=2011,
                                  today=dt.date(2011, 12, 12))
        assert '\n'.join(vert_str) == '\n'.join(example_fr)
    except locale.Error as error:
        if str(error) == 'unsupported locale setting':
            pytest.xfail(
                'To get this test to run, you need to add `fr_FR.UTF-8` to '
                'your locales. On Debian GNU/Linux 8 you do this by '
                'uncommenting `fr_FR.UTF-8` in /etc/locale.gen and then run '
                '`locale-gen` (as root).'
            )
        else:
            raise
    finally:
        locale.setlocale(locale.LC_ALL, 'C')
Пример #27
0
def test_vertical_month_unicode_weekdeays():
    try:
        locale.setlocale(locale.LC_ALL, 'cs_CZ.UTF-8')
        vert_str = vertical_month(month=12, year=2011,
                                  today=dt.date(2011, 12, 12))
        assert [line.lower() for line in vert_str] == [line.lower() for line in example_cz]
        '\n'.join(vert_str)  # issue 142/293
    except locale.Error as error:
        if str(error) == 'unsupported locale setting':
            pytest.xfail(
                'To get this test to run, you need to add `cs_CZ.UTF-8` to '
                'your locales. On Debian GNU/Linux 8 you do this by '
                'uncommenting `cs_CZ.UTF-8` in /etc/locale.gen and then run '
                '`locale-gen` (as root).'
            )
        else:
            raise
    finally:
        locale.setlocale(locale.LC_ALL, 'C')
Пример #28
0
def test_vertical_month_abbr_fr():
    # see issue #653
    try:
        locale.setlocale(locale.LC_ALL, 'fr_FR.UTF-8')
        vert_str = vertical_month(month=12, year=2011,
                                  today=dt.date(2011, 12, 12))
        assert '\n'.join(vert_str) == '\n'.join(example_fr)
    except locale.Error as error:
        if str(error) == 'unsupported locale setting':
            pytest.xfail(
                'To get this test to run, you need to add `fr_FR.UTF-8` to '
                'your locales. On Debian GNU/Linux 8 you do this by '
                'uncommenting `fr_FR.UTF-8` in /etc/locale.gen and then run '
                '`locale-gen` (as root).'
            )
        else:
            raise
    finally:
        locale.setlocale(locale.LC_ALL, 'C')
Пример #29
0
def test_vertical_month_unicode_weekdeays_gr():
    try:
        locale.setlocale(locale.LC_ALL, 'el_GR.UTF-8')
        vert_str = vertical_month(month=12, year=2011,
                                  today=datetime.date(2011, 12, 12))
        # on some OSes, Greek locale's abbreviated day of the week and
        # month names have accents, on some they haven't
        assert [line.lower() for line in vert_str] in [example_gr, example_gr_accent]
        '\n'.join(vert_str)  # issue 142/293
    except locale.Error as error:
        if str(error) == 'unsupported locale setting':
            pytest.xfail(
                'To get this test to run, you need to add `el_GR.UTF-8` to '
                'your locales. On Debian GNU/Linux 8 you do this by '
                'uncommenting `el_GR.UTF-8` in /etc/locale.gen and then run '
                '`locale-gen` (as root).'
            )
        else:
            raise
    finally:
        locale.setlocale(locale.LC_ALL, 'C')
Пример #30
0
def calendar(collection,
             format=None,
             notstarted=False,
             once=False,
             daterange=None,
             day_format=None,
             locale=None,
             conf=None,
             firstweekday=0,
             weeknumber=False,
             hmethod='fg',
             default_color='',
             multiple='',
             color='',
             highlight_event_days=0,
             full=False,
             bold_for_light_color=True,
             **kwargs):
    td = None
    show_all_days = False
    if conf is not None:
        if format is None:
            format = conf['view']['agenda_event_format']
        if day_format is None:
            day_format = conf['view']['agenda_day_format']
        td = conf['default']['timedelta']
        show_all_days = conf['default']['show_all_days']

    term_width, _ = get_terminal_size()
    lwidth = 25
    rwidth = term_width - lwidth - 4
    start, end = start_end_from_daterange(daterange, locale, td)
    event_column = get_list_from_str(collection,
                                     format=format,
                                     day_format=day_format,
                                     start=start,
                                     end=end,
                                     locale=locale,
                                     once=once,
                                     notstarted=notstarted,
                                     default_timedelta=td,
                                     width=rwidth,
                                     show_all_days=show_all_days,
                                     **kwargs)
    calendar_column = calendar_display.vertical_month(
        month=start.month,
        year=start.year,
        count=max(3,
                  (end.year - start.year) * 12 + end.month - start.month + 1),
        firstweekday=firstweekday,
        weeknumber=weeknumber,
        collection=collection,
        hmethod=hmethod,
        default_color=default_color,
        multiple=multiple,
        color=color,
        highlight_event_days=highlight_event_days,
        locale=locale,
        bold_for_light_color=bold_for_light_color)
    rows = merge_columns(calendar_column, event_column)
    echo('\n'.join(rows))