#NEWLINE# @ classmethod #NEWLINE# def create_from_options( cls , options , name ) : #NEWLINE# #INDENT# "Factory using an options dictionary.\n\n    Args:\n      options: Dictionary of options. Must contain:\n        * xpath_to_nodes: The xpath to select a record.\n        * style: 'element_centric' or 'attribute_centric'\n      name: The name of this transformer, for use in error messages.\n\n    Returns:\n      XmlConnector connector object described by the specified options.\n\n    Raises:\n      InvalidConfiguration: If the config is invalid.\n    " #NEWLINE# xpath_to_nodes = options . get ( 'xpath_to_nodes' ) #NEWLINE# if ( not xpath_to_nodes ) : #NEWLINE# #INDENT# raise bulkloader_errors . InvalidConfiguration ( ( 'simplexml must specify xpath_to_nodes. (In transformer named %s)' % name ) ) #NEWLINE# #UNINDENT# if ( not re . match ( NODE_PATH_ONLY_RE , xpath_to_nodes ) ) : #NEWLINE# #INDENT# logging . warning ( 'simplexml export only supports very simple /root/to/node xpath_to_nodes for now.' ) #NEWLINE# #UNINDENT# xml_style = options . get ( 'style' ) #NEWLINE# xml_style_mapping = { #NEWLINE# #INDENT# 'element_centric' : cls . ELEMENT_CENTRIC , #NEWLINE# 'attribute_centric' : cls . ATTRIBUTE_CENTRIC , #NEWLINE# #UNINDENT# } #NEWLINE# if ( xml_style not in xml_style_mapping ) : #NEWLINE# #INDENT# raise bulkloader_errors . InvalidConfiguration ( ( 'simplexml must specify one of these valid xml_style options: "%s". You specified %s in transformer named %s.' % ( '", "' . join ( xml_style_mapping . keys ( ) ) , xml_style , name ) ) ) #NEWLINE# #UNINDENT# return cls ( xpath_to_nodes , xml_style_mapping [ xml_style ] )