本文整理匯總了Python中google.protobuf.text_format.MergeLines方法的典型用法代碼示例。如果您正苦於以下問題:Python text_format.MergeLines方法的具體用法?Python text_format.MergeLines怎麽用?Python text_format.MergeLines使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類google.protobuf.text_format
的用法示例。
在下文中一共展示了text_format.MergeLines方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testMergeLinesGolden
# 需要導入模塊: from google.protobuf import text_format [as 別名]
# 或者: from google.protobuf.text_format import MergeLines [as 別名]
def testMergeLinesGolden(self):
opened = self.ReadGolden('text_format_unittest_data_oneof_implemented.txt')
parsed_message = unittest_pb2.TestAllTypes()
r = text_format.MergeLines(opened, parsed_message)
self.assertIs(r, parsed_message)
message = unittest_pb2.TestAllTypes()
test_util.SetAllFields(message)
self.assertEqual(message, parsed_message)
示例2: testMergeLinesGolden
# 需要導入模塊: from google.protobuf import text_format [as 別名]
# 或者: from google.protobuf.text_format import MergeLines [as 別名]
def testMergeLinesGolden(self):
opened = self.ReadGolden('text_format_unittest_data.txt')
parsed_message = unittest_pb2.TestAllTypes()
r = text_format.MergeLines(opened, parsed_message)
self.assertIs(r, parsed_message)
message = unittest_pb2.TestAllTypes()
test_util.SetAllFields(message)
self.assertEqual(message, parsed_message)
示例3: from_pbtxt_file
# 需要導入模塊: from google.protobuf import text_format [as 別名]
# 或者: from google.protobuf.text_format import MergeLines [as 別名]
def from_pbtxt_file(spec_path):
"""Loads a spec encoded as a struct_pb2.StructuredValue from a pbtxt file."""
spec_proto = struct_pb2.StructuredValue()
with tf.io.gfile.GFile(spec_path, "rb") as f:
text_format.MergeLines(f, spec_proto)
return from_proto(spec_proto)