Next / Previous / Contents / Shipman's homepage

4.15. Txny.__addCollision(): Add one collision

Converts a COLLISION_N node to an entry in self.__collMap.

txny.py
# - - -   T x n y . _ _ a d d C o l l i s i o n   - - -

    def __addCollision ( self, collNode ):
        """Convert a COLLISION_N node to a .__collMap entry.

          [ collNode is a COLLISION_N Element ->
              self.__collMap  +:=  an entry mapping the BAD_ABBR_A
                  attribute of collNode |-> a list of the codes
                  from the content of GOOD_ABBR_N element children
                  of collNode ]
        """

        #-- 1 --
        # [ badAbbr   :=  collNode's BAD_ABBR_A attribute
        #   goodList  :=  GOOD_ABBR_N children of collNode ]
        badAbbr   =  collNode.attrib[rnc.BAD_ABBR_A]
        goodNodeList  =  collNode.xpath ( rnc.GOOD_ABBR_N )

        #-- 2 --
        # [ goodAbbrs  :=  a list of the contents of goodNodeList ]
        goodAbbrs  =  [ textContent(goodNode).strip()
                        for goodNode in goodNodeList ]
        
        #-- 3 --
        self.__collMap [ badAbbr.upper() ]  =  goodAbbrs