403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.216.114
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/IPython/testing/plugin/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/IPython/testing/plugin/__pycache__/ipdoctest.cpython-311.pyc
�

�@�cs.��6�dZddlZddlZddlZddlZddlmZeje��Z	Gd�dej
��Z
Gd�dej��ZGd�d	ej
��ZGd
�dej��Zejd��ZGd
�deje��ZdS)a�Nose Plugin that supports IPython doctests.

Limitations:

- When generating examples for use as doctests, make sure that you have
  pretty-printing OFF.  This can be done either by setting the
  ``PlainTextFormatter.pprint`` option in your configuration file to  False, or
  by interactively disabling it with  %Pprint.  This is required so that IPython
  output matches that of normal Python, which is used by doctest for internal
  execution.

- Do not rely on specific prompt numbers for results (such as using
  '_34==True', for example).  For IPython tests run via an external process the
  prompt numbers may be different, and IPython tests run as normal python code
  won't even have these special _NN variables set at all.
�N)�modified_envc���eZdZ�fd�Z�xZS)�
DocTestFinderc����t���|||||��}tt|dd����r |�|jD]}d|jtj<�|S)N�__skip_doctest__FT)�super�	_get_test�bool�getattr�examples�options�doctest�SKIP)	�self�obj�name�module�globs�source_lines�test�example�	__class__s	        ��B/usr/lib/python3/dist-packages/IPython/testing/plugin/ipdoctest.pyr	zDocTestFinder._get_test*sk����w�w� � ��d�F�E�<�H�H�����/��7�7�8�8�	5�T�=M��=�
5�
5��04�����-�-���)�__name__�
__module__�__qualname__r	�
__classcell__�rs@rrr)s8���������������rrc�8�eZdZdZejd��Zd�ZdS)�IPDoctestOutputCheckerz�Second-chance checker with support for random tests.

    If the default comparison doesn't pass, this checker looks in the expected
    output string for flags that tell us to ignore the output.
    z
#\s*random\s+c��tj�||||��}|s|j�|��rdS|S)z�Check output, accepting special markers embedded in the output.

        If the output didn't pass the default validation but the special string
        '#random' is included, we accept it.T)r�
OutputChecker�check_output�	random_re�search)r�want�got�optionflags�rets     rr$z#IPDoctestOutputChecker.check_output=sN���#�0�0��t�S�1<�>�>���	�t�~�,�,�T�2�2�	��4��
rN)rrr�__doc__�re�compiler%r$�rrr!r!4sA����������
�+�,�,�I�����rr!c��eZdZdS)�	IPExampleN)rrrr.rrr0r0Ps�������rr0c��eZdZdZdZdZdZdZdZe	j
eeeeefze	je	jz��Z
e	j
eeeeefze	je	jz��Ze	j
d��Zd�Zdd
�Zdd�Zd
�ZdS)�IPDocTestParserz�
    A class used to parse strings containing doctest examples.

    Note: This is a version modified to properly recognize IPython input and
    convert any IPython examples into valid Python ones.
    z>>>z\.\.\.zIn\ \[\d+\]:z\ \ \ \.\.\.+:a]
        # Source consists of a PS1 line followed by zero or more PS2 lines.
        (?P<source>
            (?:^(?P<indent> [ ]*) (?P<ps1> %s) .*)    # PS1 line
            (?:\n           [ ]*  (?P<ps2> %s) .*)*)  # PS2 lines
        \n? # a newline
        # Want consists of any non-blank lines that do not start with PS1.
        (?P<want> (?:(?![ ]*$)    # Not a blank line
                     (?![ ]*%s)   # Not a line starting with PS1
                     (?![ ]*%s)   # Not a line starting with PS2
                     .*$\n?       # But any other line
                  )*)
                  z#\s*all-random\s+c���tj�|��}t|�����dkrt�|��S|S)z/Convert input IPython source into valid Python.�)�_ip�input_transformer_manager�transform_cell�len�
splitlines�	prefilter)r�source�blocks   r�ip2pyzIPDocTestParser.ip2py�sN���-�<�<�V�D�D���u���!�!�"�"�a�'�'��=�=��'�'�'��Lr�<string>c���|���}|�|����dkr4d��fd�|�d��D����}g}d\}}|j�|��rd}nd}d}t
|j�|����}|r
tj
}	n0t
|j�|����}t}	d}|D�].}
|�
|||
������||�d||
�����z
}|�|
|||��\}}}
}|
|z
}
|�|��sG|�
|	||
||�t%|
�d	����z|�
����||�d|
���|
�����z
}|
���}��0|�
||d���|S)a=
        Divide the given string into examples and intervening text,
        and return them as a list of alternating Examples and strings.
        Line numbers for the Examples are 0-based.  The optional
        argument `name` is a name identifying this string, and is only
        used for error messages.
        r�
c�$��g|]}|�d���
S�Nr.)�.0�l�
min_indents  �r�
<listcomp>z)IPDocTestParser.parse.<locals>.<listcomp>�s!���K�K�K�1��*�+�+��K�K�Kr)rrz	
# random�FT�indent)�linenorHr
N)�
expandtabs�_min_indent�join�split�_RANDOM_TESTr&�list�_EXAMPLE_RE_PY�finditerr�Example�_EXAMPLE_RE_IPr0�append�start�count�_parse_example�_IS_BLANK_OR_COMMENTr8�group�end)r�stringr�output�charnorI�
random_markerr=�termsrR�mr;r
r'�exc_msgrEs               @r�parsezIPDocTestParser.parse�sE����"�"�$�$���%�%�f�-�-�
���>�>��Y�Y�K�K�K�K����T�8J�8J�K�K�K�L�L�F���������#�#�F�+�+�	�(�M�M��M����T�(�1�1�&�9�9�:�:���	��o�G�G���,�5�5�f�=�=�>�>�E��G��E��	�	�A��M�M�&�����	�	�!1�2�3�3�3��f�l�l�4�������;�;�;�F��(�(��D�&��?�?�
-�V�W�d�G�

�M�!�D��,�,�V�4�4�
8��
�
�g�g�f�d�G�-3�-7��A�G�G�H�<M�<M�8N�8N�-N�.5�7�7�7�8�8�8�

�f�l�l�4������A�E�E�G�G�<�<�<�F��U�U�W�W�F�F��
�
�f�V�W�W�o�&�&�&��
rFc	�.�
��t|�d�����
|�d���d��}|�d��}|�d��}t|���|�|�
||���|r&|�|dd�d�
z|z||��d��
�fd	�|D����}|r|�|��}|�d
��}	|	�d��}
t|
��dkrtjd|
d��r|
d=|�|
d�
z||t|��z��tj	d
d|
d��|
d<d��
fd�|
D����}	|j
�|	��}|r|�d��}nd}|�|||��}|||	|fS)a7
        Given a regular expression match from `_EXAMPLE_RE` (`m`),
        return a pair `(source, want)`, where `source` is the matched
        example's source code (with prompts and indentation stripped);
        and `want` is the example's expected output (with indentation
        stripped).

        `name` is the string's name, and `lineno` is the line number
        where the example starts; both are used for error messages.

        Optional:
        `ip2py`: if true, filter the input via IPython to convert the syntax
        into valid python.
        rHr;r@�ps1�ps2r4N� c�0��g|]}|��zdzd���S)r4Nr.)rC�slrH�ps1_lens  ��rrFz2IPDocTestParser._parse_example.<locals>.<listcomp>�s-���I�I�I�b�B�v�g�~�a�/�0�0�1�I�I�Irr'z *$���zOut\[\d+\]: \s*?\n?rGrc�$��g|]}|�d���
SrBr.)rC�wlrHs  �rrFz2IPDocTestParser._parse_example.<locals>.<listcomp>�s!���;�;�;�"�"�V�W�W�+�;�;�;r�msg)r8rYrM�_check_prompt_blank�
_check_prefixrLr=r,�match�sub�
_EXCEPTION_RE�
_find_options)rr`rrIr=rrdrer;r'�
want_linesrar
rHris             @@rrWzIPDocTestParser._parse_example�s!����"�Q�W�W�X�&�&�'�'���w�w�x�(�(�.�.�t�4�4���g�g�e�n�n���g�g�e�n�n���c�(�(��� � ��v�t�V�G�L�L�L��	Q����|�A�B�B�/��V��c�1A�4��P�P�P����I�I�I�I�I�L�I�I�I�J�J���	(��Z�Z��'�'�F�
�w�w�v�����Z�Z��%�%�
��z�?�?�Q���2�8�F�J�r�N�#C�#C���2�����:�s�6�z�4�!�C��$5�$5�5�	7�	7�	7���5�b��A��G�G�
�1�
��y�y�;�;�;�;�
�;�;�;�<�<��
��$�$�T�*�*���	��g�g�e�n�n�G�G��G��$�$�V�T�6�:�:���w��g�-�-rc���||z}|dz}t|��D]M\}}	t|	��|kr5|	|dkr)td||zdz�d|�d|	||��d|	������NdS)a�
        Given the lines of a source string (including prompts and
        leading indentation), check to make sure that every prompt is
        followed by a space character.  If any line is not followed by
        a space character, then raise ValueError.

        Note: IPython-modified version which takes the input prompt length as a
        parameter, so that prompts of variable length can be dealt with.
        r4rfzline z of the docstring for z lacks blank after z: N)�	enumerater8�
ValueError)
r�linesrHrrIri�	space_idx�min_len�i�lines
          rrnz#IPDocTestParser._check_prompt_blank
s����7�N�	��A�+�� ��'�'�	A�	A�G�A�t��4�y�y�W�$�$��i��C�)?�)?� �j�"(��(�1�*�*�*�d�d�d�"&�v�i�'7�"8�"8�"8�$�$�"@�A�A�A��	A�	ArN)r>)F)rrrr+�_PS1_PY�_PS2_PY�_PS1_IP�_PS2_IP�_RE_TPLr,r-�	MULTILINE�VERBOSErPrSrNr=rbrWrnr.rrr2r2Ss���������G��G��G��G��G� �R�Z��G�G�G�G�+L�!L�!#���
�!:�<�<�N� �R�Z��G�G�G�G�+L�!L�!#���
�!:�<�<�N��2�:�2�3�3�L����B�B�B�B�H?.�?.�?.�?.�BA�A�A�A�Arr2rc�$��eZdZdZd�fd�	Z�xZS)�IPDocTestRunnerzKTest runner that synchronizes the IPython namespace with test globals.
    NTc���tddd���5tt|���||||��cddd��S#1swxYwYdS)N�80�24)�COLUMNS�LINES)rrr��run)rr�compileflags�out�clear_globsrs     �rr�zIPDocTestRunner.run(s����
�d�T�:�:�
;�
;�	Q�	Q����.�.�2�2�4�3?��K�Q�Q�	Q�	Q�	Q�	Q�	Q�	Q�	Q�	Q�	Q�	Q�	Q�	Q����	Q�	Q�	Q�	Q�	Q�	Qs�+A�A�A)NNT)rrrr+r�rrs@rr�r�$sQ���������Q�Q�Q�Q�Q�Q�Q�Q�Q�Qrr�)r+r�logging�osr,�testpathr�	getLoggerr�logrr#r!rRr0�
DocTestParserr2�register_optionflagr�
DocTestRunner�objectr�r.rr�<module>r�sh����*��������	�	�	�	�	�	�	�	�!�!�!�!�!�!��g���!�!�������G�)���������W�2����8'�&�&�&�&���&�&�&�KA�KA�KA�KA�KA�g�+�KA�KA�KA�\#�w�"�6�*�*��Q�Q�Q�Q�Q�g�+�F�Q�Q�Q�Q�Qr

Youez - 2016 - github.com/yon3zu
LinuXploit