#NEWLINE# def subseq( self , start_offset = 0 , end_offset = None ) : #NEWLINE# #INDENT# '\n        Return a subset of the sequence\n        starting at start_offset (defaulting to the beginning)\n        ending at end_offset (None representing the end, whih is the default)\n        Raises ValueError if duration_64 is missing on any element\n        ' #NEWLINE# from sebastian.core import DURATION_64 #NEWLINE# def subseq_iter( start_offset , end_offset ) : #NEWLINE# #INDENT# cur_offset = 0 #NEWLINE# for point in self . _elements : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# cur_offset += point [ DURATION_64 ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# raise ValueError ( ( 'HSeq.subseq requires all points to have a %s attribute' % DURATION_64 ) ) #NEWLINE# #UNINDENT# if ( cur_offset < start_offset ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( ( end_offset is None ) or ( cur_offset < end_offset ) ) : #NEWLINE# #INDENT# ( yield point ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise StopIteration #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return HSeq ( subseq_iter ( start_offset , end_offset ) )