#NEWLINE# def _get_node_id( node , handler , node_map ) : #NEWLINE# #INDENT# candidates = [ ] #NEWLINE# for mac in node . get ( 'mac' , [ ] ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# candidates . append ( node_map [ 'mac' ] [ mac . lower ( ) ] ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# unique_id = handler . unique_id_from_fields ( node ) #NEWLINE# if unique_id : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# candidates . append ( node_map [ 'pm_addr' ] [ unique_id ] ) #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# pass #NEWLINE# #UNINDENT# #UNINDENT# if ( len ( candidates ) > 1 ) : #NEWLINE# #INDENT# raise exception . InvalidNode ( ( 'Several candidates found for the same node data: %s' % handler ) , node = node ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if candidates : #NEWLINE# #INDENT# return candidates [ 0 ]