mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-22 23:48:12 +00:00
pb2py: Use logging module instead of print
This commit is contained in:
parent
d32cbe3466
commit
4ec8b38d4a
16
tools/pb2py
16
tools/pb2py
@ -2,10 +2,11 @@
|
|||||||
# Converts Google's protobuf python definitions of TREZOR wire messages
|
# Converts Google's protobuf python definitions of TREZOR wire messages
|
||||||
# to plain-python objects as used in TREZOR Core and python-trezor
|
# to plain-python objects as used in TREZOR Core and python-trezor
|
||||||
|
|
||||||
import sys
|
|
||||||
import importlib
|
|
||||||
import os
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import importlib
|
||||||
|
import logging
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def import_pb2(name):
|
def import_pb2(name):
|
||||||
@ -42,7 +43,7 @@ def process_message_imports(descriptor):
|
|||||||
|
|
||||||
|
|
||||||
def process_message(descriptor, protobuf_module, msg_id, indexfile, is_upy):
|
def process_message(descriptor, protobuf_module, msg_id, indexfile, is_upy):
|
||||||
print(" * type %s" % descriptor.name)
|
logging.debug("Processing message %s", descriptor.name)
|
||||||
|
|
||||||
if is_upy:
|
if is_upy:
|
||||||
yield "import protobuf as p"
|
yield "import protobuf as p"
|
||||||
@ -112,7 +113,7 @@ def process_message(descriptor, protobuf_module, msg_id, indexfile, is_upy):
|
|||||||
|
|
||||||
|
|
||||||
def process_enum(descriptor, is_upy):
|
def process_enum(descriptor, is_upy):
|
||||||
print(" * enum %s" % descriptor.name)
|
logging.debug("Processing enum %s", descriptor.name)
|
||||||
|
|
||||||
if is_upy:
|
if is_upy:
|
||||||
yield "from micropython import const"
|
yield "from micropython import const"
|
||||||
@ -134,8 +135,7 @@ def process_enum(descriptor, is_upy):
|
|||||||
|
|
||||||
|
|
||||||
def process_file(descriptor, protobuf_module, genpath, indexfile, modlist, is_upy):
|
def process_file(descriptor, protobuf_module, genpath, indexfile, modlist, is_upy):
|
||||||
|
logging.info("Processing module %s", descriptor.name)
|
||||||
print("Processing module %s" % descriptor.name)
|
|
||||||
|
|
||||||
msg_types = import_pb2('messages').MessageType
|
msg_types = import_pb2('messages').MessageType
|
||||||
|
|
||||||
@ -167,6 +167,8 @@ def write_to_file(genpath, t, out):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
logging.basicConfig(level=logging.DEBUG)
|
||||||
|
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('module', help="Name of module to generate")
|
parser.add_argument('module', help="Name of module to generate")
|
||||||
parser.add_argument('genpath', help="Directory for generated source code")
|
parser.add_argument('genpath', help="Directory for generated source code")
|
||||||
|
Loading…
Reference in New Issue
Block a user