
    Ng                     "   d Z ddlZddlZddlmZ ddlZddlmZ ddlmZ  G d d ej	        dd	          ej
                  Zd
 Zd ZddgZej        d         dk    r.ej        d         dk    rddlmZ e                    d           dS dS dS )z;Reference implementation for status mapping in gRPC Python.    N)
status_pb2   )GRPC_DETAILS_METADATA_KEY)code_to_grpc_status_codec                       e Zd ZdS )_StatusN)__name__
__module____qualname__     R/var/www/html/ai-engine/env/lib/python3.11/site-packages/grpc_status/rpc_status.pyr   r      s         	Dr   r   codedetailstrailing_metadatac                    |                                  dS |                                  D ]\  }}|t          k    rt          j                            |          }|                                 j        d         |j        k    r:t          dt          |j                  d|                                 d          | 	                                |j
        k    r-t          d|j
        d| 	                                d          |c S dS )a  Returns a google.rpc.status.Status message corresponding to a given grpc.Call.

    This is an EXPERIMENTAL API.

    Args:
      call: A grpc.Call instance.

    Returns:
      A google.rpc.status.Status message representing the status of the RPC.

    Raises:
      ValueError: If the gRPC call's code or details are inconsistent with the
        status code and message inside of the google.rpc.status.Status.
    Nr   zCode in Status proto (z) doesn't match status code ()zMessage in Status proto (z ) doesn't match status details ()r   r   r   Status
FromStringr   value
ValueErrorr   r   message)callkeyr   rich_statuss       r   	from_callr   !   s    't,,..  
U+++$+66u==Kyy{{ #{'777 j/0@AAAA499;;;;P   ||~~!444 j*222DLLNNNND    , 4r   c                     t          t          | j                  | j        t          |                                 ff          S )ad  Convert a google.rpc.status.Status message to grpc.Status.

    This is an EXPERIMENTAL API.

    Args:
      status: a google.rpc.status.Status message representing the non-OK status
        to terminate the RPC with and communicate it to the client.

    Returns:
      A grpc.Status instance representing the input google.rpc.status.Status message.
    r   )r   r   r   r   r   SerializeToString)statuss    r   	to_statusr!   C   sF     %fk22&(@(@(B(BC
   r   r   r!         )_asyncaio)__doc__collectionssys
google.rpcr   grpc_commonr   r   
namedtupler   r   r   r!   __all__version_info r$   r%   appendr   r   r   <module>r1      s/   B A     



 ! ! ! ! ! !  . . . . . . - - - - - -	 	 	 	 	K9&NOOK	 	 	  D  , 
 A! 0 3q 8 8NN5  8 8r   