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

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: Windows-specific fixes Created 4 years, 4 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..7c3721ad9a25e477804442937da7bcc51a9ac5bf
--- /dev/null
+++ b/third_party/dom_distiller_js/protoc_plugins/util/plugin.py
@@ -0,0 +1,50 @@
+# Copyright 2016 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('_'))
+
+
+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 SetBinaryStdio():
+ import platform
+ if platform.system() == 'Windows':
+ import os, sys, msvcrt
+ msvcrt.setmode(sys.stdin.fileno(), os.O_BINARY)
+ msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
+
+
+def ReadRequestFromStdin():
+ SetBinaryStdio()
+ data = sys.stdin.read()
+ return plugin_protos.PluginRequestFromString(data)

Powered by Google App Engine
This is Rietveld 408576698