
    |h	                        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y)
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 |S |D cg c]  }|j                  d       }}|S c c}w )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   utf8)find_charsetfind_pragmafind_xmlsysversion_infodecode)content	encodingsencodings      a/var/www/html/test/engine/venv/lib/python3.12/site-packages/requests_toolbelt/utils/deprecated.pyget_encodings_from_contentr      si      g&W)==G$%I!!*F* >GGX__V,G	G Hs   A!c                 6   t               }t        j                  | j                        }|r	 t	        | j
                  |      S t        | j
                        }|D ]/  }|j                         }||v r	 t	        | j
                  |      c S  |r	 t	        | j
                  |d      S | j                  S # t        $ r" |j                  |j                                Y w xY w# t        $ r |j                  |       Y w xY w# t        $ r Y | j                  S w xY w)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#   ,   s   & eO ..x/?/?@H	2x''22 +8+;+;<I +	OO%	'	+x''33+ 	x'')DD ==)  	2 01	2  	+	*	+  	==	s5   B3 3C!D 3(CC!C>=C>	DD)__doc__rer   requestsr   compileIfindallr	   r
   r   r   r#        r   <module>r,      s|    = 	 
 rzz)	'  bjj3244	'  2::,	' 	
./r+   