Index: tools/json_schema_compiler/code.py |
diff --git a/tools/json_schema_compiler/code.py b/tools/json_schema_compiler/code.py |
index e454e5d444039808553ae73e2f74823f81133fb3..d637026d6d0db88aaf950ac5d0dc9c673fbc4929 100644 |
--- a/tools/json_schema_compiler/code.py |
+++ b/tools/json_schema_compiler/code.py |
@@ -29,8 +29,11 @@ class Code(object): |
strip_right: whether or not trailing whitespace should be stripped. |
""" |
- prefix = indent_level * ' ' if indent_level else ''.join( |
- self._line_prefixes) |
+ if line: |
+ prefix = indent_level * ' ' if indent_level else ''.join( |
+ self._line_prefixes) |
+ else: |
+ prefix = '' |
if strip_right: |
line = line.rstrip() |
@@ -170,6 +173,14 @@ class Code(object): |
self._code[i].substitute = False |
return self |
+ def TrimTrailingNewlines(self): |
+ """Trims any trailing newlines. |
Dan Beam
2015/12/10 22:17:33
i'm confused by this code, but have you seen rstri
stevenjb
2015/12/10 22:29:04
self._code is an array of Line objects. This remov
|
+ """ |
+ while self._code: |
+ if self._code[-1].value != '': |
+ return |
+ self._code = self._code[:-1] |
+ |
def Render(self): |
"""Renders Code as a string. |
""" |