Next / Previous / Contents / Shipman's homepage

16.6. SightNotes.writeNode()

Given a parent node, this method attaches sighting-notes content from the instance to that parent. See Section 16.7, “SightNotes.writeChild(): Attach narrative to a child”.

birdnotes.py
# - - -   S i g h t N o t e s . w r i t e N o d e

    def writeNode(self, parent):
        """Translate to XML.
        """
        #-- 1 --
        # [ if self.desc is not None ->
        #     parent  :=  parent with a new rnc.DESC_N child
        #                 attached containing self.desc
        #   else -> I ]
        self.writeChild(parent, rnc.DESC_N, self.desc)

The other optional single items are handled similarly.

birdnotes.py
        #-- 2 --
        # [ simile ]
        self.writeChild(parent, rnc.BEHAVIOR_N, self.behavior)

        #-- 3 --
        self.writeChild(parent, rnc.VOC_N, self.voc)

        #-- 4  --
        self.writeChild(parent, rnc.BREEDING_N, self.breeding)

There may be any number of photo children; see Section 17.3, “Photo.writeNode().

birdnotes.py
        #-- 5 --
        if  len(self._photoList):
            for  photo in self._photoList:
                photo.writeNode(parent)

If the .notes attribute is not None, it contains a Narrative instance, which is added to the tree using Section 18.6, “Narrative.writeNode(): Write as XML”.

birdnotes.py
        #-- 6 --
        if  self.notes:
            self.notes.writeNode(parent)