"TYPE = %d" => "t.type = %d"

pull/25/head
slush0 8 years ago committed by Pavol Rusnak
parent 20e426e846
commit 3f9020ccf4
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -5,11 +5,14 @@ import os
from google.protobuf.internal.enum_type_wrapper import EnumTypeWrapper
def process_type(t, cls):
def process_type(t, cls, msg_id):
imports = ["from protobuf import protobuf as p",]
out = ["t = p.MessageType()", ]
if msg_id is not None:
out.append("t.type = const(%d)" % msg_id)
print(" * type %s" % t)
TYPE_STRING = 9
@ -113,12 +116,10 @@ def process_module(mod, genpath):
msg_types = __import__('pb2', globals(), locals(), ['messages_pb2', ]).messages_pb2.MessageType.items()
for t, cls in types.iteritems():
out = process_type(t, cls)
# Find message type for given class
msg_id = find_msg_type(msg_types, t)
if msg_id is not None:
out.append('TYPE = const(%d)' % msg_id)
out = process_type(t, cls, msg_id)
write_to_file(genpath, t, out)

Loading…
Cancel
Save