コード例 #1
0
    def next(self):
        if not hasattr(self, "_fileIterator"):
            if not self.quiet:
                print >>sys.stderr, "FILE: reading '%s'" % self.filePath
            fileHandle = codecs.open(self.filePath, "r", default_encoding)
            self._fileIterator = UnicodeCSVFileIterator(fileHandle)

        while True:
            char, decompString, glyph, _, flags = self._fileIterator.next()
            if len(char) > 1:
                # pseudo char
                if not char.startswith("#"):
                    print >>sys.stderr, ("FILE: Error parsing entry '%s', %s" % (char, glyph)).encode(default_encoding)
                    continue
                else:
                    char = int(char[1:])

            decomposition = CharacterLookup.decompositionFromString(decompString)
            return (char, int(glyph), decomposition, set(flags))
コード例 #2
0
    def next(self):
        if not hasattr(self, '_fileIterator'):
            if not self.quiet:
                print >> sys.stderr, "FILE: reading '%s'" % self.filePath
            fileHandle = codecs.open(self.filePath, 'r', default_encoding)
            self._fileIterator = UnicodeCSVFileIterator(fileHandle)

        while True:
            char, decompString, glyph, _, flags = self._fileIterator.next()
            if len(char) > 1:
                # pseudo char
                if not char.startswith('#'):
                    print >> sys.stderr, (
                        "FILE: Error parsing entry '%s', %s" %
                        (char, glyph)).encode(default_encoding)
                    continue
                else:
                    char = int(char[1:])

            decomposition = CharacterLookup.decompositionFromString(
                decompString)
            return (char, int(glyph), decomposition, set(flags))
コード例 #3
0
    def _getDecompositionEntriesDict(cls):
        """
        Gets the decomposition table from the database.

        @rtype: dict
        @return: dictionary with key pair character, I{glyph} and the first
            layer decomposition as value with the entry's flag
        """
        decompDict = {}
        # get entries from database
        db = dbconnector.getDBConnector()
        table = db.tables['CharacterDecomposition']

        result = db.selectRows(select([table.c.ChineseCharacter,
            table.c.Glyph, table.c.Decomposition, table.c.Flags])\
                .order_by(table.c.SubIndex))
        entries = []
        for char, glyph, decompString, flags in result:
            decomposition = CharacterLookup.decompositionFromString(
                decompString)
            entries.append((char, glyph, decomposition, set(flags)))

        return entries
コード例 #4
0
    def _getDecompositionEntriesDict(cls):
        """
        Gets the decomposition table from the database.

        @rtype: dict
        @return: dictionary with key pair character, I{glyph} and the first
            layer decomposition as value with the entry's flag
        """
        decompDict = {}
        # get entries from database
        db = dbconnector.getDBConnector()
        table = db.tables["CharacterDecomposition"]

        result = db.selectRows(
            select([table.c.ChineseCharacter, table.c.Glyph, table.c.Decomposition, table.c.Flags]).order_by(
                table.c.SubIndex
            )
        )
        entries = []
        for char, glyph, decompString, flags in result:
            decomposition = CharacterLookup.decompositionFromString(decompString)
            entries.append((char, glyph, decomposition, set(flags)))

        return entries