HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberPanel/lib64/python3.10/site-packages/pyparsing/__pycache__/testing.cpython-310.pyc
o

��hZ9�@sJddlmZddlZddlZddlmZmZmZmZm	Z	Gdd�d�Z
dS)�)�contextmanagerN�)�
ParserElement�ParseException�Keyword�__diag__�
__compat__c@s�eZdZdZGdd�d�ZGdd�d�Ze						dd	dd
�dedej	e
d
ej	e
dededej	edej	edejee
fdedefdd��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�G/usr/local/CyberPanel/lib/python3.10/site-packages/pyparsing/testing.py�__init__/s
z/pyparsing_test.reset_pyparsing_context.__init__cCs�tj|jd<tj|jd<tj|jd<tj|jd<tj|jd<tjr)tjj	|jd<nd|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>Hs�z?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�save2s&�
�
��
�z+pyparsing_test.reset_pyparsing_context.savecCs�tj|jdkrt�|jd�|jdt_|jdt_t�|jd�|jd��D]\}}|r4t	j
nt	j|�q+dt_|jdrKt�
|jd�n|jd	t_|jd
t_|jdt_|S)NrrrrrFrrrrr)rrr�set_default_whitespace_charsrrr�inlineLiteralsUsing�itemsr�enable�disabler!�enable_packratr$r%rr)r
r�valuerrr�restoreRs,���
�z.pyparsing_test.reset_pyparsing_context.restorecCst|��}|j�|j�|Sr
)�typer�update)r
�retrrr�copyss
z+pyparsing_test.reset_pyparsing_context.copycCs|��Sr
)r'rrrr�	__enter__xsz0pyparsing_test.reset_pyparsing_context.__enter__cGs|��dSr
)r/)r
�argsrrr�__exit__{sz/pyparsing_test.reset_pyparsing_context.__exit__N)
�__name__�
__module__�__qualname__�__doc__rr'r/r3r4r6rrrr�reset_pyparsing_contexts !r;c@sTeZdZdZ	ddd�Z	ddd�Z	ddd	�Z	dd
d�Zee	ddfdd
��Z
dS)z&pyparsing_test.TestParseResultsAssertszk
        A mixin class to add parse results assertion methods to normal unittest.TestCase classes.
        NcCs@|dur|j||��|d�|dur|j||��|d�dSdS)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_dictr=rrr�assertParseResultsEquals�s
�z?pyparsing_test.TestParseResultsAsserts.assertParseResultsEqualsTcC�@|j|dd�}|rt|���nt|���|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)�	parse_all)rBr=N��parse_string�print�dumpr?rD)r
�expr�test_stringrBr=�verboserArrr�assertParseAndCheckList��
z>pyparsing_test.TestParseResultsAsserts.assertParseAndCheckListcCrE)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)rCr=NrG)r
rKrLrCr=rMrArrr�assertParseAndCheckDict�rOz>pyparsing_test.TestParseResultsAsserts.assertParseAndCheckDictc	Cs<|\}}|dur|j||dur|ndd�dSdd�t||�D�}|D]k\}}}	tdd�|	D�d�}
tdd�|	D�d�}|dura|j||
pF|d	��t|t�rQ|�Wd�n1s[wYq#td
d�|	D�d�}tdd�|	D�d�}
||
fdkr�|j|||
|
p�|d
�q#td|���q#|j||dur�|ndd�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)]
            Nzfailed runTestsr<cSsg|]\}}g|�|�R�qSrr)r�rpt�expectedrrr�
<listcomp>�s��zOpyparsing_test.TestParseResultsAsserts.assertRunTestResults.<locals>.<listcomp>cs��|]
}t|t�r|VqdSr
)�
isinstance�str�r�exprrr�	<genexpr>���zNpyparsing_test.TestParseResultsAsserts.assertRunTestResults.<locals>.<genexpr>css(�|]}t|t�rt|t�r|VqdSr
)rVr0�
issubclass�	ExceptionrXrrrrZ�s���
�)�expected_exceptionr=csrUr
)rV�listrXrrrrZ�r[csrUr
)rV�dictrXrrrrZ�r[�NN)rBrCr=zno validation for )�
assertTrue�zip�next�assertRaisesrVr]rDrI)r
�run_tests_report�expected_parse_resultsr=�run_test_success�run_test_results�mergedrLrArS�fail_msgr^rBrCrrr�assertRunTestResults�sV�����
������
�z;pyparsing_test.TestParseResultsAsserts.assertRunTestResultsccs��|dur-t|t�rt�|�}|j|||d��}|VWd�dS1s&wYdS|j||d��}|VWd�dS1sCwYdS)Nr<)rVrW�re�escape�assertRaisesRegexre)r
�exc_type�expected_msgr=�ctxrrr�assertRaisesParseException�s�

"�"�zApyparsing_test.TestParseResultsAsserts.assertRaisesParseException)NNN)NTra)r7r8r9r:rDrNrQrlrrrsrrrr�TestParseResultsAsserts~s
�
�
�
�B�rtNT�|�)�indent�base_1�s�
start_line�end_line�expand_tabs�eol_mark�mark_spaces�mark_controlrwrx�returnc	s�|r|��}t�t�rd������|durZt�t|�}|dkr=dd�ttdd�tdd	��D�}	d
|	d<t�|	�}
d�nt	|��t��fd
d�t
tdd��dgD��}
|�|
�}|durz|dkrz|dkrtt�ddd��}
|�|
�}n|�d|�}|dur�d}|dur�t
|�}t|t
|��}ttd|�|�}|dkr�|��|||�}ndd�|�d�|||�D�}|s�dSt
t|���tdd�|D��}�d�d}
|dkr�|
|r�dndd�dd�t|r�dndt|dd��D��d}nd}|r�dnd|
d�dd�t|d�D��d}d}|
|�rdnd||dd}||d����fd d�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 by default - if debugging a parse action,
        pass base_1=False, to correspond to the loc value passed to the parse action.)

        :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
        :param indent: str | int - (optional) string to indent with line and column numbers; if an int
                                   is passed, converted to " " * indent
        :param base_1: bool - (optional) whether to label string using base 1; if False, string will be
                              labeled based at 0 (default=True)

        :return: str - input string with leading line numbers and column number headers
        � N�unicodecSsi|]\}}||�qSrr)r�c�urrrr's
�z4pyparsing_test.with_line_numbers.<locals>.<dictcomp>r�!i$i3$i!$�rvcsi|]}|��qSrr)rr�)�ord_mark_controlrrr0s� i	$i#$)�	r�cSsg|]}|d�qS)�␊r�r�linerrrrTCs�z4pyparsing_test.with_line_numbers.<locals>.<listcomp>r�css�|]}t|�VqdSr
)�lenr�rrrrZJs�z3pyparsing_test.with_line_numbers.<locals>.<genexpr>r�ccss$�|]
}d�|dd��VqdS)zc                                                                                                   r�dNr�r�irrrrZPs
��
�r��
css"�|]}d|dd��VqdS)z	         r�
Nrr�rrrrZ[s� r��
1234567890�0c3s2�|]\}}��|��d��d|����VqdS)�d�:Nr)rr�r�)r}rw�lineno_widthrrrZes
��
�)�start)�
expandtabsrV�int�typing�castrWrc�range�	maketrans�ordr_�	translate�replacer��min�max�
splitlines�split�join�	enumerate)ryrzr{r|r}r~rrwrx�transtable_map�tbl�s_lines�max_line_len�lead�header0�header1�digits�header2r)r}rwr�r�r�with_line_numbers�s�$
�
 �
�
�
����

����$������z pyparsing_test.with_line_numbers)NNTruNN)r7r8r9r:r;rt�staticmethodrWr��Optionalr��bool�Unionr�rrrrr	sFh}�	��������	�
��r	)�
contextlibrrmr��corerrrrrr	rrrr�<module>s