Package sabx10 :: Package oxm :: Module parse
[hide private]
[frames] | no frames]

Module parse

source code

Take an SABX XML tree and turn it into objects.

parse_tree is the main entry point for parsing XML. When you pass it an XML tree of SABX data, it returns a dictionary of information corresponding to the structure of an SABX file. It's returned as a dict because I generally use this to read an SABX file, modify it, then run it through a Jinja2 template for output. Jinja2 takes a dictionary to pass to the template as it's template data.

Here's a somewhat graphical representation of the data that you get back from parse_tree.

Classes [hide private]
  Photo
A Photo object holds the information for an "a" HTML element that links to photos of the ride.
  PhotoSet
A PhotoSet object holds information about a cover photo for the rideset and links to additional photos of the ride.
  HistoryUpdate
A HistoryUpdate object holds the information for a single update to the SABX file.
Functions [hide private]
list of Photo
_parse_photos_photo(xml_photos)
Take the Element for a photos element and turn it into a list of Photo objects.
source code
PhotoSet
parse_photos(xml_tree)
Parse the photos element in the given Element tree.
source code
HistoryUpdate
_parse_update(xml_update)
Take the Element for a history update and turn it into a HistoryUpdate object.
source code
list of HistoryUpdate
parse_history(xml_tree)
Parse the history element in the given Element tree.
source code
dict
parse_top_level(xml_tree)
Parse all of the simple root elements in an SABX file.
source code
dict
parse_tree(xml_tree)
Parse a whole SABX file.
source code
Variables [hide private]
  __package__ = 'sabx10.oxm'
Function Details [hide private]

_parse_photos_photo(xml_photos)

source code 

Take the Element for a photos element and turn it into a list of Photo objects.

Parameters:
  • xml_photos (Element) - Element for the PhotoSet element
Returns: list of Photo
list of Photo objects

parse_photos(xml_tree)

source code 

Parse the photos element in the given Element tree.

Parameters:
  • xml_tree (Element or ElementTree) - root of Element tree that has photos
Returns: PhotoSet
a PhotoSet object or None

_parse_update(xml_update)

source code 

Take the Element for a history update and turn it into a HistoryUpdate object.

Parameters:
  • xml_update (Element) - Element for a history update
Returns: HistoryUpdate
HistoryUpdate object

parse_history(xml_tree)

source code 

Parse the history element in the given Element tree.

Parameters:
  • xml_tree (Element or ElementTree) - root of Element tree that has history in it
Returns: list of HistoryUpdate
List of HistoryUpdates

parse_top_level(xml_tree)

source code 

Parse all of the simple root elements in an SABX file.

The simple root elements are:

  • uuid
  • version
  • zip_prefix
  • description
  • ride_type
  • title
  • description
  • terrain
Parameters:
  • xml_tree (Element or ElementTree) - root of Element tree that has SABX data
Returns: dict
dict of root elements

parse_tree(xml_tree)

source code 

Parse a whole SABX file.

Parameters:
  • xml_tree (Element or ElementTree) - root of Element tree that has SABX data
Returns: dict
dict of parsed SABX data