<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
hX                 @   s|   d Z yddlmZ W n  ek
r4   ddlmZ Y nX ddlZddlZddlmZ ddlm	Z	 dd Z
ddd	Zd
d ZdS )zDynamic Protobuf class creator.    )OrderedDictN)descriptor_pb2)message_factoryc             C   s   | j j|}| 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.
  )poolZFindMessageTypeByNameZGetPrototype)factory	full_nameZproto_descriptor	proto_cls r	   #/usr/lib/python3.6/proto_builder.py_GetMessageFromFactory,   s    
r   c       
      C   s   t j|d}|dk	r8yt||}|S  tk
r6   Y nX t| j }t| tsVt|}t	j
 }x4|D ],\}}|j|jd |jt|jd qdW |j d }	|dkrd|j  }yt||}|S  tk
r   Y nX |j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   Nzutf-8z.protoz6net.proto2.python.public.proto_builder.AnonymousProto_)r   ZMessageFactoryr   KeyErrorlistitems
isinstancer   sortedhashlibZsha1updateencodestrZ	hexdigestr   ZAdd_MakeFileDescriptorProto)
Zfieldsr   r   r   r   field_itemsZfields_hashf_namef_typeproto_file_namer	   r	   r
   MakeSimpleProtoClass<   s4    



r   c             C   s   |j dd\}}tj }tjj|jdd| |_||_|j	j
 }||_x@t|dD ]2\}\}}	|jj
 }
||
_||
_tjj|
_|	|
_qRW |S )zAPopulate FileDescriptorProto for MessageFactory's DescriptorPool..   /)rsplitr   ZFileDescriptorProtoospathjoinreplacenamepackageZmessage_typeadd	enumerateZfieldZnumberZFieldDescriptorProtoZLABEL_OPTIONALZlabeltype)r   r   r   r$   r#   Z
file_protoZ
desc_protoZf_numberr   r   Zfield_protor	   r	   r
   r   t   s    



r   )NN)__doc__collectionsr   ImportErrorZordereddictr   r   Zgoogle.protobufr   r   r   r   r   r	   r	   r	   r
   <module>   s   
8