This method is part of the process of translating a day-summary node into a DaySummary instance. See the definition of the day-annotation
pattern in the schema.
The node argument is the day-summary element. We look for all the
element children that are defined in the day-annotation pattern of the schema, and add
attributes to the instance for any that we find.
# - - - D a y S u m m a r y . d a y A n n o t a t i o n
def dayAnnotation(self, node):
"""Read day-annotation content.
[ node is an rnc.DAY_SUMMARY node as an et.Element ->
self := self with information added from any
day-annotation children of (node) ]
"""
First we look for the elements that can occur only
once: route, weather, missed, and film. Each of these
elements has narrative content that is processed
by Section 18.8, “Narrative.readChild() (static
method)”.
#-- 1 --
# [ if node has at least one rnc.ROUTE_N child ->
# self.route := an Annotation instance representing
# that child's content
# else -> I ]
self.route = Narrative.readChild(node, rnc.ROUTE_N)
#-- 2 --
# [ if node has at least one rnc.WEATHER_N child ->
# self.weather := an Annotation instance representing
# that child's content
# else -> I ]
self.weather = Narrative.readChild(node, rnc.WEATHER_N)
#-- 3 --
# [ if node has at least one rnc.MISSED_N child ->
# self.missed := an Annotation instance representing
# that child's content
# else -> I ]
self.missed = Narrative.readChild(node, rnc.MISSED_N)
#-- 4 --
# [ if node has at least one rnc.FILM_N child ->
# self.film := an Annotation instance representing
# that child's content
# else -> I ]
self.film = Narrative.readChild(node, rnc.FILM_N)
The para child is different: there may be
any number of them. We'll build a Narrative instance, adding each para to it.
#-- 5 --
# [ paraNodeList := list of all rnc.PARA_N children
# of node ]
paraNodeList = node.xpath(rnc.PARA_N)
See Section 18.1, “Narrative.__init__(): Constructor” and Section 19.7, “Paragraph.readNode(): Process a para element (static method)”.
#-- 6 --
# [ if paraNodeList is non-empty ->
# self.notes := a new Narrative instance with paragraphs
# added made from the elements of paraNodeList
# else -> I ]
if len(paraNodeList) > 0:
#-- 6.1 --
# [ self.notes := a new, empty Narrative instance ]
self.notes = Narrative()
#-- 6.2 --
# [ narrative := narrative with paragraphs added
# made from the elements of paraNodeList ]
for paraNode in paraNodeList:
para = Paragraph.readNode(paraNode)
self.notes.addPara(para)