Your IP : 216.73.216.172


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/tap/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/tap/__pycache__/parser.cpython-311.pyc

�

�h����ddlZddlZddlZddlmZddlmZddlmZm	Z	m
Z
mZmZm
Z
	ddlZddlmZdZn
#e$rdZYnwxYwGd�d	��ZdS)
�N)�StringIO)�	Directive)�Bail�
Diagnostic�Plan�Result�Unknown�Version)�peekableTFc��eZdZdZdZejdezej��Zejdezej��Z	ejdej��Z
ejd��Zejdej��Zejd��Z
ejd	��Zejd
��ZdZd�Zd
�Zd�Zd�Zdd�Zd�Zdd�Zd�Zd�ZdS)�Parserz!A parser for TAP files and lines.a�
        \s*                    # Optional whitespace.
        (?P<number>\d*)        # Optional test number.
        \s*                    # Optional whitespace.
        (?P<description>[^#]*) # Optional description before #.
        \#?                    # Optional directive marker.
        \s*                    # Optional whitespace.
        (?P<directive>.*)      # Optional directive text.
    z^okz^not\ oka~
        ^1..(?P<expected>\d+) # Match the plan details.
        [^#]*                 # Consume any non-hash character to confirm only
                              # directives appear with the plan details.
        \#?                   # Optional directive marker.
        \s*                   # Optional whitespace.
        (?P<directive>.*)     # Optional directive text.
    z^#zq
        ^Bail\ out!
        \s*            # Optional whitespace.
        (?P<reason>.*) # Optional reason.
    z^TAP version (?P<version>\d+)$z^(?P<indent>\s+)-z
^\s+\.\.\.�
c�F�|�t|����S)z�Parse a TAP file to an iterable of tap.line.Line objects.

        This is a generator method that will yield an object for each
        parsed line. The file given by `filename` is assumed to exist.
        )�parse�open)�self�filenames  �[/builddir/build/BUILD/cloudlinux-venv-1.0.8/venv/lib/python3.11/site-packages/tap/parser.py�
parse_filezParser.parse_file<s���z�z�$�x�.�.�)�)�)�c�@�|�tj��S)z�Parse a TAP stream from standard input.

        Note: this has the side effect of closing the standard input
        filehandle after parsing.
        )r�sys�stdin)rs r�parse_stdinzParser.parse_stdinDs���z�z�#�)�$�$�$rc�F�|�t|����S)z:Parse a string containing one or more lines of TAP output.)rr)r�texts  r�
parse_textzParser.parse_textLs���z�z�(�4�.�.�)�)�)rc#�K�|5	t|��}n#t$rYddd��dSwxYw|�|�����}t	j|g|��}|jdkrE|jdkr:tr$tt	j|g|����}ntd��|D],}|�|���|��V��-	ddd��dS#1swxYwYdS)awGenerate tap.line.Line objects, given a file-like object `fh`.

        `fh` may be any object that implements both the iterator and
        context management protocol (i.e. it can be used in both a
        "with" statement and a "for...in" statement.)

        Trailing whitespace and newline characters will be automatically
        stripped from the input lines.
        N�versionrz�
WARNING: Optional imports not found, TAP 13 output will be
    ignored. To parse yaml, see requirements in docs:
    https://tappy.readthedocs.io/en/latest/consumers.html#tap-version-13)�next�
StopIteration�
parse_line�rstrip�	itertools�chain�categoryr�ENABLE_VERSION_13r�print)r�fh�
first_line�first_parsed�fh_new�lines      rrzParser.parsePs������	=�	=�
�!�"�X�X�
�
�� �
�
�
��		=�	=�	=�	=�	=�	=�	=�	=�
�����?�?�:�+<�+<�+>�+>�?�?�L��_�j�\�2�6�6�F��$�	�1�1�l�6J�b�6P�6P�$��%�i�o�z�l�B�&G�&G�H�H�F�F��L�����
=�
=���o�o�d�k�k�m�m�V�<�<�<�<�<�<�
=�%	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=�	=����	=�	=�	=�	=�	=�	=s-�C=��C=�
0�C=�0�B?C=�=D�DNc�|�|j�|��}|r|�d||��S|j�|��}|r|�d||��S|j�|��rt|��S|j�|��}|r|�|��S|j�|��}|r"t|�
d����S|j�|��}|r|�|��St��S)z3Parse a line into whatever TAP category it belongs.TF�reason)�ok�match�
_parse_result�not_ok�
diagnosticr�plan�_parse_plan�bailr�groupr�_parse_versionr	)rrr)r1s    rr"zParser.parse_lineos/����
�
�d�#�#���	7��%�%�d�E�2�6�6�6���!�!�$�'�'���	8��%�%�e�U�B�7�7�7��?� � ��&�&�	$��d�#�#�#��	����%�%���	+��#�#�E�*�*�*��	����%�%���	/�����H�-�-�.�.�.���"�"�4�(�(���	.��&�&�u�-�-�-��y�y�rc���t|�d����}t|�d����}|jr|jst��St
||��S)zParse a matching plan line.�expected�	directive)�intr8rr�skipr	r)rr1�expected_testsr<s    rr6zParser._parse_plan�sc���U�[�[��4�4�5�5���e�k�k�+�6�6�7�7�	��>�	�)�.�	��9�9���N�I�.�.�.rc
���d}	|�HtrAt|t��r,|j�|�����}n#t$rYnwxYw|�kt||�d��|�d���	��t|�d�������S|�d��}|�||��}t||�d��|�d���	��t|�d����|���S)z4Parse a matching result line into a result instance.N�number�descriptionr<)rArBr<�indent)rArBr<�raw_yaml_block)r'�
isinstancer�yaml_block_startr1�peekr!rr8�stripr�_extract_yaml_block)rr0r1r)�
peek_matchrC�concat_yamls       rr2zParser._parse_result�sL���
�	��~�"3�~�
�2�x�8P�8P�~�!�2�8�8������C�C�
����	�	�	��D�	���������{�{�8�,�,�!�K�K�
�6�6�<�<�>�>�#�E�K�K��$<�$<�=�=�	���
��!�!�(�+�+���.�.�v�r�:�:�����;�;�x�(�(����M�2�2�8�8�:�:�����K� 8� 8�9�9�&�
�
�
�	
s�A
A�
A�Ac�"�g}tjd|����}	t|��|�|�����r�|�t|���|dd����|j�|�����rt|��n'|�|�������n#t$rYnwxYwd�	|��S)z,Extract a raw yaml block from a file handler�^��)
�re�compiler r1rG�append�replace�yaml_block_endr!�join)rrCr)�raw_yaml�indent_matchs     rrIzParser._extract_yaml_block�s������z�-�v�-�-�0�0��		���H�H�H��$�$�R�W�W�Y�Y�/�/�
�����R��� 0� 0���Q� ?� ?�@�@�@��&�,�,�R�W�W�Y�Y�7�7����H�H�H���$�$�R�W�W�Y�Y�/�/�
����	�	�	��D�	�����w�w�x� � � s�CC,�,
C9�8C9c��t|�d����}||jkrtd���t	|��S)Nrz?It is an error to explicitly specify any version lower than 13.)r=r8�TAP_MINIMUM_DECLARED_VERSION�
ValueErrorr
)rr1rs   rr9zParser._parse_version�sN���e�k�k�)�,�,�-�-���T�6�6�6��Q���
��w���r)N)�__name__�
__module__�__qualname__�__doc__�result_baserPrQ�VERBOSEr0r3r5r4r7rrFrTrYrrrrr"r6r2rIr9�rrr
r
sw������+�+��K�
���F�[�(�"�*�	5�	5�B�
�R�Z��k�1�2�:�
>�
>�F��2�:�	�	�
�
�
�D����E�"�"�J��2�:�	�
	�
�
��D��b�j�:�;�;�G�!�r�z�"6�7�7���R�Z�
�.�.�N�#%� �*�*�*�%�%�%�*�*�*�=�=�=�>����6	/�	/�	/�
�
�
�
�2!�!�!�  � � � � rr
)r$rPr�ior�
tap.directiver�tap.linerrrrr	r
�yaml�more_itertoolsrr'�ImportErrorr
rarr�<module>rhs������	�	�	�	�
�
�
�
�������#�#�#�#�#�#�E�E�E�E�E�E�E�E�E�E�E�E�E�E�E�E���K�K�K�'�'�'�'�'�'�����������������r �r �r �r �r �r �r �r �r �r s�7�A�A

?>