o
    e	                     @   s4   d Z ddlZddlmZ dd Zdd Zdd	 ZdS )
zh
This module provides general http handler functions for processing http responses from media services.
    N)utilsc                 C   sD   i }t | D ]\}}t|t jjst j|}|||< qt |S )zm
    dict to python object without converting camel key to a "pythonic" name

    :param d:
    :return:
    )r   	iteritems
isinstancecompatstring_typesconvert_to_stringZExpando)dattrkv r   UD:\Projects\ConvertPro\env\Lib\site-packages\baidubce/services/media/media_handler.pydict_to_python_object   s   

r   c                 C   s<   |   }|rtj|}|jtj|tdj | 	  dS )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)
readr   r   r   __dict__updatejsonloadsr   closehttp_responseresponsebodyr   r   r   
parse_json$   s   r   c                 C   s*   |   }|rtj|}||_|   dS )a  If the body is not empty, set body content as secretKey attribute of response

    :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
    T)r   r   r   r   Zencryption_keyr   r   r   r   r   parse_secret_key_response9   s   r   )__doc__r   Zbaidubcer   r   r   r   r   r   r   r   <module>   s   