| Server IP : 35.80.110.71 / Your IP : 216.73.216.52 Web Server : Apache/2.4.58 (Ubuntu) System : Linux ip-172-31-21-44 6.17.0-1019-aws #19~24.04.1-Ubuntu SMP Tue Jun 23 18:53:06 UTC 2026 x86_64 User : ubuntu ( 1000) PHP Version : 8.3.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /lib/python3/dist-packages/IPython/utils/__pycache__/ |
Upload File : |
�
}�eY
� �� � d Z ddlZddlmZmZ ddlmZ ddlZddlmZm Z ej dej � Z ej dej � Z
dd�Zd � Zd
d
�Zdd�Zy)z�
Tools to open .py files as Unicode, using the encoding specified within the file,
as per PEP 263.
Much of the code is taken from the tokenize module in Python 3.2.
� N)�
TextIOWrapper�BytesIO)�Path)�open�detect_encodingzcoding[:=]\s*([-\w.]+)z^\s*#.*coding[:=]\s*([-\w.]+)c � � t | t � r| S t | t � rt | � }n| } t |j
� \ }}|j d� t |||d�� 5 }d|_ |r#dj t |� � cddd� S |j � cddd� S # t $ r d}Y �sw xY w# 1 sw Y yxY w)a# Converts a bytes string with python source code to unicode.
Unicode strings are passed through unchanged. Byte strings are checked
for the python source file encoding cookie to determine encoding.
txt can be either a bytes buffer or a string containing the source
code.
�asciir T)�errors�line_buffering�r� N)
�
isinstance�str�bytesr r �readline�SyntaxError�seekr �mode�join�strip_encoding_cookie�read)�txtr
�skip_encoding_cookie�buffer�encoding�_�texts �6/usr/lib/python3/dist-packages/IPython/utils/openpy.py�source_to_unicoder s� � � �#�s���
��#�u���������%�f�o�o�6���!� �K�K��N� �v�x��t� L� �PT��� ���8�8�1�$�7�8�� �
�9�9�;�� �� � ������ �s# �B0 �*#C�C�0B>�=B>�C
c # �� K � t | � } t |� }t j |� s|�� t |� }t j |� s|�� |D ] }|�� � y# t $ r Y yw xY w�w)z{Generator to pull lines from a text-mode file, skipping the encoding
cookie if it is found in the first two lines.
N)�iter�next�cookie_comment_re�match�
StopIteration)�filelike�it�first�second�lines r r r + sw � �� �
�h��B���R��� �&�&�u�-��K��b��� �&�&�v�.��L� � ���
��� � ���s) �A2�AA# �A2�# A/�,A2�.A/�/A2c �� � t | � }t |� 5 }|r#dj t |� � cddd� S |j � cddd� S # 1 sw Y yxY w)a� Read a Python file, using the encoding declared inside the file.
Parameters
----------
filename : str
The path to the file to read.
skip_encoding_cookie : bool
If True (the default), and the encoding declaration is found in the first
two lines, that line will be excluded from the output.
Returns
-------
A unicode string containing the contents of the file.
r
N)r r r r r )�filenamer �filepath�fs r �read_py_filer/ = sU � � �H�~�H�
�h�� �1���7�7�0��3�4�� � �6�6�8� � � �s �A�A�Ac �~ � ddl m} || � }t j |j � � }t |||� S )aJ Read a Python file from a URL, using the encoding declared inside the file.
Parameters
----------
url : str
The URL from which to fetch the file.
errors : str
How to handle decoding errors in the file. Options are the same as for
bytes.decode(), but here 'replace' is the default.
skip_encoding_cookie : bool
If True (the default), and the encoding declaration is found in the first
two lines, that line will be excluded from the output.
Returns
-------
A unicode string containing the contents of the file.
r )�urlopen)�urllib.requestr1 �ior r r )�urlr
r r1 �responser s r �read_py_urlr6 S s4 � �&