
    Ngk                     j    d Z ddlmZ ddlZddlZddlmZ ddlmZ ddlmZ ddlm	Z	 d Z
dd	Zd
 ZdS )zDynamic Protobuf class creator.    )OrderedDictN)descriptor_pb2)
descriptor)descriptor_pool)message_factoryc                 X    |                      |          }t          j        |          }|S )a-  Get a proto class from the MessageFactory by name.

  Args:
    pool: a descriptor pool.
    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.
  )FindMessageTypeByNamer   GetMessageClass)pool	full_nameproto_descriptor	proto_clss       Y/var/www/html/ai-engine/env/lib/python3.11/site-packages/google/protobuf/proto_builder.py_GetMessageFromFactoryr      s/     //	::-.>??)	    c                    |pt          j                    }|#	 t          ||          }|S # t          $ r Y nw xY w|                                 }t          | t                    st          |          }t          j	                    }|D ]b\  }}|
                    |                    d                     |
                    t          |                              d                     c|                                dz   }	|:d|                                z   }	 t          ||          }|S # t          $ r Y nw xY w|                    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.
  Nzutf-8z.protoz6net.proto2.python.public.proto_builder.AnonymousProto_)r   DescriptorPoolr   KeyErroritems
isinstancer   sortedhashlibsha1updateencodestr	hexdigestAdd_MakeFileDescriptorProto)
fieldsr   r   pool_instancer   field_itemsfields_hashf_namef_typeproto_file_names
             r   MakeSimpleProtoClassr'   $   s    :/8::-(	BBi   
d +	FK	(	( &%%K +# 4 4nffv}}W--...s6{{))'223333))++h6/ I&&(()I(	BBi   
d
 	;GGI I I	y	9	99s   + 
88D. .
D;:D;c                 T   |                     dd          \  }}t          j                    }t          j                            |                    dd          |           |_        ||_        |j	        
                                }||_        t          |d          D ]\  }\  }}	|j        
                                }
||
_        |t          j        j        k    r)|t          j        j        t          j        j        z
  dz   z  }||
_        t          j        j        |
_        |	|
_        |S )zAPopulate FileDescriptorProto for MessageFactory's DescriptorPool..   /)rsplitr   FileDescriptorProtoospathjoinreplacenamepackagemessage_typeadd	enumeratefieldr   FieldDescriptorFIRST_RESERVED_FIELD_NUMBERLAST_RESERVED_FIELD_NUMBERnumberFieldDescriptorProtoLABEL_OPTIONALlabeltype)r&   r   r"   r3   r2   
file_proto
desc_protof_numberr$   r%   field_protos              r   r   r   [   s   ""3**-'4133*GLLc!:!:OLL*/*&**,,**/$-k1$=$=   h "&&((KK :-III

$
?

$
@ACDEFh "K&;JKK	r   )NN)__doc__collectionsr   r   r.   google.protobufr   r   r   r   r   r'   r    r   r   <module>rH      s    & % # # # # # #  				 * * * * * * & & & & & & + + + + + + + + + + + +   4: 4: 4: 4:n    r   