Helper class for indenting lines.
| 54 | |
| 55 | |
| 56 | class OutputFormatter(object): |
| 57 | """Helper class for indenting lines.""" |
| 58 | |
| 59 | def __init__(self, lines): |
| 60 | """Initializes the indenter with indent 0.""" |
| 61 | self.lines = lines |
| 62 | self.indent_by_ = [0] |
| 63 | |
| 64 | def PushIndent(self, indent): |
| 65 | """Pushes a particular indent onto the stack.""" |
| 66 | self.indent_by_.append(self.indent_by_[-1] + indent) |
| 67 | |
| 68 | def PopIndent(self): |
| 69 | """Pops a particular indent from the stack, reverting to the previous.""" |
| 70 | self.indent_by_.pop() |
| 71 | |
| 72 | def Line(self, line): |
| 73 | """Adds a line to self.lines, applying the indent.""" |
| 74 | self.lines.append('%s%s' % (' ' * self.indent_by_[-1], line)) |
| 75 | |
| 76 | |
| 77 | class MessageKey(object): |
no outgoing calls
no test coverage detected