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
def toReading(self, type, val):
if not self.unihan:
self.unihan = UnihanController(type)
else:
self.unihan.type = type
return self.unihan.reading(val)
try:
if not self.unihan:
self.unihan = UnihanController(type)
else:
self.unihan.type = type
return self.unihan.reading(val)
except:
return u""
unihan = ChineseGenerator()