diff options
| author | Mac Mollison <mollison@cs.unc.edu> | 2010-03-14 04:20:38 -0400 |
|---|---|---|
| committer | Mac Mollison <mollison@cs.unc.edu> | 2010-03-14 04:20:38 -0400 |
| commit | c8210c3cef340e8280658e847cc70958be77eb26 (patch) | |
| tree | 32d851453fc02677ea3437c69f9c6ce373cd45e8 /unit_trace | |
| parent | 361d978921690a7c26a63b933b502d5d2fc3e3d5 (diff) | |
Add support for intervals
Can now filter by earliest record of interest and
latest record of interest, using -e and -l.
Diffstat (limited to 'unit_trace')
| -rw-r--r-- | unit_trace/earliest.py | 21 | ||||
| -rw-r--r-- | unit_trace/latest.py | 19 |
2 files changed, 40 insertions, 0 deletions
diff --git a/unit_trace/earliest.py b/unit_trace/earliest.py new file mode 100644 index 0000000..eaf0cf8 --- /dev/null +++ b/unit_trace/earliest.py | |||
| @@ -0,0 +1,21 @@ | |||
| 1 | ############################################################################### | ||
| 2 | # Description | ||
| 3 | ############################################################################### | ||
| 4 | |||
| 5 | # Enforce earliest record | ||
| 6 | |||
| 7 | ############################################################################### | ||
| 8 | # Public functions | ||
| 9 | ############################################################################### | ||
| 10 | |||
| 11 | def earliest(stream, earliest): | ||
| 12 | for record in stream: | ||
| 13 | if record.record_type=="event": | ||
| 14 | if record.when < earliest: | ||
| 15 | pass | ||
| 16 | else: | ||
| 17 | yield record | ||
| 18 | break | ||
| 19 | yield record | ||
| 20 | for record in stream: | ||
| 21 | yield record | ||
diff --git a/unit_trace/latest.py b/unit_trace/latest.py new file mode 100644 index 0000000..4abd3a2 --- /dev/null +++ b/unit_trace/latest.py | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | ############################################################################### | ||
| 2 | # Description | ||
| 3 | ############################################################################### | ||
| 4 | |||
| 5 | # Enforce latest record | ||
| 6 | |||
| 7 | ############################################################################### | ||
| 8 | # Public functions | ||
| 9 | ############################################################################### | ||
| 10 | |||
| 11 | def latest(stream, latest): | ||
| 12 | for record in stream: | ||
| 13 | if record.record_type=="event": | ||
| 14 | if record.when > latest: | ||
| 15 | break | ||
| 16 | else: | ||
| 17 | yield record | ||
| 18 | else: | ||
| 19 | yield record | ||
