<commit_before>import calendar


def get_text_calendar_dates(date1, date2, cols=3):
    """ Get array of datetimes between two dates suitable for formatting """
    """
        The return value is a list of years.
        Each year contains a list of month rows.
        Each month row contains cols months (default 3).
        Each month contains list of 6 weeks (the max possible).
        Each week contains 1 to 7 days.
        Days are datetime.date objects.
    """
    year1 = date1.year
    year2 = date2.year

    # start and end rows
    row1 = (date1.month - 1) / cols
    row2 = (date2.month - 1) / cols + 1

    # generate base calendar array
    Calendar = calendar.Calendar()
    cal = []
    for yr in range(year1, year2+1):
        ycal = Calendar.yeardatescalendar(yr, width=cols)
        if yr == year1 and yr == year2:
            ycal = ycal[row1:row2]
        elif yr == year1:
            ycal = ycal[row1:]
        elif yr == year2:
            ycal = ycal[:row2]
        cal.append(ycal)
    return cal


def get_text_calendar(dates, cols=3):
    """ Get calendar covering all dates, with provided dates colored and labeled """
    _dates = sorted(dates.keys())
    _labels = set(dates.values())
    labels = dict(zip(_labels, [str(31 + i) for i in range(0, len(_labels))]))

    cal = get_text_calendar_dates(_dates[0], _dates[-1])

    # month and day headers
    months = calendar.month_name
    days = 'Mo Tu We Th Fr Sa Su'
    hformat = '{:^20}  {:^20}  {:^20}\n'
    rformat = ' '.join(['{:>2}'] * 7) + '  '
<commit_msg>fix slicing for python3<commit_after>import calendar


def get_text_calendar_dates(date1, date2, cols=3):
    """ Get array of datetimes between two dates suitable for formatting """
    """
        The return value is a list of years.
        Each year contains a list of month rows.
        Each month row contains cols months (default 3).
        Each month contains list of 6 weeks (the max possible).
        Each week contains 1 to 7 days.
        Days are datetime.date objects.
    """
    year1 = date1.year
    year2 = date2.year

    # start and end rows
    row1 = int((date1.month - 1) / cols)
    row2 = int((date2.month - 1) / cols) + 1

    # generate base calendar array
    Calendar = calendar.Calendar()
    cal = []
    for yr in range(year1, year2+1):
        ycal = Calendar.yeardatescalendar(yr, width=cols)
        if yr == year1 and yr == year2:
            ycal = ycal[row1:row2]
        elif yr == year1:
            ycal = ycal[row1:]
        elif yr == year2:
            ycal = ycal[:row2]
        cal.append(ycal)
    return cal


def get_text_calendar(dates, cols=3):
    """ Get calendar covering all dates, with provided dates colored and labeled """
    _dates = sorted(dates.keys())
    _labels = set(dates.values())
    labels = dict(zip(_labels, [str(31 + i) for i in range(0, len(_labels))]))

    cal = get_text_calendar_dates(_dates[0], _dates[-1])

    # month and day headers
    months = calendar.month_name
    days = 'Mo Tu We Th Fr Sa Su'
    hformat = '{:^20}  {:^20}  {:^20}\n'
    rformat = ' '.join(['{:>2}'] * 7) + '  '

{'fraction_non_alphanumeric': 0.11907810499359796, 'fraction_numerical': 0.027848911651728554, 'mean_word_length': 2.389370932754881, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4075189', 'n_tokens_mistral': 1048, 'n_tokens_neox': 991, 'n_words': 333}