This method builds a Sighting instance
from a form element when there are no
child floc elements.
# - - - B i r d F o r m . s i n g l e S i g h t i n g
def singleSighting(self, dayNotes, node):
"""Build a Sighting child for the single-sighting case.
[ (dayNotes is the parent DayNotes instance) and
(node is an rnc.FORM_N node) ->
self := self with a single Sighting child added,
made from node's age-sex-group, loc-group, and
sighting-notes content ]
"""
See Section 13.1, “Sighting.__init__()” for the constructor.
#-- 1 --
# [ sighting := a new, empty Sighting instance with
# self as the parent ]
sighting = Sighting(self)
Next, check for loc-group content. If there is
any, and it has a loc attribute,
we'll also need
to be sure that location code is defined. See Section 14.2, “LocGroup.readNode(): Extract loc-group content” and Section 8.4, “DayNotes.lookupLoc(): Look up a location
code”.
#-- 2 --
# [ if node has any valid loc-group content ->
# sighting.locGroup := that content as a LocGroup
# instance
# else if node loc-group content with a loc that is
# not in dayNotes ->
# raise IOError
# else ->
# sighting.locGroup := None ]
sighting.locGroup = LocGroup.readNode(node, dayNotes)
The other two kinds of content proceed similarly. See Section 15.2, “AgeSexGroup.readNode() (static
method)” and Section 16.5, “SightNotes.readNode() (static
method)”.
#-- 3 --
# [ if node has any age-sex-group content ->
# sighting.ageSexGroup := a new AgeSexGroup
# instance representing that content
# else ->
# sighting.ageSexGroup := None ]
sighting.ageSexGroup = AgeSexGroup.readNode(node)
#-- 4 --
# [ if node has any sighting-notes content ->
# sighting.sightNotes := a new SightNotes instance
# representing that content
# else ->
# sighting.sightNotes := None ]
sighting.sightNotes = SightNotes.readNode(node)