
    .Ph	                         d Z ddlZddlZddlmZ  ej        dej                  j        Z ej        dej                  j        Z	 ej        d          j        Z
d Zd	 ZdS )
z7A collection of functions deprecated in requests.utils.    N)utilss!   <meta.*?charset=["\']*(.+?)["\'>])flagss+   <meta.*?content=["\']*;?charset=(.+?)["\'>]s$   ^<\?xml.*?encoding=["\']*(.+?)["\'>]c                     t          |           t          |           z   t          |           z   }dt          j        cxk    rdk     rn nd |D             }|S )a  Return 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
    :return: encodings detected in the provided content
    :rtype: list(str)
    )   r   )   r   c                 8    g | ]}|                     d           S )utf8)decode).0encodings     b/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/requests_toolbelt/utils/deprecated.py
<listcomp>z.get_encodings_from_content.<locals>.<listcomp>(   s$    GGGX__V,,GGG    )find_charsetfind_pragmafind_xmlsysversion_info)content	encodingss     r   get_encodings_from_contentr      sl      g&&W)=)==G$$%I!****F*****GGYGGG	r   c                 ,   t                      }t          j        | j                  }|rM	 t	          | j        |          S # t          $ r* |                    |                                           Y nw xY wt          | j                  }|D ]W}|                                }||v r	 t	          | j        |          c S # t          $ r |                    |           Y Tw xY w|r(	 t	          | j        |d          S # t          $ r Y nw xY w| j        S )aM  Return 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
    replace)errors)setr   get_encoding_from_headersheadersstrr   UnicodeErroraddlowerr   	TypeErrortext)responsetried_encodingsr   r   	_encodings        r   get_unicode_from_responser'   ,   sa   & eeO .x/?@@H 2	2x'222 	2 	2 	2 0 011111	2 +8+;<<I + +	OO%%	''	+x'33333 	+ 	+ 	+	*****	+  	x')DDDD 	 	 	D	=s5   A   1A43A4)C  C"!C"(C? ?
DD)__doc__rer   requestsr   compileIfindallr   r   r   r   r'    r   r   <module>r/      s    = = 				 



      rz)  	  bj324  	  2:, 	 	
  ./ / / / /r   