MCPcopy Create free account
hub / github.com/ampproject/amphtml / OutputFormatter

Class OutputFormatter

validator/validator_gen_js.py:56–74  ·  view source on GitHub ↗

Helper class for indenting lines.

Source from the content-addressed store, hash-verified

54
55
56class 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
77class MessageKey(object):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected