Next / Previous / Contents / Shipman's homepage

4.11. txny.__buildMaps(): Index by key and scientific name

This method builds the internal .__txKeyMap and .__sciMap dictionaries.

txny.py
# - - -   T x n y . _ _ b u i l d M a p s   - - -

    def __buildMaps ( self ):
        """Build the key and scientific name maps.

          [ self.__txKeyMap  :=  as invariant, from self.root and its
                descendants
            self.__sciMap    :=  as invariant, from self.root and its
                descendants ]
        """

        #-- 1 --
        self.__txKeyMap  =  {}
        self.__sciMap    =  {}

Recursion takes care of visiting every Taxon node starting at self.root.

txny.py
        #-- 2 --
        # [ self.__txKeyMap  +:=  entries whose values are the Taxon
        #       objects rooted in self.root and whose keys are the
        #       .txKey attributes of those Taxon objects
        #   self.__sciMap    +:=  entries whose values are the Taxon
        #       objects rooted in self.root and whose keys are the
        #       .sci attributes of those Taxon objects ]
        self.__addTaxonMaps ( self.root )