fail gracefully if unihan.db is not available

This commit is contained in:
Damien Elmes 2009-01-04 13:13:53 +09:00
parent 6ce63b4889
commit 73767124d8

View file

@ -57,11 +57,14 @@ class ChineseGenerator(object):
self.unihan = None self.unihan = None
def toReading(self, type, val): def toReading(self, type, val):
try:
if not self.unihan: if not self.unihan:
self.unihan = UnihanController(type) self.unihan = UnihanController(type)
else: else:
self.unihan.type = type self.unihan.type = type
return self.unihan.reading(val) return self.unihan.reading(val)
except:
return u""
unihan = ChineseGenerator() unihan = ChineseGenerator()