Next / Previous / Contents / Shipman's homepage

6.19. Txny.__buildMaps(): Index by key and scientific name

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

xnomo3.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.

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