| 34 | |
| 35 | |
| 36 | class ColorizedOutput(object): # for pretty printing |
| 37 | |
| 38 | def __init__(self, orig_out, color): |
| 39 | self.orig_out = orig_out |
| 40 | self.color = color |
| 41 | |
| 42 | def __getattr__(self, attr): |
| 43 | def_color = '\033[0;0m' # resets all terminal attributes |
| 44 | |
| 45 | if attr == 'write': |
| 46 | return lambda x: self.orig_out.write(self.color + x + def_color) |
| 47 | else: |
| 48 | return getattr(self.orig_out, attr) |
| 49 | |
| 50 | |
| 51 | class CLI(object): |