ok

Mini Shell

Direktori : /opt/cloudlinux/venv/lib/python3.11/site-packages/guppy/gsl/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib/python3.11/site-packages/guppy/gsl/__pycache__/DottedTree.cpython-311.pyc

�

�܋fW"��R�dZGd�de��ZGd�d��Zd�Zd�Zd�ZdS)	a�
Handling of tree structures given in a special 'dotted' syntax.
This represents trees of nodes with strings as tags,
in a readable and writable and easy to parse syntax.

There are two main functions, unparse_sexpr and parse_string.
When parsing, the result is by default given in 'sexpr' format:
each node is a tuple of the form

    (tag, ) or (tag, node) or (tag, node, node) ...

The following invariant is intended to hold for every node x,

    parse_string(unparse_sexpr(x)) == x

Currently the following invariant has been tested for some strings:

    unparse_sexpr(parse_string(s)).strip() == s.strip()

[It only holds on stripped results but may be fixed sometime.]

c�$�eZdZdZd�Zd�Zd�ZdS)�Node��tag�children�indexc�0�||_||_||_dS�Nr)�selfrrrs    �g/builddir/build/BUILD/cloudlinux-venv-1.0.6/venv/lib64/python3.11/site-packages/guppy/gsl/DottedTree.py�__init__z
Node.__init__s����� ��
���
�
�
�c�P�|jftd�|jD����zS)Nc�6�g|]}|�����S�)�as_sexpr)�.0�cs  r�
<listcomp>z!Node.as_sexpr.<locals>.<listcomp>"s ��#H�#H�#H�Q�A�J�J�L�L�#H�#H�#Hr
)r�tupler�r
s rrz
Node.as_sexpr!s*����{�U�#H�#H�$�-�#H�#H�#H�I�I�I�Ir
c�P�|jj�d|j�d|j�d|j�d�S)N�(z, �))�	__class__�__name__rrrrs r�__repr__z
Node.__repr__$s5���N�#�#�#��H�H�H��M�M�M��J�J�J�	�	r
N)r�
__module__�__qualname__�	__slots__rrrrr
rrrsI������+�I����
J�J�J�����r
rc�`�eZdZdZdZdZdZd�Zd�ZeZ	dd�Z
dd	�Zdd
�Zdd�Z
d�Zd
�Zd�ZdS)�_GLUECLAMP_)z_parent.FileIO:IO)�node�dotchar�.�\c�(�|ft|��zSr	)r�r
rr�	lineindexs    r�
node_sexprz_GLUECLAMP_.node_sexprGs���v��h���'�'r
c�>�t|t|��|��Sr	)rrr's    r�	node_nodez_GLUECLAMP_.node_nodeRs���C��x���)�4�4�4r
Nc�^�|�|j�|��|��Sr	)�parse_string�IO�	read_file)r
�file�srcs   r�
parse_filez_GLUECLAMP_.parse_fileWs(��� � ���!2�!2�4�!8�!8�#�>�>�>r
c��|j}|j}g}|}			t|��\}}
n#t$rd}
Yn1wxYw|
�|��s|�|
��nn�St
|��D]R\}}|�||z��s|�||z|z��r|t|��d�||<�S|dgkrd}nd�|��}	|
�:t|
��|ks'|
||ks|
�||dzz��s||
|�	|||	��fSt|
��|dzkr6|
|dz|kr'|�td���|�d|��|�|dz|
|dzd�g|||��\}}
}
|�|
����)N���
zLevel must increase with 1 max)
r#�	quotechar�next�
StopIteration�
startswith�append�	enumerate�len�joinr"�SyntaxError�error�
parse_iter)r
�posrr(�itr1r#r7r�	firstline�nextvar�i�t�childs              rrAz_GLUECLAMP_.parse_iteres!���,���N�	����	�		�
�%)�"�X�X�"�	�7�7�� �
�
�
�����
�����%�%�g�.�.�
��
�
�7�#�#�#�#��		� ��n�n�	,�	,�F�Q�����Y�w�.�/�/�
,��L�L��9�!4�W�!<�=�=�
,��3�y�>�>�?�?�+��A����2�$�;�;��C�C��)�)�C�.�.�C�	#���3�w�<�<�3�#6�#6��3�<�7�*�*��*�*�7�C��E�?�;�;�+� �'�4�9�9�S�(�I�+N�+N�N�N��7�|�|�c�!�e�#�#���A���'�(A�(A��;�%�&F�G�G�G��I�I�>�	�J�J�J�(,����A����A�����?P�8A�2�s�)L�)L�%�I�w���O�O�E�"�"�"�	#s�(�7�7c�f�t|��}|�dgd||��\}}}|�J�|S)N�)r<rA)r
�linesr1rCr(rEr"s       r�parse_linesz_GLUECLAMP_.parse_lines�s=��
�u�
�
��#'�?�?�1�b�!�R��#E�#E� �	�7�D������r
c�b�|r|�d��}ng}|�||��S�Nr6)�splitrL)r
�stringr1rKs    rr-z_GLUECLAMP_.parse_string�s8���	��L�L��&�&�E�E��E�����s�+�+�+r
c�P�|�|�����Sr	)�
unparse_sexprr)r
r"s  r�unparse_nodez_GLUECLAMP_.unparse_node�s���!�!�$�-�-�/�/�2�2�2r
c�\����g����fd���d|��d����S)Nc�������||d����|dd�D]}�|dz|���dS)NrJr4)r;�unparse_tag)�depth�sexpr�x�lir
�unparses   ���rr[z*_GLUECLAMP_.unparse_sexpr.<locals>.unparse�sc����I�I�d�&�&�u�e�A�h�7�7�8�8�8��1�2�2�Y�
$�
$�����a���#�#�#�#�
$�
$r
rJr6)r>)r
rXrZr[s` @@rrRz_GLUECLAMP_.unparse_sexpr�sQ�����
��	$�	$�	$�	$�	$�	$�	$�
	���5�����y�y��}�}�r
c��|j|j}}|�d��}t|��D]:\}}|�|��s|�||z��r||z||<�;d�|��}||z|z}|SrN)r#r7rOr<r:r>)r
rWrr#r7rFrGs       rrVz_GLUECLAMP_.unparse_tag�s���!�\�4�>����i�i��o�o����n�n�	'�	'�F�Q�����W�%�%�
'��L�L��W�!4�5�5�
'�"�Q���A����i�i��n�n���e�m�C����
r
r	)rrr�	_imports_�	_chgable_r#r7r)r+r"r2rArLr-rSrRrVrr
rr!r!,s��������I�"�I��G��I�(�(�(�5�5�5��D�?�?�?�?�$#�$#�$#�$#�L����,�,�,�,�3�3�3�	�	�	�	�	�	�	�	r
r!c�:���	�
�ddlm}|��jjj��j�_�j}�j}ddgddgddgd	d
gddgd
dgddgddgddgddgddgddgddgddgdd gd!d"gd#d$gfD]O\}}||��}|�||ksJ�||�����|���ksJ��P�j	�j
dddg�ddl�
���	�
fd%��	td&��D]+}�	d'��}||��}||��}||ksJ��,dS)(NrJ��Rootr5)r5�a�rbz.a)r5rcza
.b)rb)�bza
b
.c)za
b)rz
.a
..a)r6)rbrczhello
.a
.b
..ba
x
..bb)�hellorc)rd)zba
x)�bb�\.�r$z.\.)r5rhr%)r%z.
\)r5)z
\z\\.)rgz. tag)r5)z tag� )rir6)r6�
a)rjz�
initial
text
.aspect for guppy.hsp
..returns
...type A
...latex
~\
\..~|begincolorbox|~raw::~LaTeX~\
~\
~~~{	extbackslash}{	extbackslash}begin{\{}center{\}}~\
.aspect for guppy.gsl
..contains DottedTree
)z
initial
text)zaspect for guppy.hsp)�returns)ztype A)zclatex
~\
..~|begincolorbox|~raw::~LaTeX~\
~\
~~~{	extbackslash}{	extbackslash}begin{\{}center{\}}~\)zaspect for guppy.gsl)zcontains DottedTree
c�������d���}�����d����}��fd�t|��D��}��||d��S)NrJr5c�,��g|]}��dz
����S)r4r)rrF�maxchild�randnodes  ��rrz,test_1.<locals>.randnode.<locals>.<listcomp>
s'���B�B�B�Q�H�H�X�a�Z�(�(�B�B�Br
)�randint�shuffler>�ranger")rn�numchildrr�chars�dtro�randoms`   ����rroztest_1.<locals>.randnodesp�����>�>�!�X�.�.�����u�����g�g�e�n�n��B�B�B�B�B�%��/�/�B�B�B���w�w�s�H�a�(�(�(r
�
�)
�guppyra�gsl�
DottedTreer)r"r-rR�stripr7r#rvrr)ra�parser[rY�y�zrFrtrurorvs       @@@@r�test_1r��s�������������	
�����	�	$�B��m�B�G��O�E���G�
�U��	�f�
�	
�|��	�-� �	�%�&�	�/�0�	+�9�	;�
���	���	
�w��	�/�"�	���
�#�$�

�f�
�	
�w��	���
�
+�	,�93�7/�7/���1�h
�E�!�H�H���=���6�6�6�6��w�q�z�z���!�!�Q�W�W�Y�Y�.�.�.�.�.��\�2�:�t�S�#�6�E��M�M�M�)�)�)�)�)�)�)�)��2�Y�Y�����H�Q�K�K���G�A�J�J���E�!�H�H���A�v�v�v�v�v�	�r
c�<�ddlm}|��jjj}|j}|j}|d��}t
dt
dt
ddd��fd	��t
d
dd��fd��}t|��t|��ksJ�dS)NrJr`z'line 0
.line 1
..line 2
line 3
.line 4
zline 0zline 1z
line 2
line 3r�r4zline 4
�)ryrarzr{r-rSr�repr)rarur}r[r"�exps      r�test_2r�s���������	
�����	�	$�B��O�E��o�G��5����D��x��X��#�R��+�+�
-�q�	2�	2��Z��Q���!�#$�%�%�C���:�:��c���"�"�"�"�"�"r
c�>�t��t��dSr	)r�r�rr
r�	test_mainr�/s��
�H�H�H�
�H�H�H�H�Hr
N)�__doc__�objectrr!r�r�r�rr
r�<module>r�s�����0�����6����&I�I�I�I�I�I�I�I�XY�Y�Y�x#�#�#�6
�
�
�
�
r

Zerion Mini Shell 1.0