| 2 | from __future__ import unicode_literals |
| 3 | |
| 4 | class extendtable(object): |
| 5 | |
| 6 | # TODO check the possiblility if the encoding is not utf-8 |
| 7 | encoding = 'utf-8' |
| 8 | |
| 9 | def __init__(self, fs): |
| 10 | |
| 11 | self.chardefs = {} |
| 12 | |
| 13 | for line in fs: |
| 14 | |
| 15 | line = line.strip() |
| 16 | |
| 17 | key, root = safeSplit(line) |
| 18 | key = key.lower().strip() |
| 19 | root = root.strip() |
| 20 | |
| 21 | try: |
| 22 | self.chardefs[key].append(root) |
| 23 | except KeyError: |
| 24 | self.chardefs[key] = [root] |
| 25 | |
| 26 | def __del__(self): |
| 27 | del self.chardefs |
| 28 | self.chardefs = {} |
| 29 | |
| 30 | def isInCharDef(self, key): |
| 31 | return key in self.chardefs |
| 32 | |
| 33 | def getCharDef(self, key): |
| 34 | """ |
| 35 | will return a list conaining all possible result |
| 36 | """ |
| 37 | return self.chardefs[key] |
| 38 | |
| 39 | |
| 40 | def safeSplit(line): |
no outgoing calls
no test coverage detected