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

protobuf text_format now prints in both binary and hex form

This commit is contained in:
slush0 2014-02-01 11:57:59 +01:00
parent 2782655320
commit eb22fad568

View File

@ -90,9 +90,8 @@ def monkeypatch_google_protobuf_text_format():
def _customPrintFieldValue(field, value, out, indent=0, as_utf8=False, as_one_line=False):
if field.cpp_type == google.protobuf.descriptor.FieldDescriptor.CPPTYPE_STRING and \
str(field.GetOptions()).strip() == '[binary]:': # binary option set
_oldPrintFieldValue(field, 'hex(%s) str(%s)' % (binascii.hexlify(value), value), out, indent, as_utf8, as_one_line)
'[binary]:' in str(field.GetOptions()).strip(): # binary option set
_oldPrintFieldValue(field, 'hex(%s) | str(%s)' % (binascii.hexlify(value), value), out, indent, as_utf8, as_one_line)
else:
_oldPrintFieldValue(field, value, out, indent, as_utf8, as_one_line)