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

Unified Diff: third_party/dom_distiller_js/protoc_plugins/util/plugin.py

Issue 2034373002: Generate the proto JSON converter for DOM distiller (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months 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: third_party/dom_distiller_js/protoc_plugins/util/plugin.py
diff --git a/third_party/dom_distiller_js/protoc_plugins/util/plugin.py b/third_party/dom_distiller_js/protoc_plugins/util/plugin.py
new file mode 100644
index 0000000000000000000000000000000000000000..2c91579706485bd31f97cf92ff9a38c515eb12fa
--- /dev/null
+++ b/third_party/dom_distiller_js/protoc_plugins/util/plugin.py
@@ -0,0 +1,41 @@
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import sys
+
+import plugin_protos
+import types
+
+
+def Debug(data):
+ sys.stderr.write(str(data))
+ sys.stderr.write('\n')
+ sys.stderr.flush()
+
+
+def TitleCase(s):
+ return ''.join((p[0].upper() + p[1:] for p in s.split('_')))
nyquist 2016/06/14 00:48:11 Do you need the inner parenthesis here?
wychen 2016/08/07 09:16:27 Done.
+
+
+def Indented(s, indent=2):
+ return '\n'.join((' ' * indent) + p for p in s.rstrip('\n').split('\n'))
+
+
+proto_path_to_file_map = {}
+
+
+def RegisterProtoFile(proto_file):
+ proto_path_to_file_map[proto_file.Filename()] = proto_file
+ types.RegisterTypesForFile(proto_file)
+
+
+def GetProtoFileForFilename(filename):
+ proto_file = proto_path_to_file_map[filename]
+ assert proto_file
+ return proto_file
+
+
+def ReadRequestFromStdin():
+ data = sys.stdin.read()
+ return plugin_protos.PluginRequestFromString(data)

Powered by Google App Engine
This is Rietveld 408576698