def filter(self, date=None, regroup=False, ignored=None, pushed=None, unmapped=None, current_workday=None):
def entry_filter(entry_date, entry):<EOL><INDENT>if ignored is not None and entry.ignored != ignored:<EOL><INDENT>return False<EOL><DEDENT>if pushed is not None and entry.pushed != pushed:<EOL><INDENT>return False<EOL><DEDENT>if unmapped is not None and entry.mapped == unmapped:<EOL><INDENT>return False<EOL><DEDENT>if current_workday is not None:<EOL><INDENT>today = datetime.date.today()<EOL>yesterday = date_utils.get_previous_working_day(today)<EOL>is_current_workday = entry_date in (today, yesterday) and entry_date.strftime('<STR_LIT>') not in [<NUM_LIT:6>, <NUM_LIT:0>]<EOL>if current_workday != is_current_workday:<EOL><INDENT>return False<EOL><DEDENT><DEDENT>return True<EOL><DEDENT>if date is not None and not isinstance(date, tuple):<EOL><INDENT>date = (date, date)<EOL><DEDENT>filtered_entries = collections.defaultdict(list)<EOL>for (entries_date, entries) in six.iteritems(self):<EOL><INDENT>if (date is not None and (<EOL>(date[<NUM_LIT:0>] is not None and entries_date < date[<NUM_LIT:0>])<EOL>or (date[<NUM_LIT:1>] is not None and entries_date > date[<NUM_LIT:1>]))):<EOL><INDENT>continue<EOL><DEDENT>entries_for_date = []<EOL>if regroup:<EOL><INDENT>aggregated_entries = {}<EOL>id = <NUM_LIT:0><EOL>for entry in entries:<EOL><INDENT>if not entry_filter(entries_date, entry):<EOL><INDENT>continue<EOL><DEDENT>if entry.hash not in aggregated_entries:<EOL><INDENT>entries_for_date.append(entry)<EOL>aggregated_entries[entry.hash] = id<EOL>id += <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>existing_entry = entries_for_date[<EOL>aggregated_entries[entry.hash]<EOL>]<EOL>if isinstance(existing_entry, Entry):<EOL><INDENT>aggregated_entry = AggregatedTimesheetEntry()<EOL>aggregated_entry.entries.append(existing_entry)<EOL>aggregated_entry.entries.append(entry)<EOL>entries_for_date[<EOL>aggregated_entries[entry.hash]<EOL>] = aggregated_entry<EOL><DEDENT>else:<EOL><INDENT>aggregated_entry = existing_entry<EOL>aggregated_entry.entries.append(entry)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>entries_for_date = [<EOL>entry for entry in entries if entry_filter(entries_date, entry)<EOL>]<EOL><DEDENT>if entries_for_date:<EOL><INDENT>filtered_entries[entries_date].extend(entries_for_date)<EOL><DEDENT><DEDENT>return filtered_entries<EOL>
Return the entries as a dict of {:class:`datetime.date`: :class:`~taxi.timesheet.lines.Entry`}
items.

`date` can either be a single :class:`datetime.date` object to filter only entries from the given date,
or a tuple of :class:`datetime.date` objects representing `(from, to)`. `filter_callback` is a function that,
given a :class:`~taxi.timesheet.lines.Entry` object, should return True to include that line, or False to
exclude it. If `regroup` is set to True, similar entries (ie. having the same
:meth:`~taxi.timesheet.lines.Entry.hash`) will be regrouped intro a single
:class:`~taxi.timesheet.entry.AggregatedTimesheetEntry`.