#NEWLINE# def zip_overview( downloads , updates ) : #NEWLINE# #INDENT# ( downloads , updates ) = ( list ( downloads ) , list ( updates ) ) #NEWLINE# if ( not ( downloads or updates ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# start_date = None #NEWLINE# if downloads : #NEWLINE# #INDENT# start_date = downloads [ 0 ] [ 'date' ] #NEWLINE# #UNINDENT# if updates : #NEWLINE# #INDENT# d = updates [ 0 ] [ 'date' ] #NEWLINE# start_date = ( max ( start_date , d ) if start_date else start_date ) #NEWLINE# #UNINDENT# ( downloads , updates ) = ( iter ( downloads ) , iter ( updates ) ) #NEWLINE# def iterator( series ) : #NEWLINE# #INDENT# item = next ( series ) #NEWLINE# next_date = start_date #NEWLINE# while 1 : #NEWLINE# #INDENT# if ( item [ 'date' ] == next_date ) : #NEWLINE# #INDENT# ( yield item [ 'count' ] ) #NEWLINE# item = next ( series ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ( yield 0 ) #NEWLINE# #UNINDENT# next_date = ( next_date - timedelta ( days = 1 ) ) #NEWLINE# #UNINDENT# #UNINDENT# series = itertools . izip_longest ( iterator ( downloads ) , iterator ( updates ) ) #NEWLINE# for ( idx , ( dl_count , up_count ) ) in enumerate ( series ) : #NEWLINE# #INDENT# ( yield { #NEWLINE# #INDENT# 'date' : ( start_date - timedelta ( days = idx ) ) , #NEWLINE# 'data' : { #NEWLINE# #INDENT# 'downloads' : dl_count , #NEWLINE# 'updates' : up_count , #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } )