
    9i                     N    S r SSKrSSKrSSKJr  SSKJr  SSKJr  S r	S r
S rg)	zf
This module provides general http handler functions for processing http responses from BCE services.
    N)BceClientError)BceServerError)utilsc                     U R                  5       nU(       a<  UR                  R                  [        R                  " U[
        S9R                  5        U R                  5         g)a  If the body is not empty, convert it to a python object and set as the value of
response.body. http_response is always closed if no error occurs.

:param http_response: the http_response object returned by HTTPConnection.getresponse()
:type http_response: httplib.HTTPResponse

:param response: general response object which will be returned to the caller
:type response: baidubce.BceResponse

:return: always true
:rtype bool
)object_hookT)read__dict__updatejsonloadsdict_to_python_objectclose)http_responseresponsebodys      a/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/baidubce/services/cfc/cfc_handler.py
parse_jsonr      sJ     D  D>S!T!]!]^    c                    U R                   S-  [        R                  R                  S-  :X  a  gU R                   S-  [        R                  R                  S-  :X  a  [        S5      eSnU R                  5       nU(       aB  [        R                  " U5      nSU;   a  [        US   US   US   S9nO[        US	   US
   SS9nUc(  [        U R                  UR                  R                  S9nU R                   Ul        Ue)a$  If the body is not empty, convert it to a python object and set as the value of
response.body. http_response is always closed if no error occurs.

:param http_response: the http_response object returned by HTTPConnection.getresponse()
:type http_response: httplib.HTTPResponse

:param response: general response object which will be returned to the caller
:type response: baidubce.BceResponse

:return: false if http status code is 2xx, raise an error otherwise
:rtype bool

:raise baidubce.exception.BceClientError: if http status code is NOT 2xx
d   Fs#   Can not handle 1xx http status codeNcodemessage	requestId)r   
request_idMessageCode )r   )statushttpclientOKCONTINUEr   r   r   r   r   reasonmetadatabce_request_idstatus_code)r   r   bser   ds        r   parse_errorr)   ,   s     s"dkknn&;;s"dkk&:&:c&AACDD
CDJJtQ; 9AfI!K.YC 9AfI"MC
{]11h>O>O>^>^_#**CO
Ir   c                     0 nU R                  5        H  u  p#[        U5      nX1U'   M     [        R                  " U5      $ )z

:param d:
:return:
)itemsstrr   Expando)r(   attrkvs       r   r   r   N   s<     D	VQ  ==r   )__doc__http.clientr   r   baidubce.exceptionr   r   baidubcer   r   r)   r    r   r   <module>r6      s+      - - (D
r   