This method translates a BirdForm instance to
XML, building the form node and its subtree.
# - - - B i r d F o r m . w r i t e N o d e
def writeNode(self, parent):
"""Add self's content to the parent node.
"""
#- 1 --
# [ parent := parent with a new rnc.FORM_N node added
# formnode := that new node ]
formNode = et.SubElement(parent, rnc.FORM_N)
We first add the taxon-group content to the node we are building; see Section 12.13, “BirdForm._writeTaxonGroup()”.
#-- 2 --
# [ formNode +:= self's taxon-group content ]
self._writeTaxonGroup(formNode)
As with Section 12.7, “BirdForm.readNode() (static
method)”, there are two
general cases, depending on whether there are multiple sightings
or not. See Section 12.14, “BirdForm.writeSingle(): Create
single-sighting XML” and Section 12.15, “BirdForm.writeMulti(): Create multi-sighting
XML”.
#-- 3 --
# [ if self has only one sighting ->
# formNode +:= form node with age-sex-group, loc-group,
# and sighting-notes content added from that sighting
# else ->
# formNode := formNode + (loc-group and sighting-notes
# from self) + (rnc.FLOC_N children added made from
# self's sightings ]
if len(self) == 1:
self.writeSingle(formNode)
else:
self.writeMulti(formNode)