| OLD | NEW |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """ | 5 """ |
| 6 Provides simple state-less wrappers of the proto types used by plugins. | 6 Provides simple state-less wrappers of the proto types used by plugins. |
| 7 | 7 |
| 8 See https://developers.google.com/protocol-buffers/docs/reference/cpp/google.pro
tobuf.descriptor.pb | 8 See https://developers.google.com/protocol-buffers/docs/reference/cpp/google.pro
tobuf.descriptor.pb |
| 9 and https://developers.google.com/protocol-buffers/docs/reference/cpp/google.pro
tobuf.compiler.plugin.pb | 9 and https://developers.google.com/protocol-buffers/docs/reference/cpp/google.pro
tobuf.compiler.plugin.pb |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 import os | 12 import os |
| 13 import sys | 13 import sys |
| 14 | 14 |
| 15 SCRIPT_DIR = os.path.dirname(__file__) |
| 16 SRC_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, '..', '..', '..', '..')) |
| 17 |
| 18 sys.path.insert( |
| 19 1, os.path.join(SRC_DIR, 'third_party', 'protobuf', 'python')) |
| 20 sys.path.insert( |
| 21 1, os.path.join(SRC_DIR, 'third_party', 'protobuf', 'third_party', 'six')) |
| 15 from google.protobuf.descriptor_pb2 import FieldDescriptorProto | 22 from google.protobuf.descriptor_pb2 import FieldDescriptorProto |
| 16 | 23 |
| 17 import plugin | 24 import plugin |
| 18 import types | 25 import types |
| 19 | 26 |
| 20 sys.path.insert( | 27 sys.path.insert( |
| 21 1, os.path.join(os.path.dirname(__file__), '..', '..', | 28 1, os.path.join(SRC_DIR, 'third_party', 'dom_distiller_js', 'dist', 'python'
)) |
| 22 'dist', 'python')) | |
| 23 import plugin_pb2 | 29 import plugin_pb2 |
| 24 | 30 |
| 25 | 31 |
| 26 class PluginRequest(object): | 32 class PluginRequest(object): |
| 27 def __init__(self, proto): | 33 def __init__(self, proto): |
| 28 self.proto = proto | 34 self.proto = proto |
| 29 | 35 |
| 30 def GetArgs(self): | 36 def GetArgs(self): |
| 31 return dict((v.split('=') for v in self.proto.parameter.split(','))) | 37 return dict((v.split('=') for v in self.proto.parameter.split(','))) |
| 32 | 38 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 def GetName(self): | 281 def GetName(self): |
| 276 return self.proto.name | 282 return self.proto.name |
| 277 | 283 |
| 278 def GetValue(self): | 284 def GetValue(self): |
| 279 return self.proto.number | 285 return self.proto.number |
| 280 | 286 |
| 281 def CheckSupported(self): | 287 def CheckSupported(self): |
| 282 if self.proto.HasField('options'): | 288 if self.proto.HasField('options'): |
| 283 return 'Enum value options are not supported: {} {}'.format( | 289 return 'Enum value options are not supported: {} {}'.format( |
| 284 self.proto.name, self.proto.value) | 290 self.proto.name, self.proto.value) |
| OLD | NEW |