#NEWLINE# def find_graphml_keys( self , graph_element ) : #NEWLINE# #INDENT# 'Extracts all the keys and key defaults from the xml.\n        ' #NEWLINE# graphml_keys = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# graphml_key_defaults = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# for k in graph_element . findall ( ( '{%s}key' % self . NS_GRAPHML ) ) : #NEWLINE# #INDENT# attr_id = k . get ( 'id' ) #NEWLINE# attr_type = k . get ( 'attr.type' ) #NEWLINE# attr_name = k . get ( 'attr.name' ) #NEWLINE# yfiles_type = k . get ( 'yfiles.type' ) #NEWLINE# if ( yfiles_type is not None ) : #NEWLINE# #INDENT# attr_name = yfiles_type #NEWLINE# attr_type = 'yfiles' #NEWLINE# #UNINDENT# if ( attr_type is None ) : #NEWLINE# #INDENT# attr_type = 'string' #NEWLINE# warnings . warn ( ( 'No key type for id %s. Using string' % attr_id ) ) #NEWLINE# #UNINDENT# if ( attr_name is None ) : #NEWLINE# #INDENT# raise nx . NetworkXError ( ( 'Unknown key for id %s in file.' % attr_id ) ) #NEWLINE# #UNINDENT# graphml_keys [ attr_id ] = { #NEWLINE# #INDENT# 'name' : attr_name , #NEWLINE# 'type' : self . python_type [ attr_type ] , #NEWLINE# 'for' : k . get ( 'for' ) , #NEWLINE# #UNINDENT# } #NEWLINE# default = k . find ( ( '{%s}default' % self . NS_GRAPHML ) ) #NEWLINE# if ( default is not None ) : #NEWLINE# #INDENT# graphml_key_defaults [ attr_type ] = default . text #NEWLINE# #UNINDENT# #UNINDENT# return ( graphml_keys , graphml_key_defaults )