#NEWLINE# def _calculate_word_prob_all( ) : #NEWLINE# #INDENT# links = Link . objects . all ( ) . order_by ( '-created_on' ) [ : max_links_in_corpus ] #NEWLINE# try : #NEWLINE# #INDENT# corpus = file ( sample_corpus_location , 'r' ) #NEWLINE# corpus_created = os . path . getmtime ( sample_corpus_location ) #NEWLINE# diff = ( datetime . now ( ) - datetime . fromtimestamp ( corpus_created ) ) #NEWLINE# if ( diff . days > calculate_corpus_after ) : #NEWLINE# #INDENT# raise IOError #NEWLINE# #UNINDENT# all_corpus = pickle . load ( corpus ) #NEWLINE# corpus . close ( ) #NEWLINE# #UNINDENT# except IOError : #NEWLINE# #INDENT# all_corpus = _calculate_word_prob ( links ) #NEWLINE# corpus = file ( sample_corpus_location , 'w' ) #NEWLINE# pickle . dump ( all_corpus , corpus ) #NEWLINE# corpus . close ( ) #NEWLINE# #UNINDENT# return all_corpus