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))
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))
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
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