✏️ 正在编辑: descriptor_pool.cpython-36.opt-1.pyc
路径:
/lib/python3.6/site-packages/google/protobuf/__pycache__/descriptor_pool.cpython-36.opt-1.pyc
提示:
您可以编辑任何文件(包括二进制文件),但请注意不当修改可能导致文件损坏。
3 ���h�� � @ s� d Z dZddlZddlmZ ddlmZ ddlmZ ejZdd� Zd d � Z dd� Z G d d� de�Zdd� Z erxejjZne� Zdd� ZdS )aJ Provides DescriptorPool to use as a container for proto2 descriptors. The DescriptorPool is used in conjection with a DescriptorDatabase to maintain a collection of protocol buffer descriptors for use when dynamically creating message types at runtime. For most applications protocol buffers should be used via modules generated by the protocol buffer compiler tool. This should only be used when the type of protocol buffers used in an application or library cannot be predetermined. Below is a straightforward example on how to use this class: pool = DescriptorPool() file_descriptor_protos = [ ... ] for file_descriptor_proto in file_descriptor_protos: pool.Add(file_descriptor_proto) my_message_descriptor = pool.FindMessageTypeByName('some.package.MessageType') The message descriptor can be used in conjunction with the message_factory module in order to create a protocol buffer class that can be encoded and decoded. If you want to get a Python class for the specified proto, use the helper functions inside google.protobuf.message_factory directly instead of this class. z"matthewtoia@google.com (Matt Toia)� N)� descriptor)�descriptor_database)� text_encodingc C s | j d�S )aL Remove leading period from fully-qualified type name. Due to b/13860351 in descriptor_database.py, types in the root namespace are generated with a leading period. This function removes that prefix. Args: name: A str, the fully-qualified symbol name. Returns: A str, the normalized fully-qualified symbol name. �.)�lstrip)�name� r �%/usr/lib/python3.6/descriptor_pool.py�_NormalizeFullyQualifiedNameF s r c C s | j d�r| jS dS dS )zCReturns the value of the field `options`, or None if it is not set.�optionsN)�HasFieldr )Zdescriptor_protor r r �_OptionsOrNoneU s r c C s6 | j o4| jjo4| jj� jo4| jtjjko4| j tjj kS )N)�is_extension�containing_typeZhas_optionsZ GetOptionsZmessage_set_wire_format�typer �FieldDescriptor�TYPE_MESSAGE�labelZLABEL_OPTIONAL)�fieldr r r �_IsMessageSetExtension] s r c @ s& e Zd ZdZerdFdd�ZdGdd�Zdd� Zd d � Zdd� Z d d� Z dd� Zdd� Zdd� Z dd� Zdd� Zdd� Zdd� Zdd� Zdd � Zd!d"� Zd#d$� Zd%d&� Zd'd(� Zd)d*� Zd+d,� Zd-d.� ZdHd/d0�ZdId1d2�ZdJd4d5�Zd6d7� Zd8d9� Zd:d;� Z d<d=� Z!d>d?� Z"d@dA� Z#dBdC� Z$dDdE� Z%dS )K�DescriptorPoolzGA collection of protobufs dynamically constructed by descriptor protos.Nc C s t jj|�S )N)r �_messager )�cls� descriptor_dbr r r �__new__j s zDescriptorPool.__new__c C sJ t j� | _|| _i | _i | _i | _i | _i | _t j t�| _t j t�| _ dS )a� Initializes a Pool of proto buffs. The descriptor_db argument to the constructor is provided to allow specialized file descriptor proto lookup code to be triggered on demand. An example would be an implementation which will read and compile a file specified in a call to FindFileByName() and not require the call to Add() at all. Results from this database will be cached internally here as well. Args: descriptor_db: A secondary source of file descriptors. N)r ZDescriptorDatabase�_internal_db�_descriptor_db�_descriptors�_enum_descriptors�_service_descriptors�_file_descriptors�_toplevel_extensions�collections�defaultdict�dict�_extensions_by_name�_extensions_by_number)�selfr r r r �__init__n s zDescriptorPool.__init__c C s | j j|� dS )zAdds the FileDescriptorProto and its types to this pool. Args: file_desc_proto: The FileDescriptorProto to add. N)r �Add)r'