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 12.7, “
method)”, which is also
a static method.
Refer to the schema for the definition of
# - - - 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) -> if node's taxon-group content defines a kind of bird valid in txny -> dayNotes +:= a new BirdForm instance made from node's taxon-group content return that instance else -> raise KeyError ] """
First we extract the
taxon-group items. The
ab6 attribute is required;
notable are optional.
#-- 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)
Next we must check that the code or codes are valid against the reference taxonomy.
#-- 2 # [ if (ab6, rel, alt) is a valid bird-id in txny -> # birdId := an abbrModule.BirdId instance representing # those values # else -> raise KeyError ] birdId = abbrModule.BirdId(txny, ab6, rel, alt)
At this point we have everything we need to build a new
BirdForm instance; see Section 12.5, “
BirdForm.__init__()” for the constructor's calling sequence.
#-- 2 -- # [ dayNotes +:= a new BirdForm instance using ab6, rel, # alt, and notable # birdForm := that new BirdForm instance ] birdForm = BirdForm(dayNotes, birdId, notable)
#-- 3 -- return birdForm