Next / Previous / Contents / Shipman's homepage

17.6. Txny.__scanNonSpTail(): Process higher-taxon tail

nomcompile3
# - - -   T x n y . _ _ s c a n N o n S p T a i l

    def __scanNonSpTail ( self, scan, stdHead ):
        '''Process the tail section of a higher-taxon record.

          [ (scan is a Scan instance) and
            (stdHead is a StdHead instance) ->
              if line in scan contains a valid non-species tail ->
                scan  :=  scan advanced to end of line
                self  :=  self with taxon added from stdHead and
                          that tail
                Log()  +:=  error messages for duplicate or
                            inconsistent bindings, if any                
              else ->
                scan  :=  scan advanced not past end of line
                Log()  +:=  error message(s)
                raise SyntaxError ]
        '''

The scanning logic is in Section 21, “class NonSpTail: Scanner for the non-species tail”.

nomcompile3
        #-- 1 --
        # [ if the balance of the line in scan is a valid
        #   non-species tail ->
        #     scan  :=  scan advanced to end of line
        #     nonSpTail  :=  a NonSpTail instance representing
        #                    that line
        #   else ->
        #     scan  :=  scan advanced not past end of line
        #     Log()  +:=  error message(s)
        #     raise SyntaxError ]
        nonSpTail = NonSpTail ( scan )

We collect the various attributes of the new taxon in a RawTaxon instance; see Section 23, “class RawTaxon: Temporary container for taxon attributes”.

nomcompile3
        #-- 2 --
        # [ rawTaxon  :=  a new RawTaxon instance with rank code
        #       (stdHead.rank.code), scientific name (nonSpTail.sci),
        #       English name nonSpTail.eng, status (stdHead.status),
        #       and no codes ]
        rawTaxon = RawTaxon ( stdHead.rank.code, nonSpTail.sci,
            nonSpTail.eng, stdHead.status, None, None )

For the logic that appends the new taxon to the tree (or raises an exception if it doesn't fit), see Section 17.7, “Txny.__appendTaxon(): Try to append this taxon to the tree”.

nomcompile3
        #-- 3 --
        # [ if rawTaxon can be appended to self.taxaTree ->
        #     self.taxaTree  +:=  a new Taxon instance made from rawTaxon
        #   else ->
        #     Log()  +:=  error message(s)
        #     raise SyntaxError ]
        self.__appendTaxon ( scan, rawTaxon )