HEX
Server: Apache
System: Linux sg2plmcpnl492417.prod.sin2.secureserver.net 4.18.0-553.58.1.lve.el8.x86_64 #1 SMP Fri Jul 4 12:07:06 UTC 2025 x86_64
User: nyiet8349bzl (9207396)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/python38/lib/python3.8/site-packages/pip/_vendor/pyparsing/__pycache__/testing.cpython-38.pyc
U

��e�4�@sBddlmZddlZddlmZmZmZmZmZGdd�d�Z	dS)�)�contextmanagerN�)�
ParserElement�ParseException�Keyword�__diag__�
__compat__c@sfeZdZdZGdd�d�ZGdd�d�Zedeej	e
ej	e
eeej	eej	eed	�d
d��ZdS)
�pyparsing_testzB
    namespace class for classes useful in writing unit tests
    c@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)z&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
        cCs
i|_dS�N)�
_save_context��self�r�A/tmp/pip-unpacked-wheel-uzdrexel/pip/_vendor/pyparsing/testing.py�__init__-sz/pyparsing_test.reset_pyparsing_context.__init__cCs�tj|jd<tj|jd<tj|jd<tj|jd<tj|jd<tjrRtjj	|jd<n
d|jd<tj
|jd<tj|jd<d	d
�tj
D�|jd<dtji|jd
<|S)N�default_whitespace�default_keyword_chars�literal_string_class�verbose_stacktrace�packrat_enabled�packrat_cache_size�
packrat_parse�recursion_enabledcSsi|]}|tt|��qSr)�getattrr)�.0�namerrr�
<dictcomp>Fsz?pyparsing_test.reset_pyparsing_context.save.<locals>.<dictcomp>r�collect_all_And_tokensr)r�DEFAULT_WHITE_CHARSrr�DEFAULT_KEYWORD_CHARS�_literalStringClassr�_packratEnabled�
packrat_cache�size�_parse�_left_recursion_enabledr�
_all_namesrrrrrr�save0s4����
����
z+pyparsing_test.reset_pyparsing_context.savecCs�tj|jdkr t�|jd�|jdt_|jdt_t�|jd�|jd��D]\}}|rht	j
nt	j|�qVdt_|jdr�t�
|jd�n|jd	t_|jd
t_|jdt_|S)NrrrrrFrrrrr)rrrZset_default_whitespace_charsrrr�inlineLiteralsUsing�itemsr�enable�disabler!Zenable_packratr$r%rr)r
r�valuerrr�restorePs.����
�z.pyparsing_test.reset_pyparsing_context.restorecCst|��}|j�|j�|Sr
)�typer�update)r
�retrrr�copyqs
z+pyparsing_test.reset_pyparsing_context.copycCs|��Sr
)r'rrrr�	__enter__vsz0pyparsing_test.reset_pyparsing_context.__enter__cGs|��dSr
)r-)r
�argsrrr�__exit__ysz/pyparsing_test.reset_pyparsing_context.__exit__N)
�__name__�
__module__�__qualname__�__doc__rr'r-r1r2r4rrrr�reset_pyparsing_contexts !r9c@sJeZdZdZddd�Zddd�Zddd	�Zdd
d�Zee	dfdd
��Z
dS)z&pyparsing_test.TestParseResultsAssertszk
        A mixin class to add parse results assertion methods to normal unittest.TestCase classes.
        NcCs<|dk	r|j||��|d�|dk	r8|j||��|d�dS)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_listZas_dict)r
�result�
expected_list�
expected_dictr;rrr�assertParseResultsEquals�sz?pyparsing_test.TestParseResultsAsserts.assertParseResultsEqualsTcCs@|j|dd�}|r t|���nt|���|j|||d�dS)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)Z	parse_all)r?r;N��parse_string�print�dumpr=rA)r
�expr�test_stringr?r;�verboser>rrr�assertParseAndCheckList�s
z>pyparsing_test.TestParseResultsAsserts.assertParseAndCheckListcCs@|j|dd�}|r t|���nt|���|j|||d�dS)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)r@r;NrB)r
rFrGr@r;rHr>rrr�assertParseAndCheckDict�s
z>pyparsing_test.TestParseResultsAsserts.assertParseAndCheckDictc
Cs
|\}}|dk	r�dd�t||�D�}|D]�\}}}	tdd�|	D�d�}
tdd�|	D�d�}|dk	r�|j||
pn|d��t|t�r�|�W5QRXq(tdd�|	D�d�}td	d�|	D�d�}
||
fd
kr�|j|||
|
p�|d�q(td|���q(|j||dk	r�|nd
d�dS)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)]
            NcSsg|]\}}||f��qSrr)r�rpt�expectedrrr�
<listcomp>�s�zOpyparsing_test.TestParseResultsAsserts.assertRunTestResults.<locals>.<listcomp>css|]}t|t�r|VqdSr
)�
isinstance�str�r�exprrr�	<genexpr>�s
zNpyparsing_test.TestParseResultsAsserts.assertRunTestResults.<locals>.<genexpr>css&|]}t|t�rt|t�r|VqdSr
)rOr.�
issubclass�	ExceptionrQrrrrS�s

�)�expected_exceptionr;css|]}t|t�r|VqdSr
)rO�listrQrrrrS�s
css|]}t|t�r|VqdSr
)rO�dictrQrrrrS�s
)NN)r?r@r;zno validation for zfailed runTestsr:)�zip�next�assertRaisesrOrUrArD�
assertTrue)r
�run_tests_report�expected_parse_resultsr;�run_test_success�run_test_results�mergedrGr>rM�fail_msgrVr?r@rrr�assertRunTestResults�sV�����
����z;pyparsing_test.TestParseResultsAsserts.assertRunTestResultsc	cs$|j||d��dVW5QRXdS)Nr:)r[)r
�exc_typer;rrr�assertRaisesParseException�szApyparsing_test.TestParseResultsAsserts.assertRaisesParseException)NNN)NT)NT)NN)r5r6r7r8rArIrKrcrrrerrrr�TestParseResultsAsserts|s �

�
�
�
?rfNT�|)�s�
start_line�end_line�expand_tabs�eol_mark�mark_spaces�mark_control�returncs4|r|��}|dk	r�t�t|�}|dkr`dd�ttdd�tdd��D�}d	|d
<t�|�}d�n0t|��t��fdd�ttdd
��d
gD��}|�	|�}|dk	r�|dkr�|dkr�t�ddd��}|�	|�}n|�
d|�}|dkr�d}|dkr�t|�}t|t|��}tt
d|�|�}|dk�r4|��|d|�}	n dd�|�d�|d|�D�}	|	�s^dStt|���t
dd�|	D��}
d�d}|
dk�r�|d�dd�tt
|
dd��D��d}nd}||d�dd�t|
d�D��d}
|d|
dd}|
|d���fdd�t|	|d �D��dS)!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
        N�unicodecSsi|]\}}||�qSrr)r�c�urrrrsz4pyparsing_test.with_line_numbers.<locals>.<dictcomp>r�!i$i3$i!$��csi|]
}|��qSrr)rrq)�ord_mark_controlrrrs� � i	$i#$)�	rwrcSsg|]}|d�qS)�␊r�r�linerrrrN*sz4pyparsing_test.with_line_numbers.<locals>.<listcomp>rzcss|]}t|�VqdSr
)�lenr{rrrrS/sz3pyparsing_test.with_line_numbers.<locals>.<genexpr>�ccss"|]}d�|dd��VqdS)zc                                                                                                   r�dNr�r�irrrrS4s�r�
css |]}d|dd��VqdS)z	         r�
Nrr�rrrrS?sr�Z
1234567890c3s,|]$\}}|��d��d|����VqdS)�d�:Nr)rr�r|)rl�lineno_widthrrrSFs�)�start)�
expandtabs�typing�castrPrY�range�	maketrans�ordrW�	translate�replacer}�min�max�
splitlines�split�join�	enumerate)rhrirjrkrlrmrnZtranstable_mapZtblZs_linesZmax_line_lenZleadZheader0Zheader1Zheader2r)rlr�rvr�with_line_numbers�s��
 �

 

����	�����
����z pyparsing_test.with_line_numbers)NNTrgNN)
r5r6r7r8r9rf�staticmethodrPr��Optional�int�boolr�rrrrr	s(hq��r	)
�
contextlibrr��corerrrrrr	rrrr�<module>s