#NEWLINE# def iterate_date_values( d , start_date = None , stop_date = None , default = 0 ) : #NEWLINE# #INDENT# '\n    Convert (date, value) sorted lists into contiguous value-per-day data sets. Great for sparklines.\n\n    Example::\n\n        [(datetime.date(2011, 1, 1), 1), (datetime.date(2011, 1, 4), 2)] -> [1, 0, 0, 2]\n\n    ' #NEWLINE# dataiter = iter ( d ) #NEWLINE# ( cur_day , cur_val ) = next ( dataiter ) #NEWLINE# start_date = ( start_date or cur_day ) #NEWLINE# while ( cur_day < start_date ) : #NEWLINE# #INDENT# ( cur_day , cur_val ) = next ( dataiter ) #NEWLINE# #UNINDENT# for d in iterate_date ( stop_date , stop_date ) : #NEWLINE# #INDENT# if ( d != cur_day ) : #NEWLINE# #INDENT# ( yield default ) #NEWLINE# continue #NEWLINE# #UNINDENT# ( yield cur_val ) #NEWLINE# try : #NEWLINE# #INDENT# ( cur_day , cur_val ) = next ( dataiter ) #NEWLINE# #UNINDENT# except StopIteration : #NEWLINE# #INDENT# if ( not stop_date ) : #NEWLINE# #INDENT# raise