Convert protobuf message to text format. Double values can be formatted compactly with 15 digits of precision (which is the most that IEEE 754 "double" can guarantee) using double_format='.15g'. To ensure that converting to text and back to a proto will result in an identical value, double_
(
message,
as_utf8=False,
as_one_line=False,
use_short_repeated_primitives=False,
pointy_brackets=False,
use_index_order=False,
float_format=None,
double_format=None,
use_field_number=False,
descriptor_pool=None,
indent=0,
message_formatter=None,
print_unknown_fields=False,
force_colon=False)
| 111 | |
| 112 | |
| 113 | def MessageToString( |
| 114 | message, |
| 115 | as_utf8=False, |
| 116 | as_one_line=False, |
| 117 | use_short_repeated_primitives=False, |
| 118 | pointy_brackets=False, |
| 119 | use_index_order=False, |
| 120 | float_format=None, |
| 121 | double_format=None, |
| 122 | use_field_number=False, |
| 123 | descriptor_pool=None, |
| 124 | indent=0, |
| 125 | message_formatter=None, |
| 126 | print_unknown_fields=False, |
| 127 | force_colon=False): |
| 128 | # type: (...) -> str |
| 129 | """Convert protobuf message to text format. |
| 130 | |
| 131 | Double values can be formatted compactly with 15 digits of |
| 132 | precision (which is the most that IEEE 754 "double" can guarantee) |
| 133 | using double_format='.15g'. To ensure that converting to text and back to a |
| 134 | proto will result in an identical value, double_format='.17g' should be used. |
| 135 | |
| 136 | Args: |
| 137 | message: The protocol buffers message. |
| 138 | as_utf8: Return unescaped Unicode for non-ASCII characters. |
| 139 | In Python 3 actual Unicode characters may appear as is in strings. |
| 140 | In Python 2 the return value will be valid UTF-8 rather than only ASCII. |
| 141 | as_one_line: Don't introduce newlines between fields. |
| 142 | use_short_repeated_primitives: Use short repeated format for primitives. |
| 143 | pointy_brackets: If True, use angle brackets instead of curly braces for |
| 144 | nesting. |
| 145 | use_index_order: If True, fields of a proto message will be printed using |
| 146 | the order defined in source code instead of the field number, extensions |
| 147 | will be printed at the end of the message and their relative order is |
| 148 | determined by the extension number. By default, use the field number |
| 149 | order. |
| 150 | float_format (str): If set, use this to specify float field formatting |
| 151 | (per the "Format Specification Mini-Language"); otherwise, shortest float |
| 152 | that has same value in wire will be printed. Also affect double field |
| 153 | if double_format is not set but float_format is set. |
| 154 | double_format (str): If set, use this to specify double field formatting |
| 155 | (per the "Format Specification Mini-Language"); if it is not set but |
| 156 | float_format is set, use float_format. Otherwise, use ``str()`` |
| 157 | use_field_number: If True, print field numbers instead of names. |
| 158 | descriptor_pool (DescriptorPool): Descriptor pool used to resolve Any types. |
| 159 | indent (int): The initial indent level, in terms of spaces, for pretty |
| 160 | print. |
| 161 | message_formatter (function(message, indent, as_one_line) -> unicode|None): |
| 162 | Custom formatter for selected sub-messages (usually based on message |
| 163 | type). Use to pretty print parts of the protobuf for easier diffing. |
| 164 | print_unknown_fields: If True, unknown fields will be printed. |
| 165 | force_colon: If set, a colon will be added after the field name even if the |
| 166 | field is a proto message. |
| 167 | |
| 168 | Returns: |
| 169 | str: A string of the text formatted protocol buffer message. |
| 170 | """ |
no test coverage detected