mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-13 19:18:56 +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):
|
||||
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):
|
||||
|
Loading…
Reference in New Issue
Block a user