Next / Previous / Contents / Shipman's homepage

6.18. Txny.__readTaxonomy()

This method reads the root taxonomy node and recursively adds its descendants.

xnomo3.py
# - - -   T x n y . _ _ r e a d T a x o n o m y   - - -

    def __readTaxonomy ( self, taxonomyNode ):
        """Build the taxonomy subtree.

          [ taxonomyNode is a TAXONOMY_N Element node ->
              self.root  :=  a Taxon instance made from root's TAXONOMY_N
                  subtree, with children representing that subtree
              self.__txKeyMap  :=  as invariant, from that subtree
              self.__sciMap    :=  as invariant, from that subtree ]
        """

First we find the taxon node that roots the classification tree:

xnomo3.py
        #-- 1 --
        # [ rootTaxonNode  :=  the TAXON_N node child of taxonomyNode ]
        rootTaxonNode = taxonomyNode.find ( rnc.TAXON_N )

Then we recursively transform that node and its descendants into a tree of Taxon instances, storing the new root instance in self.root:

xnomo3.py
        #-- 2 --
        # [ self.root  :=  a new Taxon instance representing rootTaxonNode
        #       and having descendants made from the descendants of
        #       rootTaxonNode ]
        self.root = Taxon ( self, None, rootTaxonNode )

We still need to add entries to our internal maps so we can find taxa by taxonomic key or by scientific name:

xnomo3.py
        #-- 3 --
        # [ self.__txKeyMap  :=  as invariant, from self.root and its
        #       descendants
        #   self.__sciMap    :=  as invariant, from self.root and its
        #       descendants ]
        self.__buildMaps()