Next / Previous / Contents / Shipman's homepage

18.5. TaxaTree.addTaxon()

nomcompile3
# - - -   T a x a T r e e . a d d T a x o n

    def addTaxon ( self, parent, rawTaxon ):
        '''Create a new Taxon and add it to the tree.
        '''

The Taxon() constructor takes care of linking the parent to the child. We must also update the two lookup tables, .__sciMap and .__txKeyMap. Checking for duplicate scientific names must be done elsewhere before calling this method.

nomcompile3
        #-- 1 --
        # [ parent  :=  parent with a new child Taxon added, made
        #               from rawTaxon
        #   taxon  :=  that new Taxon instance ]
        taxon = Taxon ( self.hier, parent, rawTaxon )

        #-- 2 --
        self.__sciMap[taxon.sci] = taxon
        self.__txKeyMap[taxon.txKey] = taxon

        #-- 3 --
        return taxon