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

Side by Side Diff: third_party/dom_distiller_js/protoc_plugins/util/plugin_protos.py

Issue 2935953002: Fix protobuf's Python runtime and imports.
Patch Set: debug import path Created 3 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 unified diff | Download patch
« no previous file with comments | « third_party/dom_distiller_js/BUILD.gn ('k') | third_party/protobuf/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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__) 15 PYPROTO_DIR = os.path.abspath('pyproto')
16 SRC_DIR = os.path.abspath(os.path.join(SCRIPT_DIR, '..', '..', '..', '..')) 16 sys.path.insert(0, PYPROTO_DIR)
17 import google.protobuf
17 18
18 sys.path.insert( 19 FOO = os.path.abspath( \
19 1, os.path.join(SRC_DIR, 'third_party', 'protobuf', 'python')) 20 os.path.join(os.path.dirname(google.protobuf.__file__), '..', '..'))
20 sys.path.insert( 21 if PYPROTO_DIR != FOO:
21 1, os.path.join(SRC_DIR, 'third_party', 'protobuf', 'third_party', 'six')) 22 print >> sys.stderr, 'PYPROTO_DIR = ' + PYPROTO_DIR
23 print >> sys.stderr, 'FOO = ' + FOO
24 assert False
25
26 from google.protobuf.compiler import plugin_pb2
22 from google.protobuf.descriptor_pb2 import FieldDescriptorProto 27 from google.protobuf.descriptor_pb2 import FieldDescriptorProto
23 28
24 from . import types 29 from . import types
25 30
26 sys.path.insert(
27 1, os.path.join(SRC_DIR,
28 'third_party', 'dom_distiller_js', 'dist', 'python'))
29 import plugin_pb2
30
31 31
32 class PluginRequest(object): 32 class PluginRequest(object):
33 def __init__(self, proto): 33 def __init__(self, proto):
34 self.proto = proto 34 self.proto = proto
35 35
36 def GetArgs(self): 36 def GetArgs(self):
37 return dict((v.split('=') for v in self.proto.parameter.split(','))) 37 return dict((v.split('=') for v in self.proto.parameter.split(',')))
38 38
39 def GetAllFiles(self): 39 def GetAllFiles(self):
40 files = map(ProtoFile, self.proto.proto_file) 40 files = map(ProtoFile, self.proto.proto_file)
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 def GetName(self): 283 def GetName(self):
284 return self.proto.name 284 return self.proto.name
285 285
286 def GetValue(self): 286 def GetValue(self):
287 return self.proto.number 287 return self.proto.number
288 288
289 def CheckSupported(self): 289 def CheckSupported(self):
290 if self.proto.HasField('options'): 290 if self.proto.HasField('options'):
291 return 'Enum value options are not supported: {} {}'.format( 291 return 'Enum value options are not supported: {} {}'.format(
292 self.proto.name, self.proto.value) 292 self.proto.name, self.proto.value)
OLDNEW
« no previous file with comments | « third_party/dom_distiller_js/BUILD.gn ('k') | third_party/protobuf/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698