Next / Previous / Contents / Shipman's homepage

11.8. BirdForm.getTaxonGroup() (static method)

The purpose of this method is to extract all the items of the taxon-group pattern from the XML form element, and use that to construct a new BirdForm instance. It is a static method because it is called from Section 11.7, “BirdForm.readNode() (static method)”, which is also a static method.

Refer to the schema for the definition of taxon-group.

birdnotes.py
# - - -   B i r d F o r m . g e t T a x o n G r o u p

#   @staticmethod
    def getTaxonGroup ( txny, dayNotes, node ):
        """Convert the XML taxon-group pattern to a BirdForm instance.

          [ (txny is a bird taxonomy as a txny.Txny instance) and
            (dayNotes is the parent DayNotes instance) and
            (node is an et.Element) ->
              return a new BirdForm instance made from node's
              taxon-group content ]
        """

First we extract the taxon-group items. The ab6 attribute is required; rel, alt, and notable are optional.

birdnotes.py
        #-- 1 --
        # [ ab6  :=  node's rnc.AB6_A attribute
        #   rel  :=  node's rnc.REL_A attribute, defaulting to None
        #   alt  :=  node's rnc.ALT_A attribute, defaulting to None
        #   notable  :=  node's rnc.NOTABLE_A attribute, defaulting
        #                to None ]
        ab6  =  node.attrib [ rnc.AB6_A ]
        rel  =  node.attrib.get ( rnc.REL_A, None )
        alt  =  node.attrib.get ( rnc.ALT_A, None )
        notable  =  node.attrib.get ( rnc.NOTABLE_A, None )

At this point we have everything we need to build a new BirdForm instance; see Section 11.5, “BirdForm.__init__() for the constructor's calling sequence.

birdnotes.py
        #-- 2 --
        # [ birdForm  :=  a new BirdForm instance using ab6, rel,
        #       alt, and notable ]
        birdForm  =  BirdForm ( txny, dayNotes, ab6, rel, alt,
                                notable )
birdnotes.py
        #-- 3 --
        return birdForm

    getTaxonGroup  =  staticmethod(getTaxonGroup)