Users don't call this constructor directly. Its purpose is to
convert XML nodes into Taxon instances.
Consequently, its calling sequence looks like this:
# - - - T a x o n . _ _ i n i t _ _ - - -
def __init__ ( self, txny, parentTaxon, taxonNode ):
"""Constructor for a Taxon instance.
"""
Note that this constructor is recursive. It converts not only the
given taxonNode but all its descendants.
Pass it the root TAXON_N node, and it will
build the entire tree.
The first step is to set up the parts of the instance that point elsewhere.
#-- 1 --
self.txny = txny
self.parent = parentTaxon
Next, we set up the parts of the instance that are derived from the XML node we're converting:
#-- 2 --
# [ self.abbr := STD_ABBR_A attribute from taxonNode, or None
# if there is no such attribute
# self.__raweng := ENG_A attribute from taxonNode
# self.rank := rank whose code is the RANK_A
# attribute from taxonNode
# self.sci := SCI_A attribute from taxonNode
# self.status := STATUS_A attribute from taxonNode, or None
# if there is no such attribute
# self.txKey := TX_KEY_A attribute from taxonNode ]
self.abbr = taxonNode.attrib.get(rnc.STD_ABBR_A, None)
self.__rawEng = taxonNode.findtext(rnc.ENG_N).strip()
rankCode = taxonNode.attrib[rnc.RANK_A]
self.rank = txny.hier.lookupRankCode ( rankCode )
self.sci = taxonNode.attrib[rnc.SCI_A]
self.status = taxonNode.attrib.get(rnc.STATUS_A, None)
self.txKey = taxonNode.attrib[rnc.TX_KEY_A]
See Section 9.14, “Taxon.__engNames(): Build the variants on
the English name”.
#-- 3 --
# [ self.eng := as invariant, from self.__rawEng
# self.engComma := as invariant, from self.__rawEng
# self.tex := as invariant, from self.__rawEng
# self.texComma := as invariant, from self.__rawEng ]
self.__engNames()
Finally, we recursively translate all this node's descendants
into Taxon instances, and set up the .__childList attribute as a list of them.
#-- 4 --
# [ self.__childList +:= Taxon instances made from taxonNode's
# children, recursively containing all descendants of
# those children ]
self.__childList = [
Taxon(txny, self, childElt)
for childElt in taxonNode.findall(rnc.TAXON_N) ]