Server IP : 209.38.156.173 / Your IP : 216.73.216.122 [ Web Server : Apache/2.4.52 (Ubuntu) System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.1.2-1ubuntu2.22 Disable Function : NONE Domains : 2 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3/dist-packages/requests_toolbelt/utils/__pycache__/ |
Upload File : |
o �O�X� � @ sd d Z ddlZddlZddlmZ ejdejd�jZejdejd�jZ e�d�jZ dd � Zd d� ZdS )z7A collection of functions deprecated in requests.utils.� N)�utilss! <meta.*?charset=["\']*(.+?)["\'>])�flagss+ <meta.*?content=["\']*;?charset=(.+?)["\'>]s$ ^<\?xml.*?encoding=["\']*(.+?)["\'>]c C sF t | �t| � t| � }dtj krdk r!n |S dd� |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 S s g | ]}|� d ��qS )�utf8)�decode)�.0�encoding� r �D/usr/lib/python3/dist-packages/requests_toolbelt/utils/deprecated.py� <listcomp>( s z.get_encodings_from_content.<locals>.<listcomp>)�find_charset�find_pragma�find_xml�sys�version_info)�content� encodingsr r r �get_encodings_from_content s ��r c C s� t � }t�| j�}|r#zt| j|�W S ty" |�|�� � Y nw t | j�}|D ]"}|�� }||v r5q*z t| j|�W S tyL |�|� Y q*w |rdz t| j|dd�W S t yc Y | jS w | jS )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 � _encodingr r r �get_unicode_from_response, s4 � ��r# ) �__doc__�rer �requestsr �compile�I�findallr r r r r# r r r r �<module> s* ������