|
|
|
@ -76,16 +76,17 @@ def process_message_imports(descriptor):
|
|
|
|
|
def create_init_method(fields):
|
|
|
|
|
yield " def __init__("
|
|
|
|
|
yield " self,"
|
|
|
|
|
for field in fields:
|
|
|
|
|
for field in fields[:-1]:
|
|
|
|
|
yield " %s: %s = None," % (field.name, field.py_type)
|
|
|
|
|
yield " **kwargs"
|
|
|
|
|
# last field must not have a traling comma
|
|
|
|
|
yield " %s: %s = None" % (fields[-1].name, fields[-1].py_type)
|
|
|
|
|
yield " ) -> None:"
|
|
|
|
|
|
|
|
|
|
for field in fields:
|
|
|
|
|
if field.repeated:
|
|
|
|
|
yield " self.{0} = {0} if {0} is not None else []".format(field.name)
|
|
|
|
|
else:
|
|
|
|
|
yield " self.{0} = {0}".format(field.name)
|
|
|
|
|
yield " super().__init__(**kwargs)"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def process_message(descriptor, protobuf_module, msg_id, is_upy):
|
|
|
|
@ -113,6 +114,9 @@ def process_message(descriptor, protobuf_module, msg_id, is_upy):
|
|
|
|
|
yield ""
|
|
|
|
|
yield "class %s(p.MessageType):" % descriptor.name
|
|
|
|
|
|
|
|
|
|
if msg_id is not None:
|
|
|
|
|
yield " MESSAGE_WIRE_TYPE = %d" % msg_id
|
|
|
|
|
|
|
|
|
|
if fields:
|
|
|
|
|
yield " FIELDS = {"
|
|
|
|
|
for field in fields:
|
|
|
|
@ -135,12 +139,11 @@ def process_message(descriptor, protobuf_module, msg_id, is_upy):
|
|
|
|
|
yield " %d: ('%s', %s, %s),%s" % (field.number, field.name, field.proto_type, flags, comment)
|
|
|
|
|
|
|
|
|
|
yield " }"
|
|
|
|
|
yield ""
|
|
|
|
|
yield from create_init_method(fields)
|
|
|
|
|
|
|
|
|
|
if msg_id is not None:
|
|
|
|
|
yield " MESSAGE_WIRE_TYPE = %d" % msg_id
|
|
|
|
|
|
|
|
|
|
yield ""
|
|
|
|
|
yield from create_init_method(fields)
|
|
|
|
|
if not fields and not msg_id:
|
|
|
|
|
yield " pass"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def process_enum(descriptor, is_upy):
|
|
|
|
|