App Engine Python SDK  v1.6.9 rev.445
The Python runtime is available as an experimental Preview feature.
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
google.appengine.ext.bulkload.simplexml_connector.SimpleXmlConnector Class Reference
Inheritance diagram for google.appengine.ext.bulkload.simplexml_connector.SimpleXmlConnector:
google.appengine.ext.bulkload.connector_interface.ConnectorInterface

Public Member Functions

def create_from_options
 
def __init__
 
def generate_import_record
 
def initialize_export
 
def write_iterable_as_elements
 
def write_dict
 
def finalize_export
 
- Public Member Functions inherited from google.appengine.ext.bulkload.connector_interface.ConnectorInterface
def generate_import_record
 
def initialize_export
 
def write_dict
 
def finalize_export
 

Public Attributes

 xpath_to_nodes
 
 xml_style
 
 output_stream
 
 bulkload_state
 
 depth
 
 node_list
 
 entity_node
 
 indent
 

Static Public Attributes

int ELEMENT_CENTRIC = 1
 
int ATTRIBUTE_CENTRIC = 2
 

Detailed Description

Read/write a simply-structured XML file and convert dicts for each record.

A simply-structed XML file is one where we can locate all interesting nodes
with a simple (ElementTree supported) xpath, and each node contains either
all the info we care about as child (and not grandchild) nodes with text or
as attributes.
We'll also pass the entire node in case the developer wants to do something
more interesting with it (occasional grandchildren, parents, etc.).

This is of course a fairly expensive way to read XML--we build a DOM, then
copy parts of it into a dict. A pull model would work well with the interface
too.

Constructor & Destructor Documentation

def google.appengine.ext.bulkload.simplexml_connector.SimpleXmlConnector.__init__ (   self,
  xpath_to_nodes,
  xml_style 
)
Constructor.

Args:
  xpath_to_nodes: xpath to the nodes to run over.
  xml_style: ELEMENT_CENTRIC or ATTRIBUTE_CENTRIC--we'll
either convert the list of elements to a dict (last element of the same
name will be used) or the list of attributes.

Raises:
  InvalidConfiguration: If the config is invalid.

Member Function Documentation

def google.appengine.ext.bulkload.simplexml_connector.SimpleXmlConnector.create_from_options (   cls,
  options,
  name 
)
Factory using an options dictionary.

Args:
  options: Dictionary of options. Must contain:
* xpath_to_nodes: The xpath to select a record.
* style: 'element_centric' or 'attribute_centric'
  name: The name of this transformer, for use in error messages.

Returns:
  XmlConnector connector object described by the specified options.

Raises:
  InvalidConfiguration: If the config is invalid.
def google.appengine.ext.bulkload.simplexml_connector.SimpleXmlConnector.generate_import_record (   self,
  filename,
  bulkload_state 
)
Generator, yields dicts for nodes found as described in the options.
def google.appengine.ext.bulkload.simplexml_connector.SimpleXmlConnector.initialize_export (   self,
  filename,
  bulkload_state 
)
Initialize the output file.
def google.appengine.ext.bulkload.simplexml_connector.SimpleXmlConnector.write_dict (   self,
  dictionary 
)
Write one record for the specified entity.
def google.appengine.ext.bulkload.simplexml_connector.SimpleXmlConnector.write_iterable_as_elements (   self,
  values 
)
Write a dict as elements, possibly recursively.

The documentation for this class was generated from the following file: