mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 20:11:00 +00:00
protobuf: drop kwargs from constructors
This commit is contained in:
parent
b502169bae
commit
c6ac4f2200
19
tools/pb2py
19
tools/pb2py
@ -76,16 +76,17 @@ def process_message_imports(descriptor):
|
|||||||
def create_init_method(fields):
|
def create_init_method(fields):
|
||||||
yield " def __init__("
|
yield " def __init__("
|
||||||
yield " self,"
|
yield " self,"
|
||||||
for field in fields:
|
for field in fields[:-1]:
|
||||||
yield " %s: %s = None," % (field.name, field.py_type)
|
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:"
|
yield " ) -> None:"
|
||||||
|
|
||||||
for field in fields:
|
for field in fields:
|
||||||
if field.repeated:
|
if field.repeated:
|
||||||
yield " self.{0} = {0} if {0} is not None else []".format(field.name)
|
yield " self.{0} = {0} if {0} is not None else []".format(field.name)
|
||||||
else:
|
else:
|
||||||
yield " self.{0} = {0}".format(field.name)
|
yield " self.{0} = {0}".format(field.name)
|
||||||
yield " super().__init__(**kwargs)"
|
|
||||||
|
|
||||||
|
|
||||||
def process_message(descriptor, protobuf_module, msg_id, is_upy):
|
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 ""
|
||||||
yield "class %s(p.MessageType):" % descriptor.name
|
yield "class %s(p.MessageType):" % descriptor.name
|
||||||
|
|
||||||
|
if msg_id is not None:
|
||||||
|
yield " MESSAGE_WIRE_TYPE = %d" % msg_id
|
||||||
|
|
||||||
if fields:
|
if fields:
|
||||||
yield " FIELDS = {"
|
yield " FIELDS = {"
|
||||||
for field in 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 " %d: ('%s', %s, %s),%s" % (field.number, field.name, field.proto_type, flags, comment)
|
||||||
|
|
||||||
yield " }"
|
yield " }"
|
||||||
|
yield ""
|
||||||
|
yield from create_init_method(fields)
|
||||||
|
|
||||||
if msg_id is not None:
|
if not fields and not msg_id:
|
||||||
yield " MESSAGE_WIRE_TYPE = %d" % msg_id
|
yield " pass"
|
||||||
|
|
||||||
yield ""
|
|
||||||
yield from create_init_method(fields)
|
|
||||||
|
|
||||||
|
|
||||||
def process_enum(descriptor, is_upy):
|
def process_enum(descriptor, is_upy):
|
||||||
|
Loading…
Reference in New Issue
Block a user