mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-23 07:58:09 +00:00
messages_map: Fix Flake8 warnings
This commit is contained in:
parent
88230e33c4
commit
69356e5f56
@ -1,7 +1,10 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from messages_pb2 import MessageType
|
from messages_pb2 import MessageType
|
||||||
from types_pb2 import wire_in, wire_out, wire_debug_in, wire_debug_out, wire_tiny, wire_bootloader
|
|
||||||
|
from types_pb2 import wire_in, wire_out
|
||||||
|
from types_pb2 import wire_debug_in, wire_debug_out
|
||||||
|
from types_pb2 import wire_bootloader, wire_tiny
|
||||||
|
|
||||||
# len("MessageType_MessageType_") - len("_fields") == 17
|
# len("MessageType_MessageType_") - len("_fields") == 17
|
||||||
TEMPLATE = "\t{{ {type} {dir} {msg_id:46} {fields:29} {process_func} }},"
|
TEMPLATE = "\t{{ {type} {dir} {msg_id:46} {fields:29} {process_func} }},"
|
||||||
@ -13,6 +16,7 @@ LABELS = {
|
|||||||
wire_debug_out: "debug out messages",
|
wire_debug_out: "debug out messages",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def handle_message(message, extension):
|
def handle_message(message, extension):
|
||||||
name = message.name
|
name = message.name
|
||||||
short_name = name.split("MessageType_", 1).pop()
|
short_name = name.split("MessageType_", 1).pop()
|
||||||
@ -32,15 +36,22 @@ def handle_message(message, extension):
|
|||||||
if tiny:
|
if tiny:
|
||||||
return '\t// Message %s is used in tiny mode' % short_name
|
return '\t// Message %s is used in tiny mode' % short_name
|
||||||
|
|
||||||
|
if direction == "i":
|
||||||
|
process_func = "(void (*)(void *)) fsm_msg%s" % short_name
|
||||||
|
else:
|
||||||
|
process_func = "0"
|
||||||
|
|
||||||
return TEMPLATE.format(
|
return TEMPLATE.format(
|
||||||
type="'%c'," % interface,
|
type="'%c'," % interface,
|
||||||
dir="'%c'," % direction,
|
dir="'%c'," % direction,
|
||||||
msg_id="MessageType_%s," % name,
|
msg_id="MessageType_%s," % name,
|
||||||
fields="%s_fields," % short_name,
|
fields="%s_fields," % short_name,
|
||||||
process_func = "(void (*)(void *)) fsm_msg%s" % short_name if direction == "i" else "0"
|
process_func=process_func,
|
||||||
)
|
)
|
||||||
|
|
||||||
print('\t// This file is automatically generated by messages_map.py -- DO NOT EDIT!')
|
|
||||||
|
print("\t// This file is automatically generated"
|
||||||
|
"by messages_map.py -- DO NOT EDIT!")
|
||||||
|
|
||||||
messages = defaultdict(list)
|
messages = defaultdict(list)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user