a *Na @sddZddlZddlZddlmZejdejdjZejdejdjZ edjZ dd Z d d Z dS) z7A collection of functions deprecated in requests.utils.N)utilss!])flagss+]s$^<\?xml.*?encoding=["\']*(.+?)["\'>]cCsDt|t|t|}dtjkr.dkr@nndd|D}|S)aReturn 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)rcSsg|]}|dqS)utf8)decode).0encodingr }/private/var/folders/js/6pj4vh5d4zd0k6bxv74qrbhr0000gr/T/pip-target-22xwyzbs/lib/python/requests_toolbelt/utils/deprecated.py (z.get_encodings_from_content..) find_charset find_pragmafind_xmlsys version_info)content encodingsr r r get_encodings_from_contents rc Cst}t|j}|rFzt|j|WStyD||Yn0t |j}|D]F}|}||vrjqTzt|j|WSty||YqT0qT|rzt|j|ddWSt yYn0|j S)aMReturn 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) setrget_encoding_from_headersheadersstrr UnicodeErroraddlowerr TypeErrortext)responsetried_encodingsr r _encodingr r r get_unicode_from_response,s,     r$) __doc__rerrequestsrcompileIfindallrrrrr$r r r r s