Next / Previous / Contents / Shipman's homepage

12.10. BirdForm.multiSighting(): Read the multi-sighting case

While reading an XML file, this method handles the case where the form element has one or more floc children.

Note that loc-group and sighting-notes content can occur both at the form level and at the floc level. The former is attached to the BirdForm instance, while the latter is attached to the child Sighting instance.

birdnotes.py
# - - -   B i r d F o r m . m u l t i S i g h t i n g

    def multiSighting(self, dayNotes, formNode, flocList):
        """Read a form with floc children.

          [ (dayNotes is the parent DayNotes instance) and
            (formNode is an rnc.FORM_N et.Element) and
            (flocList is a list of its rnc.FLOC_N children) ->
              self  :=  self with loc-group and sighting-notes
                  added from node, and Sighting children added, made
                  from the elements of flocList ]
        """

If there is no loc-group content, set self.locGroup to None, otherwise set it to a LocGroup instance. See Section 14.2, “LocGroup.readNode(): Extract loc-group content”.

birdnotes.py
        #-- 1 --
        # [ if formNode has any loc-group content ->
        #     self.locGroup  :=  that content as a LocGroup instance
        #   else ->
        #     self.locGroup  :=  None ]
        self.locGroup = LocGroup.readNode(formNode, dayNotes)

The parent node's sighting-notes is handled similarly; see Section 16.5, “SightNotes.readNode() (static method)”.

birdnotes.py
        #-- 2 --
        # [ if formNode has any sighting-notes content ->
        #     self.sightNotes  :=  that content as a SightNotes
        #                          instance
        #   else ->
        #     self.sightNotes  :=  None ]
        self.sightNotes = SightNotes.readNode(formNode)

Each child floc node is converted into a child Sighting by Section 12.11, “BirdForm.readFloc(): Read one floc element”.

birdnotes.py
        #-- 3 --
        # [ self  :=  self with child Sighting instances added
        #             made from the elements of flocList ]
        for  flocNode in flocList:
            self.readFloc(flocNode, dayNotes)