本文整理汇总了Python中google.protobuf.internal.containers.ScalarMap方法的典型用法代码示例。如果您正苦于以下问题:Python containers.ScalarMap方法的具体用法?Python containers.ScalarMap怎么用?Python containers.ScalarMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类google.protobuf.internal.containers
的用法示例。
在下文中一共展示了containers.ScalarMap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _GetInitializeDefaultForMap
# 需要导入模块: from google.protobuf.internal import containers [as 别名]
# 或者: from google.protobuf.internal.containers import ScalarMap [as 别名]
def _GetInitializeDefaultForMap(field):
if field.label != _FieldDescriptor.LABEL_REPEATED:
raise ValueError('map_entry set on non-repeated field %s' % (
field.name))
fields_by_name = field.message_type.fields_by_name
key_checker = type_checkers.GetTypeChecker(fields_by_name['key'])
value_field = fields_by_name['value']
if _IsMessageMapField(field):
def MakeMessageMapDefault(message):
return containers.MessageMap(
message._listener_for_children, value_field.message_type, key_checker,
field.message_type)
return MakeMessageMapDefault
else:
value_checker = type_checkers.GetTypeChecker(value_field)
def MakePrimitiveMapDefault(message):
return containers.ScalarMap(
message._listener_for_children, key_checker, value_checker,
field.message_type)
return MakePrimitiveMapDefault
示例2: _GetInitializeDefaultForMap
# 需要导入模块: from google.protobuf.internal import containers [as 别名]
# 或者: from google.protobuf.internal.containers import ScalarMap [as 别名]
def _GetInitializeDefaultForMap(field):
if field.label != _FieldDescriptor.LABEL_REPEATED:
raise ValueError('map_entry set on non-repeated field %s' % (
field.name))
fields_by_name = field.message_type.fields_by_name
key_checker = type_checkers.GetTypeChecker(fields_by_name['key'])
value_field = fields_by_name['value']
if _IsMessageMapField(field):
def MakeMessageMapDefault(message):
return containers.MessageMap(
message._listener_for_children, value_field.message_type, key_checker)
return MakeMessageMapDefault
else:
value_checker = type_checkers.GetTypeChecker(value_field)
def MakePrimitiveMapDefault(message):
return containers.ScalarMap(
message._listener_for_children, key_checker, value_checker)
return MakePrimitiveMapDefault