#NEWLINE# def _check_termination( factors , n , limitp1 , use_trial , use_rho , use_pm1 , verbose ) : #NEWLINE# #INDENT# '\n    Helper function for integer factorization. Checks if ``n``\n    is a prime or a perfect power, and in those cases updates\n    the factorization and raises ``StopIteration``.\n    ' #NEWLINE# if verbose : #NEWLINE# #INDENT# print ( 'Check for termination' ) #NEWLINE# #UNINDENT# p = perfect_power ( n , factor = False ) #NEWLINE# if ( p is not False ) : #NEWLINE# #INDENT# ( base , exp ) = p #NEWLINE# if limitp1 : #NEWLINE# #INDENT# limit = ( limitp1 - 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# limit = limitp1 #NEWLINE# #UNINDENT# facs = factorint ( base , limit , use_trial , use_rho , use_pm1 , verbose = False ) #NEWLINE# for ( b , e ) in facs . items ( ) : #NEWLINE# #INDENT# if verbose : #NEWLINE# #INDENT# print ( ( factor_msg % ( b , e ) ) ) #NEWLINE# #UNINDENT# factors [ b ] = ( exp * e ) #NEWLINE# #UNINDENT# raise StopIteration #NEWLINE# #UNINDENT# if isprime ( n ) : #NEWLINE# #INDENT# factors [ int ( n ) ] = 1 #NEWLINE# raise StopIteration #NEWLINE# #UNINDENT# if ( n == 1 ) : #NEWLINE# #INDENT# raise StopIteration