Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Unified Diff: tools/json_schema_compiler/code.py

Issue 1488773003: Add js_interface_generator for generating extensions interfaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase + shorten line Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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.
"""
« no previous file with comments | « no previous file | tools/json_schema_compiler/compiler.py » ('j') | tools/json_schema_compiler/js_externs_generator_test.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698