diff options
author | Mac Mollison <mollison@cs.unc.edu> | 2010-03-14 03:12:53 -0400 |
---|---|---|
committer | Mac Mollison <mollison@cs.unc.edu> | 2010-03-14 03:12:53 -0400 |
commit | a4377f43c14f3fb28fad1a7b1273080eaf921f57 (patch) | |
tree | e0b6798deed6b7032421f15ed17d95a3d26ee4db /unit_trace/maxer.py | |
parent | 53752df921cc50450926a57ee11301693504c5c5 (diff) |
Created maxer and skipper
Maxer: Allow a maximum number of records to be parsed
Skipper: Skip a given number of records at the beginning
Diffstat (limited to 'unit_trace/maxer.py')
-rw-r--r-- | unit_trace/maxer.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/unit_trace/maxer.py b/unit_trace/maxer.py new file mode 100644 index 0000000..086c6bc --- /dev/null +++ b/unit_trace/maxer.py | |||
@@ -0,0 +1,20 @@ | |||
1 | ############################################################################### | ||
2 | # Description | ||
3 | ############################################################################### | ||
4 | |||
5 | # Parse at most the given number of records | ||
6 | |||
7 | ############################################################################### | ||
8 | # Public functions | ||
9 | ############################################################################### | ||
10 | |||
11 | def maxer(stream, number): | ||
12 | for record in stream: | ||
13 | if record.record_type=="event": | ||
14 | if number > 0: | ||
15 | number -= 1 | ||
16 | yield record | ||
17 | else: | ||
18 | break | ||
19 | else: | ||
20 | yield record | ||