%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/pyparsing/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/pyparsing/__pycache__/testing.cpython-312.pyc

�

&
�d�4��H�ddlmZddlZddlmZmZmZmZmZGd�d�Z	y)�)�contextmanagerN�)�
ParserElement�ParseException�Keyword�__diag__�
__compat__c���eZdZdZGd�d�ZGd�d�Ze						ddedeje
d	eje
d
ededejed
ejedefd��Zy)�pyparsing_testzB
    namespace class for classes useful in writing unit tests
    c�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	�&pyparsing_test.reset_pyparsing_contexta�
        Context manager to be used when writing unit tests that modify pyparsing config values:
        - packrat parsing
        - bounded recursion parsing
        - default whitespace characters.
        - default keyword characters
        - literal string auto-conversion class
        - __diag__ settings

        Example::

            with reset_pyparsing_context():
                # test that literals used to construct a grammar are automatically suppressed
                ParserElement.inlineLiteralsUsing(Suppress)

                term = Word(alphas) | Word(nums)
                group = Group('(' + term[...] + ')')

                # assert that the '()' characters are not included in the parsed tokens
                self.assertParseAndCheckList(group, "(abc 123 def)", ['abc', '123', 'def'])

            # after exiting context manager, literals are converted to Literal expressions again
        c��i|_y�N)�
_save_context��selfs �3/usr/lib/python3/dist-packages/pyparsing/testing.py�__init__z/pyparsing_test.reset_pyparsing_context.__init__-s
��!#�D��c���tj|jd<tj|jd<tj
|jd<tj|jd<tj|jd<tjr(tjj|jd<nd|jd<tj|jd<tj|jd<tjD�cic]}|tt|���c}|jd	<d
tj i|jd<|Scc}w)N�default_whitespace�default_keyword_chars�literal_string_class�verbose_stacktrace�packrat_enabled�packrat_cache_size�
packrat_parse�recursion_enabledr�collect_all_And_tokensr	)r�DEFAULT_WHITE_CHARSrr�DEFAULT_KEYWORD_CHARS�_literalStringClassr�_packratEnabled�
packrat_cache�size�_parse�_left_recursion_enabledr�
_all_names�getattrr	r)r�names  r�savez+pyparsing_test.reset_pyparsing_context.save0sT��7D�7X�7X�D���3�4�:A�:W�:W�D���6�7��1�1�
���&�
�8E�7W�7W�D���3�4�4A�4Q�4Q�D���0�1��,�,�"�/�/�4�4��"�"�(��<@��"�"�#7�8�2?�2F�2F�D����/��5�5�
���#�
�
;C�:M�:M�.�26��g�h��-�-�.�D���z�*�
)�*�*K�*K�0�D���|�,��K��.s�%E.c���tj|jdk7r"tj|jd�|jdt_|jdt
_tj|jd�|jdj�D]-\}}|rtjntj|��/dt_|jdr#tj|jd�n|jd	t_|jd
t_|jdt _|S)NrrrrrFrrrrr	)rr r�set_default_whitespace_charsrrr!�inlineLiteralsUsing�itemsr�enable�disabler#�enable_packratr&r'r	r)rr*�values   r�restorez.pyparsing_test.reset_pyparsing_context.restorePs@���1�1��%�%�&:�;�<��:�:��&�&�';�<��04�/A�/A�BV�/W�M�,�,0�,>�,>�?V�,W�G�)��-�-��"�"�#9�:�
� $�1�1�*�=�C�C�E�
G���e�?�E����x�/?�/?��F�
G�-2�M�)��!�!�"3�4��,�,�T�-?�-?�@T�-U�V�'+�'9�'9�/�'J�
�$�48�4F�4F�#�5�M�1�15�0B�0B�<�0P�J�-��Krc�p�t|��}|jj|j�|Sr)�typer�update)r�rets  r�copyz+pyparsing_test.reset_pyparsing_context.copyqs.���$�t�*�,�C����$�$�T�%7�%7�8��Jrc�"�|j�Sr)r+rs r�	__enter__z0pyparsing_test.reset_pyparsing_context.__enter__vs���9�9�;�rc�$�|j�yr)r4)r�argss  r�__exit__z/pyparsing_test.reset_pyparsing_context.__exit__ys���L�L�NrN)
�__name__�
__module__�__qualname__�__doc__rr+r4r9r;r>�rr�reset_pyparsing_contextr
s'��	�0	$�	�@	�B	�
	�	rrDc�N�eZdZdZ	dd�Z	d	d�Z	d	d�Z	d
d�Zee	dfd��Z
y)�&pyparsing_test.TestParseResultsAssertszk
        A mixin class to add parse results assertion methods to normal unittest.TestCase classes.
        Nc��|�"|j||j�|��|�#|j||j�|��yy)z�
            Unit test assertion to compare a :class:`ParseResults` object with an optional ``expected_list``,
            and compare any defined results names with an optional ``expected_dict``.
            N��msg)�assertEqual�as_list�as_dict)r�result�
expected_list�
expected_dictrIs     r�assertParseResultsEqualsz?pyparsing_test.TestParseResultsAsserts.assertParseResultsEquals�sM���(�� � �����0@�c� �J��(�� � �����0@�c� �J�)rc��|j|d��}|rt|j��nt|j��|j	|||��y)z�
            Convenience wrapper assert to test a parser element and input string, and assert that
            the resulting ``ParseResults.asList()`` is equal to the ``expected_list``.
            T)�	parse_all)rNrIN��parse_string�print�dumprKrP)r�expr�test_stringrNrI�verboserMs       r�assertParseAndCheckListz>pyparsing_test.TestParseResultsAsserts.assertParseAndCheckList�sO���&�&�{�d�&�C�F���f�k�k�m�$��f�n�n�&�'��)�)�&�
�SV�)�Wrc��|j|d��}|rt|j��nt|j��|j	|||��y)z�
            Convenience wrapper assert to test a parser element and input string, and assert that
            the resulting ``ParseResults.asDict()`` is equal to the ``expected_dict``.
            T)�parseAll)rOrINrS)rrWrXrOrIrYrMs       r�assertParseAndCheckDictz>pyparsing_test.TestParseResultsAsserts.assertParseAndCheckDict�sO���&�&�{�T�&�B�F���f�k�k�m�$��f�n�n�&�'��)�)�&�
�SV�)�Wrc�.�|\}}|��t||�D��cgc]\}}g|�|����}}}|D]�\}	}
}td�|D�d�}td�|D�d�}|�4|j||xs|��5t|
t�r|
�	ddd��ctd�|D�d�}
td�|D�d�}|
|fdk7r|j|
|
||xs|����t
d	|	�����|j||�|��yd
��ycc}}w#1swY��xYw)ah
            Unit test assertion to evaluate output of ``ParserElement.runTests()``. If a list of
            list-dict tuples is given as the ``expected_parse_results`` argument, then these are zipped
            with the report tuples returned by ``runTests`` and evaluated using ``assertParseResultsEquals``.
            Finally, asserts that the overall ``runTests()`` success value is ``True``.

            :param run_tests_report: tuple(bool, [tuple(str, ParseResults or Exception)]) returned from runTests
            :param expected_parse_results (optional): [tuple(str, list, dict, Exception)]
            Nc3�BK�|]}t|t�s�|���y�wr)�
isinstance�str��.0�exps  r�	<genexpr>zNpyparsing_test.TestParseResultsAsserts.assertRunTestResults.<locals>.<genexpr>�s����I��J�s�C�4H��I����c3�`K�|]&}t|t�rt|t�r|���(y�wr)r`r6�
issubclass�	Exceptionrbs  rrezNpyparsing_test.TestParseResultsAsserts.assertRunTestResults.<locals>.<genexpr>�s+����� #�)�#�t�4��C��9S� ��s�,.)�expected_exceptionrIc3�BK�|]}t|t�s�|���y�wr)r`�listrbs  rrezNpyparsing_test.TestParseResultsAsserts.assertRunTestResults.<locals>.<genexpr>������N�S�
�3��8M�S�N�rfc3�BK�|]}t|t�s�|���y�wr)r`�dictrbs  rrezNpyparsing_test.TestParseResultsAsserts.assertRunTestResults.<locals>.<genexpr>�rmrf�NN)rNrOrIzno validation for zfailed runTestsrH)�zip�next�assertRaisesr`rirPrU�
assertTrue)r�run_tests_report�expected_parse_resultsrI�run_test_success�run_test_results�rpt�expected�mergedrXrM�fail_msgrjrNrOs               r�assertRunTestResultsz;pyparsing_test.TestParseResultsAsserts.assertRunTestResults�s���2B�.��.�%�1�*-�-=�?U�)V��%��X�%�c�$�8�$����6<�%H�1�K��� $�I��I�4� �H�*.��'/��
�
*�&�*�5�!�.�.�/A�x��SV�/��-� *�&�)�<�&,�� =�-�-�)-�N�H�N�PT�)�
�)-�N�H�N�PT�)�
�*�=�9�\�I� �9�9� &�.;�.;�$,�O��	:��"�$6�{�o�"F�G�K%H�P
�O�O� �S�_�c�
�
�BS�
�
��Y�(-�-�s�D�3D�D	c#�dK�|j||��5d��ddd�y#1swYyxYw�w)NrH)rs)r�exc_typerIs   r�assertRaisesParseExceptionzApyparsing_test.TestParseResultsAsserts.assertRaisesParseException�s0�����"�"�8��"�5�
��
�
�
�s�0�$�	0�-�0)NNN)NTrp)r?r@rArBrPrZr]r}rrr�rCrr�TestParseResultsAssertsrF|sT��	�
GK�
	K�GK�	X�GK�	X�FJ�=	�~
�6D�$�	�
�	rr�N�s�
start_line�end_line�expand_tabs�eol_mark�mark_spaces�mark_control�returnc
����|r|j�}|��tjt|�}|dk(rPt	tdd�tdd��D��cic]\}}||��
}	}}d|	d<tj
|	�}
d�nFt|�}tj
ttdd	��dgzD�cic]}||��c}�}
|j|
�}|�F|d
k7rA|dk(r*tj
ddd
��}
|j|
�}n|jd
|�}|�d}|�t|�}t|t|��}ttd|�|�}|dk7r|j�|dz
|}n'|jd�|dz
|D�
cgc]}
|
dz��	}}
|sytt|���td�|D��}d
�dzz}|dk\r5|dj!d�tt|dzd��D��zdz}nd}||zdj!d�t|dz�D��zdz}|d|dzzzdz}||zdj!��fd�t#||��D��zdzScc}}wcc}wcc}
w)u	
        Helpful method for debugging a parser - prints a string with line and column numbers.
        (Line and column numbers are 1-based.)

        :param s: tuple(bool, str - string to be printed with line and column numbers
        :param start_line: int - (optional) starting line number in s to print (default=1)
        :param end_line: int - (optional) ending line number in s to print (default=len(s))
        :param expand_tabs: bool - (optional) expand tabs to spaces, to match the pyparsing default
        :param eol_mark: str - (optional) string to mark the end of lines, helps visualize trailing spaces (default="|")
        :param mark_spaces: str - (optional) special character to display in place of spaces
        :param mark_control: str - (optional) convert non-printing control characters to a placeholding
                                 character; valid values:
                                 - "unicode" - replaces control chars with Unicode symbols, such as "␍" and "␊"
                                 - any single character string - replace control characters with given string
                                 - None (default) - string is displayed as-is

        :return: str - input string with leading line numbers and column number headers
        �unicoder�!i$i3$i!$��� � i	$i#$)�	r�ru␊c3�2K�|]}t|����y�wr)�len)rc�lines  rrez3pyparsing_test.with_line_numbers.<locals>.<genexpr>/s����9��3�t�9�9����cc3�4K�|]}d�|dzdz�����y�w)zc                                                                                                   r�dNrC�rc�is  rrez3pyparsing_test.with_line_numbers.<locals>.<genexpr>4s)������ �j�!�a�%�3���0��s�r��
c3�2K�|]}d|dzdz�����y�w)z	         r�
NrCr�s  rrez3pyparsing_test.with_line_numbers.<locals>.<genexpr>?s����X�Q�	�1�q�5�B�,��0�X�r�r��
1234567890c3�>�K�|]\}}|��d��d|�������y�w)�d�:NrC)rcr�r�r��lineno_widths   ��rrez3pyparsing_test.with_line_numbers.<locals>.<genexpr>Fs6�������A�t��l�^�1�$�%�Q�t�f�X�J�7��s�)�start)�
expandtabs�typing�castrarq�range�	maketrans�ordrl�	translate�replacer��min�max�
splitlines�split�join�	enumerate)r�r�r�r�r�r�r��c�u�transtable_map�tbl�ord_mark_control�s_linesr��max_line_len�lead�header0�header1�header2r�s    `              @r�with_line_numbersz pyparsing_test.with_line_numbers�s����8�����A��#�!�;�;�s�L�9�L��y�(�%(��q�"��u�V�V�7L�%M�"�!�Q��A�q�D�"��"�'-��s�#��m�m�N�3����#&�|�#4� ��m�m�26�u�Q��|�2D��u�2L�M�Q�Q�(�(�M������C� �A��"�{�c�'9��i�'��m�m��F�$;�<���K�K��$���I�I�c�;�/�����J����1�v�H��x��Q��(����Q�
�+�X�6�
��9�$��l�l�n�Z�!�^�h�?�G�01�����z�A�~�PX�0Y�Z��t�e�|�Z�G�Z����3�x�=�)���9��9�9���l�Q�&�'���2����'�'��"�3�|�s�':�A�#>�?����
��
��G���
��g�g�X�%�<�-�SU�BU�@V�:W�X�X�
Y��
�	���L�=�B�+>�)?�@�@�4�G����
��i�i��(��
�C���
��

�	
��k"��N��&[s�
I?�;
J�J
)NNT�|NN)
r?r@rArBrDr��staticmethodrar��Optional�int�boolr�rCrrrrs����f�f�Po�o�b�,0�)-� ��,0�-1�]
��]
��O�O�C�(�]
��/�/�#�&�]
��	]
�
�]
��_�_�S�)�
]
��o�o�c�*�]
�

�]
��]
rr)
�
contextlibrr��corerrrrr	rrCrr�<module>r�s#��&�
���|
�|
r

Zerion Mini Shell 1.0