%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python37/lib64/python3.7/site-packages/guppy/gsl/__pycache__/
Upload File :
Create Path :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/guppy/gsl/__pycache__/DottedTree.cpython-37.pyc

B

�]W"�@s>dZGdd�de�ZGdd�d�Zdd�Zdd�Zd	d
�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@s(eZdZdZdd�Zdd�Zdd�ZdS)	�Node)�tag�children�indexcCs||_||_||_dS)N)rrr)�selfrrr�r�G/opt/alt/python37/lib64/python3.7/site-packages/guppy/gsl/DottedTree.py�__init__sz
Node.__init__cCs|jftdd�|jD��S)NcSsg|]}|���qSr)�as_sexpr)�.0�crrr�
<listcomp>"sz!Node.as_sexpr.<locals>.<listcomp>)r�tupler)rrrrr	!sz
Node.as_sexprcCsd|jj|j|j|jfS)Nz%s(%r, %r, %r))�	__class__�__name__rrr)rrrr�__repr__$s
z
Node.__repr__N)r�
__module__�__qualname__�	__slots__rr	rrrrrrsrc@speZdZdZdZdZdZdd�Zdd�ZeZ	dd
d�Z
ddd
�Zddd�Zddd�Z
dd�Zdd�Zdd�Zd	S)�_GLUECLAMP_)z_parent.FileIO:IO)�node�dotchar�.�\cCs|ft|�S)N)r
)rrr�	lineindexrrr�
node_sexprGsz_GLUECLAMP_.node_sexprcCst|t|�|�S)N)rr
)rrrrrrr�	node_nodeRsz_GLUECLAMP_.node_nodeNcCs|�|j�|�|�S)N)�parse_stringZIOZ	read_file)r�file�srcrrr�
parse_fileWsz_GLUECLAMP_.parse_filecCs�|j}|j}g}|}	xHyt|�\}}
Wntk
r@d}
PYnX|
�|�sX|�|
�qPqWxHt|�D]<\}}|�||�s�|�|||�rh|t|�d�||<qhW|dgkr�d}n
d�|�}x�|
dks�t|
�|ks�|
||ks�|
�||d��s||
|�	|||	�fSt|
�|dk�rP|
|d|k�rP|dk�rDt
d��n|�d|�|�|d|
|dd�g|||�\}}
}
|�|
�q�WdS)N��
�zLevel must increase with 1 max)
r�	quotechar�next�
StopIteration�
startswith�append�	enumerate�len�joinr�SyntaxError�error�
parse_iter)r�posrr�itrrr#r�	firstline�nextvar�i�tZchildrrrr-es@


$

z_GLUECLAMP_.parse_itercCs0t|�}|�dgd||�\}}}|dks,t�|S)N�)r(r-�AssertionError)r�linesrr/rr1rrrr�parse_lines�sz_GLUECLAMP_.parse_linescCs |r|�d�}ng}|�||�S)Nr!)�splitr7)r�stringrr6rrrr�sz_GLUECLAMP_.parse_stringcCs|�|���S)N)�
unparse_sexprr	)rrrrr�unparse_node�sz_GLUECLAMP_.unparse_nodecs(g����fdd���d|�d���S)Ncs>����||d��x"|dd�D]}�|d|�q$WdS)Nr4r")r'�unparse_tag)�depth�sexpr�x)�lir�unparserrrA�sz*_GLUECLAMP_.unparse_sexpr.<locals>.unparser4r!)r*)rr>r)r@rrArr:�s
z_GLUECLAMP_.unparse_sexprcCsl|j|j}}|�d�}x8t|�D],\}}|�|�sB|�||�r"||||<q"Wd�|�}|||}|S)Nr!)rr#r8r(r&r*)rr=rrr#r2r3rrrr<�s


z_GLUECLAMP_.unparse_tag)N)N)N)N)rrrZ	_imports_Z	_chgable_rr#rrrrr-r7rr;r:r<rrrrr,s


&


rcsBddlm}|�jjj��j�_�j}�j}x�ddgddgddgd	d
gddgd
dgddgddgddgddgddgddgddgddgdd gd!d"gd#d$ggD]<\}}||�}|dk	r�||ks�t�||��	�|�	�ks�t�q�W�j
�jdddg�ddl�����fd%d&��x8t
d'�D],}�d(�}||�}||�}||k�st��qWdS))Nr4)�Rootr )r �a)rCz.a)r )rCza
.b)rC)�bza
b
.c)za
b)rz
.a
..a)r!)rC)rCzhello
.a
.b
..ba
x
..bb)Zhello)rC)rD)zba
x)Zbbz\.)rz.\.)r )rr)rz.
\)r )z
\z\\.)z\.z. tag)r )z tag� )rEr!)r!z
a)z
az�
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)Zreturns)ztype A)zclatex
~\
..~|begincolorbox|~raw::~LaTeX~\
~\
~~~{	extbackslash}{	extbackslash}begin{\{}center{\}}~\)zaspect for guppy.gsl)zcontains DottedTree
csF��d��}����d���}��fdd�t|�D�}��||d�S)Nr4r csg|]}��d��qS)r"r)r
r2)�maxchild�randnoderrr
sz,test_1.<locals>.randnode.<locals>.<listcomp>)ZrandintZshuffler*�ranger)rFZnumchildrr)�chars�dtrG�random)rFrrGs


ztest_1.<locals>.randnode�
�)�guppyrB�gsl�
DottedTreerrrr:r5�stripr#rrKrH)rB�parserAr?�y�zr2r)rIrJrGrKr�test_1�sJ	rUcCsnddlm}|�jjj}|j}|j}|d�}tdtdtddd�fd	�td
dd�fd�}t|�t|�ksjt�dS)Nr4)rBz'line 0
.line 1
..line 2
line 3
.line 4
zline 0zline 1z
line 2
line 3r�r"zline 4
�)	rNrBrOrPrr;r�reprr5)rBrJrRrArZexprrr�test_2srYcCst�t�dS)N)rUrYrrrr�	test_main/srZN)�__doc__�objectrrrUrYrZrrrr�<module>s
\

Zerion Mini Shell 1.0