File: //lib/python3.9/site-packages/google/protobuf/__pycache__/proto_builder.cpython-39.pyc
a
x��gR � @ sz d Z zddlmZ W n ey2 ddlmZ Y n0 ddlZddlZddlmZ ddlm Z dd� Z
ddd �Zd
d� ZdS )
zDynamic Protobuf class creator.� )�OrderedDictN)�descriptor_pb2)�message_factoryc C s | j �|�}| �|�}|S )a8 Get a proto class from the MessageFactory by name.
Args:
factory: a MessageFactory instance.
full_name: str, the fully qualified name of the proto type.
Returns:
A class, for the type identified by full_name.
Raises:
KeyError, if the proto is not found in the factory's descriptor pool.
)�poolZFindMessageTypeByNameZGetPrototype)�factory� full_nameZproto_descriptor� proto_cls� r �A/usr/lib/python3.9/site-packages/google/protobuf/proto_builder.py�_GetMessageFromFactory, s
r c
C s� t j|d�}|dur8zt||�}|W S ty6 Y n0 | �� }t| t�sRt|�}t� � }|D ],\}}|�
|�d�� |�
t|��d�� q^|�
� d } |du r�d|�
� }zt||�}|W S ty� Y n0 |j�t| ||�� t||�S )a� Create a Protobuf class whose fields are basic types.
Note: this doesn't validate field names!
Args:
fields: dict of {name: field_type} mappings for each field in the proto. If
this is an OrderedDict the order will be maintained, otherwise the
fields will be sorted by name.
full_name: optional str, the fully-qualified name of the proto type.
pool: optional DescriptorPool instance.
Returns:
a class, the new protobuf class with a FileDescriptor.
)r Nzutf-8z.protoz6net.proto2.python.public.proto_builder.AnonymousProto_)r ZMessageFactoryr �KeyError�items�
isinstancer �sorted�hashlibZsha1�update�encode�strZ hexdigestr ZAdd�_MakeFileDescriptorProto)
�fieldsr r r r �field_itemsZfields_hash�f_name�f_type�proto_file_namer r r
�MakeSimpleProtoClass<