Your IP : 216.73.216.213


Current Path : /opt/alt/python27/lib/python2.7/site-packages/requests_toolbelt/utils/
Upload File :
Current File : //opt/alt/python27/lib/python2.7/site-packages/requests_toolbelt/utils/deprecated.pyc

�
��Wc@s8dZddlZddlmZd�Zd�ZdS(s7A collection of functions deprecated in requests.utils.i����N(tutilscCsftjddtj�j}tjddtj�j}tjd�j}||�||�||�S(sLReturn encodings from given content string.

    .. code-block:: python

        import requests
        from requests_toolbelt.utils import deprecated

        r = requests.get(url)
        encodings = deprecated.get_encodings_from_content(r)

    :param content: bytestring to extract encodings from.
    :type content: bytes
    s!<meta.*?charset=["\']*(.+?)["\'>]tflagss+<meta.*?content=["\']*;?charset=(.+?)["\'>]s$^<\?xml.*?encoding=["\']*(.+?)["\'>](tretcompiletItfindall(tcontenttfind_charsettfind_pragmatfind_xml((sS/opt/alt/python27/lib/python2.7/site-packages/requests_toolbelt/utils/deprecated.pytget_encodings_from_contentscCst�}tj|j�}|r_yt|j|�SWq_tk
r[|j|j��q_Xnt	|j�}xa|D]Y}|j�}||kr�qunyt|j|�SWqutk
r�|j|�quXquW|r	yt|j|dd�SWq	t
k
rq	Xn|jS(sMReturn the requested content back in unicode.

    This will first attempt to retrieve the encoding from the response
    headers. If that fails, it will use
    :func:`requests_toolbelt.utils.deprecated.get_encodings_from_content`
    to determine encodings from HTML elements.

    .. code-block:: python

        import requests
        from requests_toolbelt.utils import deprecated

        r = requests.get(url)
        text = deprecated.get_unicode_from_response(r)

    :param response: Response object to get unicode content from.
    :type response: requests.models.Response
    terrorstreplace(tsetRtget_encoding_from_headerstheaderststrRtUnicodeErrortaddtlowerR
t	TypeErrorttext(tresponsettried_encodingstencodingt	encodingst	_encoding((sS/opt/alt/python27/lib/python2.7/site-packages/requests_toolbelt/utils/deprecated.pytget_unicode_from_response%s,	



(t__doc__RtrequestsRR
R(((sS/opt/alt/python27/lib/python2.7/site-packages/requests_toolbelt/utils/deprecated.pyt<module>s