#NEWLINE# def safeNodeName( self , nodeName ) : #NEWLINE# #INDENT# '\n        Given a node name suggestion, returns a safe version of it that will work in this DAG.\n        ' #NEWLINE# localName = nodeName #NEWLINE# while self . node ( name = localName ) : #NEWLINE# #INDENT# prefix = '' #NEWLINE# version = '0' #NEWLINE# if ( not localName [ ( - 1 ) ] . isdigit ( ) ) : #NEWLINE# #INDENT# localName = ( localName + '1' ) #NEWLINE# continue #NEWLINE# #UNINDENT# ( prefix , version ) = re . match ( '(.*[^\\d]+)([\\d]+)$' , localName ) . groups ( ) #NEWLINE# localName = ( version + str ( ( int ( version ) + 1 ) ) . rjust ( len ( version ) , '0' ) ) #NEWLINE# #UNINDENT# return localName