| 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..76e31bccfa5f3406c54f1a0f572a82875df6d1a8 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(
|
| + 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
|
| + """
|
| + while len(self._code) > 0:
|
| + if self._code[-1].value != '':
|
| + return
|
| + self._code = self._code[:-1]
|
| +
|
| def Render(self):
|
| """Renders Code as a string.
|
| """
|
|
|