精华内容
下载资源
问答
  • descriptor
    2021-01-14 22:12:45

    本文整理汇总了Python中google.protobuf.descriptor.FieldDescriptor方法的典型用法代码示例。如果您正苦于以下问题:Python descriptor.FieldDescriptor方法的具体用法?Python descriptor.FieldDescriptor怎么用?Python descriptor.FieldDescriptor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在模块google.protobuf.descriptor的用法示例。

    在下文中一共展示了descriptor.FieldDescriptor方法的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

    示例1: _CheckConflictRegister

    ​点赞 6

    # 需要导入模块: from google.protobuf import descriptor [as 别名]

    # 或者: from google.protobuf.descriptor import FieldDescriptor [as 别名]

    def _CheckConflictRegister(self, desc):

    """Check if the descriptor name conflicts with another of the same name.

    Args:

    desc: Descriptor of a message, enum, service or extension.

    """

    desc_name = desc.full_name

    for register, descriptor_type in [

    (self._descriptors, descriptor.Descriptor),

    (self._enum_descriptors, descriptor.EnumDescriptor),

    (self._service_descriptors, descriptor.ServiceDescriptor),

    (self._toplevel_extensions, descriptor.FieldDescriptor)]:

    if desc_name in register:

    file_name = register[desc_name].file.name

    if not isinstance(desc, descriptor_type) or (

    file_name != desc.file.name):

    warn_msg = ('Conflict register for file "' + desc.file.name +

    '": ' + desc_name +

    ' is already defined in file "' +

    file_name + '"')

    warnings.warn(warn_msg, RuntimeWarning)

    return

    开发者ID:ryfeus,项目名称:lambda-packs,代码行数:24,

    示例2: AddFileDescriptor

    ​点赞 6

    # 需要导入模块: from google.protobuf import descriptor [as 别名]

    # 或者: from google.protobuf.descriptor import FieldDescriptor [as 别名]

    def AddFileDescriptor(self, file_desc):

    """Adds a FileDescriptor to the pool, non-recursively.

    If the FileDescriptor contains messages or enums, the caller must explicitly

    register them.

    Args:

    file_desc: A FileDescriptor.

    """

    self._AddFileDescriptor(file_desc)

    # TODO(jieluo): This is a temporary solution for FieldDescriptor.file.

    # FieldDescriptor.file is added in code gen. Remove this solution after

    # maybe 2020 for compatibility reason (with 3.4.1 only).

    for extension in list(file_desc.extensions_by_name.values()):

    self._file_desc_by_toplevel_extension[

    extension.full_name] = file_desc

    开发者ID:ryfeus,项目名称:lambda-packs,代码行数:19,

    示例3: _AddPropertiesForField

    ​点赞 6

    # 需要导入模块: from google.protobuf import descriptor [as 别名]

    # 或者: from google.protobuf.descriptor import FieldDescriptor [as 别名]

    def _AddPropertiesForField(field, cls):

    """Adds a public property for a protocol message field.

    Clients can use this property to get and (in the case

    of non-repeated scalar fields) directly set the value

    of a protocol message field.

    Args:

    field: A FieldDescriptor for this field.

    cls: The class we're constructing.

    """

    # Catch it if we add other types that we should

    # handle specially here.

    assert _FieldDescriptor.MAX_CPPTYPE == 10

    constant_name = field.name.upper() + "_FIELD_NUMBER"

    setattr(cls, constant_name, field.number)

    if field.label == _FieldDescriptor.LABEL_REPEATED:

    _AddPropertiesForRepeatedField(field, cls)

    elif field.cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:

    _AddPropertiesForNonRepeatedCompositeField(field, cls)

    else:

    _AddPropertiesForNonRepeatedScalarField(field, cls)

    开发者ID:ryfeus,项目名称:lambda-packs,代码行数:25,

    示例4: FindExtensionByName

    ​点赞 6

    # 需要导入模块: from google.protobuf import descriptor [as 别名]

    # 或者: from google.protobuf.descriptor import FieldDescriptor [as 别名]

    def FindExtensionByName(self, full_name):

    """Loads the named extension descriptor from the pool.

    Args:

    full_name: The full name of the extension descriptor to load.

    Returns:

    A FieldDescriptor, describing the named extension.

    """

    full_name = _NormalizeFullyQualifiedName(full_name)

    message_name, _, extension_name = full_name.rpartition('.')

    try:

    # Most extensions are nested inside a message.

    scope = self.FindMessageTypeByName(message_name)

    except KeyError:

    # Some extensions are defined at file scope.

    scope = self.FindFileContainingSymbol(full_name)

    return scope.extensions_by_name[extension_name]

    开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:20,

    示例5: __getitem__

    ​点赞 6

    # 需要导入模块: from google.protobuf import descriptor [as 别名]

    # 或者: from google.protobuf.descriptor import FieldDescriptor [as 别名]

    def __getitem__(self, extension):

    from google.protobuf import descriptor

    if not isinstance(extension, descriptor.FieldDescriptor):

    raise KeyError('Bad extension %r.' % (extension,))

    cdescriptor = extension._cdescriptor

    if (cdescriptor.label != _LABEL_REPEATED and

    cdescriptor.cpp_type != _CPPTYPE_MESSAGE):

    return self._cmsg.GetScalar(cdescriptor)

    ext = self._values.get(extension, None)

    if ext is not None:

    return ext

    ext = self._CreateNewHandle(extension)

    self._values[extension] = ext

    return ext

    开发者ID:katharosada,项目名称:botchallenge,代码行数:19,

    示例6: _BytesForNonRepeatedElement

    ​点赞 6

    # 需要导入模块: from google.protobuf import descriptor [as 别名]

    # 或者: from google.protobuf.descriptor import FieldDescriptor [as 别名]

    def _BytesForNonRepeatedElement(value, field_number, field_type):

    """Returns the number of bytes needed to serialize a non-repeated element.

    The returned byte count includes space for tag information and any

    other additional space associated with serializing value.

    Args:

    value: Value we're serializing.

    field_number: Field number of this value. (Since the field number

    is stored as part of a varint-encoded tag, this has an impact

    on the total bytes required to serialize the value).

    field_type: The type of the field. One of the TYPE_* constants

    within FieldDescriptor.

    """

    try:

    fn = type_checkers.TYPE_TO_BYTE_SIZE_FN[field_type]

    return fn(field_number, value)

    except KeyError:

    raise message_mod.EncodeError('Unrecognized field type: %d' % field_type)

    开发者ID:katharosada,项目名称:botchallenge,代码行数:20,

    示例7: GetTypeChecker

    ​点赞 6

    # 需要导入模块: from google.protobuf import descriptor [as 别名]

    # 或者: from google.protobuf.descriptor import FieldDescriptor [as 别名]

    def GetTypeChecker(field):

    """Returns a type checker for a message field of the specified types.

    Args:

    field: FieldDescriptor object for this field.

    Returns:

    An instance of TypeChecker which can be used to verify the types

    of values assigned to a field of the specified type.

    """

    if (field.cpp_type == _FieldDescriptor.CPPTYPE_STRING and

    field.type == _FieldDescriptor.TYPE_STRING):

    return UnicodeValueChecker()

    if field.cpp_type == _FieldDescriptor.CPPTYPE_ENUM:

    return EnumValueChecker(field.enum_type)

    return _VALUE_CHECKERS[field.cpp_type]

    # None of the typecheckers below make any attempt to guard against people

    # subclassing builtin types and doing weird things. We're not trying to

    # protect against malicious clients here, just people accidentally shooting

    # themselves in the foot in obvious ways.

    开发者ID:katharosada,项目名称:botchallenge,代码行数:24,

    示例8: AddFileDescriptor

    ​点赞 6

    # 需要导入模块: from google.protobuf import descriptor [as 别名]

    # 或者: from google.protobuf.descriptor import FieldDescriptor [as 别名]

    def AddFileDescriptor(self, file_desc):

    """Adds a FileDescriptor to the pool, non-recursively.

    If the FileDescriptor contains messages or enums, the caller must explicitly

    register them.

    Args:

    file_desc: A FileDescriptor.

    """

    self._AddFileDescriptor(file_desc)

    # TODO(jieluo): This is a temporary solution for FieldDescriptor.file.

    # Remove it when FieldDescriptor.file is added in code gen.

    for extension in file_desc.extensions_by_name.values():

    self._file_desc_by_toplevel_extension[

    extension.full_name] = file_desc

    开发者ID:apple,项目名称:coremltools,代码行数:18,

    示例9: FindExtensionByNumber

    ​点赞 6

    # 需要导入模块: from google.protobuf import descriptor [as 别名]

    # 或者: from google.protobuf.descriptor import FieldDescriptor [as 别名]

    def FindExtensionByNumber(self, message_descriptor, number):

    """Gets the extension of the specified message with the specified number.

    Extensions have to be registered to this pool by calling

    AddExtensionDescriptor.

    Args:

    message_descriptor: descriptor of the extended message.

    number: integer, number of the extension field.

    Returns:

    A FieldDescriptor describing the extension.

    Raise:

    KeyError: when no extension with the given number is known for the

    specified message.

    """

    return self._extensions_by_number[message_descriptor][number]

    开发者ID:enricofer,项目名称:go2mapillary,代码行数:20,

    示例10: _IsMessageSetExtension

    ​点赞 5

    # 需要导入模块: from google.protobuf import descriptor [as 别名]

    # 或者: from google.protobuf.descriptor import FieldDescriptor [as 别名]

    def _IsMessageSetExtension(field):

    return (field.is_extension and

    field.containing_type.has_options and

    field.containing_type.GetOptions().message_set_wire_format and

    field.type == descriptor.FieldDescriptor.TYPE_MESSAGE and

    field.label == descriptor.FieldDescriptor.LABEL_OPTIONAL)

    开发者ID:ryfeus,项目名称:lambda-packs,代码行数:8,

    示例11: FindExtensionByName

    ​点赞 5

    # 需要导入模块: from google.protobuf import descriptor [as 别名]

    # 或者: from google.protobuf.descriptor import FieldDescriptor [as 别名]

    def FindExtensionByName(self, full_name):

    """Loads the named extension descriptor from the pool.

    Args:

    full_name: The full name of the extension descriptor to load.

    Returns:

    A FieldDescriptor, describing the named extension.

    Raises:

    KeyError: if the extension cannot be found in the pool.

    """

    full_name = _NormalizeFullyQualifiedName(full_name)

    try:

    # The proto compiler does not give any link between the FileDescriptor

    # and top-level extensions unless the FileDescriptorProto is added to

    # the DescriptorDatabase, but this can impact memory usage.

    # So we registered these extensions by name explicitly.

    return self._toplevel_extensions[full_name]

    except KeyError:

    pass

    message_name, _, extension_name = full_name.rpartition('.')

    try:

    # Most extensions are nested inside a message.

    scope = self.FindMessageTypeByName(message_name)

    except KeyError:

    # Some extensions are defined at file scope.

    scope = self._FindFileContainingSymbolInDb(full_name)

    return scope.extensions_by_name[extension_name]

    开发者ID:ryfeus,项目名称:lambda-packs,代码行数:31,

    示例12: FindAllExtensions

    ​点赞 5

    # 需要导入模块: from google.protobuf import descriptor [as 别名]

    # 或者: from google.protobuf.descriptor import FieldDescriptor [as 别名]

    def FindAllExtensions(self, message_descriptor):

    """Gets all the known extension of a given message.

    Extensions have to be registered to this pool by calling

    AddExtensionDescriptor.

    Args:

    message_descriptor: descriptor of the extended message.

    Returns:

    A list of FieldDescriptor describing the extensions.

    """

    return list(self._extensions_by_number[message_descriptor].values())

    开发者ID:ryfeus,项目名称:lambda-packs,代码行数:15,

    示例13: testHandWrittenReflection

    ​点赞 5

    # 需要导入模块: from google.protobuf import descriptor [as 别名]

    # 或者: from google.protobuf.descriptor import FieldDescriptor [as 别名]

    def testHandWrittenReflection(self):

    # Hand written extensions are only supported by the pure-Python

    # implementation of the API.

    if api_implementation.Type() != 'python':

    return

    FieldDescriptor = descriptor.FieldDescriptor

    foo_field_descriptor = FieldDescriptor(

    name='foo_field', full_name='MyProto.foo_field',

    index=0, number=1, type=FieldDescriptor.TYPE_INT64,

    cpp_type=FieldDescriptor.CPPTYPE_INT64,

    label=FieldDescriptor.LABEL_OPTIONAL, default_value=0,

    containing_type=None, message_type=None, enum_type=None,

    is_extension=False, extension_scope=None,

    options=descriptor_pb2.FieldOptions())

    mydescriptor = descriptor.Descriptor(

    name='MyProto', full_name='MyProto', filename='ignored',

    containing_type=None, nested_types=[], enum_types=[],

    fields=[foo_field_descriptor], extensions=[],

    options=descriptor_pb2.MessageOptions())

    class MyProtoClass(six.with_metaclass(reflection.GeneratedProtocolMessageType, message.Message)):

    DESCRIPTOR = mydescriptor

    myproto_instance = MyProtoClass()

    self.assertEqual(0, myproto_instance.foo_field)

    self.assertTrue(not myproto_instance.HasField('foo_field'))

    myproto_instance.foo_field = 23

    self.assertEqual(23, myproto_instance.foo_field)

    self.assertTrue(myproto_instance.HasField('foo_field'))

    开发者ID:ryfeus,项目名称:lambda-packs,代码行数:30,

    示例14: testPackedOptions

    ​点赞 5

    # 需要导入模块: from google.protobuf import descriptor [as 别名]

    # 或者: from google.protobuf.descriptor import FieldDescriptor [as 别名]

    def testPackedOptions(self):

    proto = unittest_pb2.TestAllTypes()

    proto.optional_int32 = 1

    proto.optional_double = 3.0

    for field_descriptor, _ in proto.ListFields():

    self.assertEqual(False, field_descriptor.GetOptions().packed)

    proto = unittest_pb2.TestPackedTypes()

    proto.packed_int32.append(1)

    proto.packed_double.append(3.0)

    for field_descriptor, _ in proto.ListFields():

    self.assertEqual(True, field_descriptor.GetOptions().packed)

    self.assertEqual(descriptor.FieldDescriptor.LABEL_REPEATED,

    field_descriptor.label)

    开发者ID:ryfeus,项目名称:lambda-packs,代码行数:16,

    示例15: _IsPresent

    ​点赞 5

    # 需要导入模块: from google.protobuf import descriptor [as 别名]

    # 或者: from google.protobuf.descriptor import FieldDescriptor [as 别名]

    def _IsPresent(item):

    """Given a (FieldDescriptor, value) tuple from _fields, return true if the

    value should be included in the list returned by ListFields()."""

    if item[0].label == _FieldDescriptor.LABEL_REPEATED:

    return bool(item[1])

    elif item[0].cpp_type == _FieldDescriptor.CPPTYPE_MESSAGE:

    return item[1]._is_present_in_parent

    else:

    return True

    开发者ID:ryfeus,项目名称:lambda-packs,代码行数:12,

    示例16: GetTypeChecker

    ​点赞 5

    # 需要导入模块: from google.protobuf import descriptor [as 别名]

    # 或者: from google.protobuf.descriptor import FieldDescriptor [as 别名]

    def GetTypeChecker(field):

    """Returns a type checker for a message field of the specified types.

    Args:

    field: FieldDescriptor object for this field.

    Returns:

    An instance of TypeChecker which can be used to verify the types

    of values assigned to a field of the specified type.

    """

    if (field.cpp_type == _FieldDescriptor.CPPTYPE_STRING and

    field.type == _FieldDescriptor.TYPE_STRING):

    return UnicodeValueChecker()

    if field.cpp_type == _FieldDescriptor.CPPTYPE_ENUM:

    if SupportsOpenEnums(field):

    # When open enums are supported, any int32 can be assigned.

    return _VALUE_CHECKERS[_FieldDescriptor.CPPTYPE_INT32]

    else:

    return EnumValueChecker(field.enum_type)

    return _VALUE_CHECKERS[field.cpp_type]

    # None of the typecheckers below make any attempt to guard against people

    # subclassing builtin types and doing weird things. We're not trying to

    # protect against malicious clients here, just people accidentally shooting

    # themselves in the foot in obvious ways.

    开发者ID:ryfeus,项目名称:lambda-packs,代码行数:28,

    示例17: _MakeFieldDescriptor

    ​点赞 5

    # 需要导入模块: from google.protobuf import descriptor [as 别名]

    # 或者: from google.protobuf.descriptor import FieldDescriptor [as 别名]

    def _MakeFieldDescriptor(self, field_proto, message_name, index,

    is_extension=False):

    """Creates a field descriptor from a FieldDescriptorProto.

    For message and enum type fields, this method will do a look up

    in the pool for the appropriate descriptor for that type. If it

    is unavailable, it will fall back to the _source function to

    create it. If this type is still unavailable, construction will

    fail.

    Args:

    field_proto: The proto describing the field.

    message_name: The name of the containing message.

    index: Index of the field

    is_extension: Indication that this field is for an extension.

    Returns:

    An initialized FieldDescriptor object

    """

    if message_name:

    full_name = '.'.join((message_name, field_proto.name))

    else:

    full_name = field_proto.name

    return descriptor.FieldDescriptor(

    name=field_proto.name,

    full_name=full_name,

    index=index,

    number=field_proto.number,

    type=field_proto.type,

    cpp_type=None,

    message_type=None,

    enum_type=None,

    containing_type=None,

    label=field_proto.label,

    has_default_value=False,

    default_value=None,

    is_extension=is_extension,

    extension_scope=None,

    options=_OptionsOrNone(field_proto))

    开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:43,

    示例18: _MakeFieldDescriptor

    ​点赞 5

    # 需要导入模块: from google.protobuf import descriptor [as 别名]

    # 或者: from google.protobuf.descriptor import FieldDescriptor [as 别名]

    def _MakeFieldDescriptor(self, field_proto, message_name, index,

    is_extension=False):

    """Creates a field descriptor from a FieldDescriptorProto.

    For message and enum type fields, this method will do a look up

    in the pool for the appropriate descriptor for that type. If it

    is unavailable, it will fall back to the _source function to

    create it. If this type is still unavailable, construction will

    fail.

    Args:

    field_proto: The proto describing the field.

    message_name: The name of the containing message.

    index: Index of the field

    is_extension: Indication that this field is for an extension.

    Returns:

    An initialized FieldDescriptor object

    """

    if message_name:

    full_name = '.'.join((message_name, field_proto.name))

    else:

    full_name = field_proto.name

    return descriptor.FieldDescriptor(

    name=field_proto.name,

    full_name=full_name,

    index=index,

    number=field_proto.number,

    type=field_proto.type,

    cpp_type=None,

    message_type=None,

    enum_type=None,

    containing_type=None,

    label=field_proto.label,

    has_default_value=False,

    default_value=None,

    is_extension=is_extension,

    extension_scope=None,

    options=field_proto.options)

    开发者ID:sklearn-theano,项目名称:sklearn-theano,代码行数:43,

    注:本文中的google.protobuf.descriptor.FieldDescriptor方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。

    更多相关内容
  • mysql默认是线程不安全的...[MDEV-9749] InnoDB receives 'Bad file descriptor' error, possibly related to feedback plugin Lost connection to MySQL server at 'handshake- reading initial communication packet'
  • 描述符(descriptor)是实现了__get__、__set__、__del__方法的类,进一步可以细分为两类: 数据描述符:实现了__get__和__set__ 非数据描述符:没有实现__set__ 描述符在类的属性调用中起着很重要的作用,类在...
  • Cron描述符 掌握: 全部: 一个将cron表达式转换为人类可读字符串的Python库。...from cron_descriptor import get_description , ExpressionDescriptor print ( get_description ( "* 2 3 * *" )) #OR prin
  • In this paper, we propose to learn high per-.formance descriptor in Euclidean space via the Convolu-.tional Neural Network (CNN). Our method is distinctive in.four aspects: (i) We propose a ...
  • 通常,一个 descriptor 是具有“绑定行为”的对象属性。所绑定行为可通过 descriptor 协议被自定义的 __get__() , __set__() 和 __delete__() 方法重写。如果一个对象的上述三个方法任意一个被重写,则就可被称为 ...
  • jar包,亲测可用
  • 最新版HID Descriptor Tool

    2018-04-23 17:06:15
    This tool allows you to create, edit and validate HID Report Descriptors. The tool also supports a variety of output formats (.txt, .inc, .h, etc.). DT uses ASCII based Usage Tables and supports ...
  • import { MINUTES , SECONDS , inDays } from "time-descriptor" ;const start = Date . now ( ) ;setInterval ( ( ) => { // Days running console . log ( inDays ( Date . now ( ) - start ) ) ;} , 3 * MINUTES...
  • 猪描述符hog-descriptor 从图像(画布)中提取描述符: var hog = require ( "hog-descriptor" ) ;var descriptor = hog . extractHOG ( canvas ) ;console . log ( descriptor ) ; // [0.455, 0.003, 0.987, ...]...
  • 自定义一个插件,继承AbstractMojo,实现execute方法,引入该...-descriptor) on project maven-project: Error extracting plugin descriptor: ‘No mojo definitions wer e found for plugin: com.gupao:maven-pro
  • eclipse一打开就会出现这个情况Loading descriptor for [项目名]这个情况,这里有我的解决办法,希望可以帮到大家。
  • plugin-descriptor.properties

    2022-04-11 00:09:09
    plugin-descriptor.properties
  • 关于jsp中报错:cannot find the tag library descriptor for http://java.sun.com/jsp/jstl/core-附件资源
  • MyEclipse 出错提示 Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core"
  • FileDescriptor 是“文件描述符”。可以被用来表示开放文件、开放套接字等。接下来通过本文给大家分享Java FileDescriptor总结,感兴趣的朋友一起学习吧
  • 主要给大家介绍了golang bad file descriptor问题的解决方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面来一起学习学习吧
  • descriptor method performs as a classifier on the last 100 training points. The centroid-distance function should have a 74% success rate, the polygonal approximation should have about 51% success...
  • HID_descriptor_tool.rar

    2020-03-04 20:46:12
    在usb官网下载的HID报告描述符生成工具,亲测绝对可用!可用于HID设备驱动程序开发,不要积分,不要积分,不要积分!
  • MIPI Specification for Device Descriptor Block (DDB) V1.0 - 2008
  • Report Descriptor

    2017-03-20 23:09:58
    Report Descriptor分析
  • Sybase.Modeling.Pd.Oom.Xmi.dll.descriptor
  • awesome-local-global-descriptor:关于本地和全局描述符的我的个人笔记
  • Discrete-time Linear Descriptor System Unknown Input Observer Design: an Auxiliary Output-based Approach
  • 有的时候在开发jsp时,需要使用jstl时,在jsp上面引用jstl却出现错误:Can not find the tag library descriptor for "http://java.sun.com/jsp/jstl/core,这是由于缺少两个jar包导致的。
  • Robust 3D Tracking with Descriptor Fields 论文 。
  • hid descriptor tool USB 描述符生成工具

    热门讨论 2014-07-28 11:20:10
    hid descriptor tool USB 描述符生成工具
  • DAISY has a matlab implementation now.

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 201,267
精华内容 80,506
关键字:

descriptor