Next / Previous / Contents / Shipman's homepage

6.15. UniData._readOneChar(): Extract the data for one code point

unidata.py
# - - -   U n i D a t a . _ r e a d O n e C h a r

    def _readOneChar(self, charNode):
        '''Add one character to self.

          [ charNode is a CHARACTER_N et.Element ->
              if charNode is for a single character ->
                  self._cpMap  +:=  a UniChar instance representing
                      charNode and its entities
                  else -> I ]
        '''

The processing of the node and its subtree are performed by Section 6.28, “UniChar.__init__().

Some of the CHARACTER_N nodes in the file representing multiple characters. In such cases, the UniChar constructor will raise a ValueError. We can ignore those entries.

unidata.py
        #-- 1
        # [ if charNode represents a single-character code point ->
        #     self._cpMap  +:=  an entry whose key is that code point
        #         and the related value is a UniChar instance
        #         representing charNode
        #   else -> I ]
        try:
            uniChar = UniChar(self, charNode)
            self._cpMap[uniChar.cp] = uniChar
        except ValueError as x:
            pass