VirtKeyboard: add check_symbols method

This method allows one to verify, before any decoding attempt,
if all the symbols given as arguments can be found in the
virtual keyboard.

Signed-off-by: Pierre Mazière <pierre.maziere@gmail.com>
This commit is contained in:
Pierre Mazière 2011-11-04 10:10:23 +01:00
commit 2fdb2fe36a

View file

@ -101,6 +101,16 @@ class VirtKeyboard(object):
return i
raise VirtKeyboardError('Symbol not found')
def check_symbols(self,symbols,dirname):
# symbols: dictionary <symbol>:<md5 value>
for s in symbols.keys():
try:
self.get_symbol_code(symbols[s])
except VirtKeyboardError:
self.generate_MD5(dirname)
raise VirtKeyboardError("Symbol '%s' not found; all symbol hashes are available in %s"\
% (s,dirname))
def generate_MD5(self,dir):
for i in self.coords.keys():
width=self.coords[i][2]-self.coords[i][0]+1