|
|
@@ -9,6 +9,24 @@ import bisect |
|
|
|
class FileInterval(Interval): |
|
|
|
"""Represents an interval of time and its corresponding data""" |
|
|
|
|
|
|
|
def __init__(self, start, end, |
|
|
|
filename, |
|
|
|
start_offset = None, end_offset = None): |
|
|
|
self.start = start |
|
|
|
self.end = end |
|
|
|
self.filename = filename |
|
|
|
if start_offset is None: |
|
|
|
start_offset = 0 |
|
|
|
self.start_offset = start_offset |
|
|
|
if end_offset is None: |
|
|
|
f = open(filename, 'rb') |
|
|
|
f.seek(0, os.SEEK_END) |
|
|
|
end_offset = f.tell() |
|
|
|
self.end_offset = end_offset |
|
|
|
|
|
|
|
def __setattr__(self, name, value): |
|
|
|
|
|
|
|
|
|
|
|
def subset(self, start, end): |
|
|
|
"""Return a new Interval that is a subset of this one""" |
|
|
|
# TODO: Any magic regarding file/offset/length mapping for subsets |
|
|
|