#NEWLINE# def clean_all( G , settings ) : #NEWLINE# #INDENT# '\n    Removes all the output files from all targets. Takes\n    the graph as the only argument\n\n    Args:\n        The networkx graph object\n        The settings dictionary\n\n    Returns:\n        0 if successful\n        1 if removing even one file failed\n    ' #NEWLINE# quiet = settings [ 'quiet' ] #NEWLINE# recon = settings [ 'recon' ] #NEWLINE# sprint = settings [ 'sprint' ] #NEWLINE# error = settings [ 'error' ] #NEWLINE# all_outputs = [ ] #NEWLINE# for node in G . nodes ( data = True ) : #NEWLINE# #INDENT# if ( 'output' in node [ 1 ] ) : #NEWLINE# #INDENT# for item in get_all_outputs ( node [ 1 ] ) : #NEWLINE# #INDENT# all_outputs . append ( quiet ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# all_outputs . append ( '.shastore' ) #NEWLINE# retcode = 0 #NEWLINE# for item in sorted ( all_outputs ) : #NEWLINE# #INDENT# if os . path . isfile ( item ) : #NEWLINE# #INDENT# if recon : #NEWLINE# #INDENT# sprint ( 'Would remove file: {}' . format ( item ) ) #NEWLINE# continue #NEWLINE# #UNINDENT# sprint ( "Attempting to remove file '{}'" , level = 'verbose' ) #NEWLINE# try : #NEWLINE# #INDENT# os . remove ( item ) #NEWLINE# sprint ( 'Removed file' , level = 'verbose' ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# errmes = "Error: file '{}' failed to be removed" #NEWLINE# error ( errmes . format ( item ) ) #NEWLINE# retcode = 1 #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# if ( ( not retcode ) and ( not recon ) ) : #NEWLINE# #INDENT# sprint ( 'All clean' , color = True ) #NEWLINE# #UNINDENT# return retcode