Chromium Code Reviews| 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) |