This method attaches a day-summary subtree
to the given parent, made from self.
# - - - D a y S u m m a r y . w r i t e N o d e
def writeNode(self, parent):
"""Translate self to XML.
"""
First we build the day-summary node
itself, and attach its default-loc
attribute.
#-- 1 --
# [ parent := parent with a new rnc.DAY_SUMMARY_N node
# added with its rnc.DEFAULT_LOC_A attribute set to
# self.defaultLocCode
# result := that new node ]
result = et.SubElement(parent, rnc.DAY_SUMMARY_N)
result.attrib[rnc.DEFAULT_LOC_A] = self.defaultLocCode
Next, add the locations. See Section 10.5, “Loc.writeNode(): Translate to XML”.
#-- 2 --
# [ result := result with rnc.LOC_N nodes added, made
# from the locations in self ]
for loc in self.genLocs():
locNode = loc.writeNode(result)
Finally, add the various day-annotation elements.
In each case, this addition is done by Section 18.6, “Narrative.writeNode(): Write as XML”.
#-- 3 --
# [ if self.route is not None ->
# result := result with an rnc.ROUTE_N node added
# containing self.route's narrative
# else -> I ]
if self.route:
routeNode = et.SubElement(result, rnc.ROUTE_N)
self.route.writeNode(routeNode)
#-- 4 --
# [ if self.weather is not None ->
# result := result with an rnc.WEATHER_N node added
# containing self.weather's narrative
# else -> I ]
if self.weather:
weatherNode = et.SubElement(result, rnc.WEATHER_N)
self.weather.writeNode(weatherNode)
#-- 5 --
# [ if self.missed is not None ->
# result := result with an rnc.MISSED_N node added
# containing self.missed's narrative
# else -> I ]
if self.missed:
missedNode = et.SubElement(result, rnc.MISSED_N)
self.missed.writeNode(missedNode)
#-- 6 --
# [ if self.film is not None ->
# result := result with an rnc.FILM_N node added
# containing self.film's narrative
# else -> I ]
if self.film:
filmNode = et.SubElement(result, rnc.FILM_N)
self.film.writeNode(filmNode)
Finally, add the notes narrative if
present. They will be added as para
elements directly under the day-summary
node, unlike the above four where the narrative is added
under a child node.
#-- 7 --
# [ if self.notes is not None ->
# result := result with rnc.PARA_N nodes added
# from self.notes
# else -> I ]
if self.notes:
self.notes.writeNode(result)