Create a new Snapshot instance with a filtered traces sequence, filters is a list of Filter or DomainFilter instances. If filters is an empty list, return a new Snapshot instance with a copy of the traces.
(self, filters)
| 450 | return True |
| 451 | |
| 452 | def filter_traces(self, filters): |
| 453 | """ |
| 454 | Create a new Snapshot instance with a filtered traces sequence, filters |
| 455 | is a list of Filter or DomainFilter instances. If filters is an empty |
| 456 | list, return a new Snapshot instance with a copy of the traces. |
| 457 | """ |
| 458 | if not isinstance(filters, Iterable): |
| 459 | raise TypeError("filters must be a list of filters, not %s" |
| 460 | % type(filters).__name__) |
| 461 | if filters: |
| 462 | include_filters = [] |
| 463 | exclude_filters = [] |
| 464 | for trace_filter in filters: |
| 465 | if trace_filter.inclusive: |
| 466 | include_filters.append(trace_filter) |
| 467 | else: |
| 468 | exclude_filters.append(trace_filter) |
| 469 | new_traces = [trace for trace in self.traces._traces |
| 470 | if self._filter_trace(include_filters, |
| 471 | exclude_filters, |
| 472 | trace)] |
| 473 | else: |
| 474 | new_traces = self.traces._traces.copy() |
| 475 | return Snapshot(new_traces, self.traceback_limit) |
| 476 | |
| 477 | def _group_by(self, key_type, cumulative): |
| 478 | if key_type not in ('traceback', 'filename', 'lineno'): |