1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

pb2py: properly handle nested messages and enums

This commit is contained in:
matejcik 2018-07-04 17:07:37 +02:00
parent 000d832632
commit 1b9b7d6c8e

View File

@ -116,6 +116,8 @@ class Descriptor:
for file in self.files: for file in self.files:
self.messages += file.message_type self.messages += file.message_type
self.enums += file.enum_type self.enums += file.enum_type
for message in file.message_type:
self._nested_types_from_message(message)
if not self.messages and not self.enums: if not self.messages and not self.enums:
raise RuntimeError("No messages and no enums found.") raise RuntimeError("No messages and no enums found.")
@ -125,6 +127,12 @@ class Descriptor:
self.out_dir = None self.out_dir = None
def _nested_types_from_message(self, message):
self.messages += message.nested_type
self.enums += message.enum_type
for nested in message.nested_type:
self._nested_types_from_message(nested)
def find_message_types(self, message_type): def find_message_types(self, message_type):
message_types = {} message_types = {}
try: try: