def group_by_ctime(events, mode):
    counter = Counter()
    total = 0

    for event in events:
        if mode == 'daily':
            day = event.ctime.day
        elif mode == 'monthly':
            day = 1

        key = datetime(event.ctime.year, event.ctime.month, day)

        counter[key] += 1
        total += 1

    if mode == 'daily':
        fmt = '%Y-%m-%d'
        title = 'day'
    elif mode == 'monthly':
        fmt = '%Y-%m'
        title = 'month'

    table = PrettyTable([title, 'count', '%'])
    total = sum(counter.values())

    for item in sorted(counter.items()):
        table.add_row((item[0].strftime(fmt),
                       item[1],
                       item[1] * 100.0 / total))

    table.align['count'] = 'r'
    table.align['%'] = 'r'
    table.float_format['%'] = '.1'
    print table
Mark or unmark an item for trash and save it to the filesystem.
dataset/ETHPy150Open operasoftware/sentrycli/sentrycli/group.py/group_by_ctime--crossover with--dataset/ETHPy150Open DeanCutlet/filestack/views.py/trash