Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 1 | from xos.logger import Logger, logging, logger |
| 2 | |
Matteo Scandolo | ceccb1f | 2017-06-05 10:35:44 -0700 | [diff] [blame] | 3 | |
Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 4 | class ErrorMapper: |
Matteo Scandolo | ceccb1f | 2017-06-05 10:35:44 -0700 | [diff] [blame] | 5 | def __init__(self, error_map_file): |
| 6 | self.error_map = {} |
| 7 | try: |
| 8 | error_map_lines = open(error_map_file).read().splitlines() |
| 9 | for l in error_map_lines: |
| 10 | if (not l.startswith('#')): |
| 11 | splits = l.split('->') |
| 12 | k, v = map(lambda i: i.rstrip(), splits) |
| 13 | self.error_map[k] = v |
| 14 | except: |
| 15 | logging.info('Could not read error map') |
Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 16 | |
Matteo Scandolo | ceccb1f | 2017-06-05 10:35:44 -0700 | [diff] [blame] | 17 | def map(self, error): |
| 18 | return self.error_map[error] |