403Webshell
Server IP : 127.0.0.1  /  Your IP : 216.73.216.109
Web Server : Apache/2.4.54 (Win64) OpenSSL/1.1.1q PHP/8.1.10
System : Windows NT DESKTOP-E5T4RUN 10.0 build 19045 (Windows 10) AMD64
User : SERVERWEB ( 0)
PHP Version : 8.1.10
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : OFF |  Perl : OFF |  Python : OFF |  Sudo : OFF |  Pkexec : OFF
Directory :  C:/cygwin64/lib/python3.9/site-packages/pyparsing/diagram/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : C:/cygwin64/lib/python3.9/site-packages/pyparsing/diagram/__pycache__/__init__.cpython-39.pyc
a

�l�axV�@s�ddlZddlZddlmZddlmZmZmZmZm	Z	m
Z
mZmZm
Z
ddlmZddlmZddlZeeed�dd��Zee���ZWd�n1s�0Yed	d
efdeejfdefg�Ze	d
�ZGdd�dej�ZGdd�dej�ZGdd�dee�Z eeed�dd�Z!ded�dd�Z"d2ej#ee$ee%eed�dd�Z&ee
ej#e%d �d!d"�Z'Gd#d$�d$�Z(Gd%d&�d&�Z)ej#e%d'�d(d)�Z*d*d+�Z+e
ej#d,�d-d.�Z,e+d3ej#ee e)eeee%ee d/�d0d1��Z-dS)4�N)�resource_filename)	�List�Optional�
NamedTuple�Generic�TypeVar�Dict�Callable�Set�Iterable)�Template)�StringIOztemplate.jinja2zutf-8)�encoding�NamedDiagram�name�diagram�index�Tcs$eZdZdZdZ�fdd�Z�ZS)�EachItemz�
    Custom railroad item to compose a:
    - Group containing a
      - OneOrMore containing a
        - Choice of the elements in the Each
    with the group label indicating that all must be matched
    z[ALL]cs<tjt|�dg|�R�}tj|d�}t�j||jd�dS)N���item��label)�railroad�Choice�len�	OneOrMore�super�__init__�	all_label)�self�itemsZchoice_itemZone_or_more_item��	__class__��>/usr/lib/python3.9/site-packages/pyparsing/diagram/__init__.pyr-szEachItem.__init__)�__name__�
__module__�__qualname__�__doc__r r�
__classcell__r%r%r#r&r"srcs&eZdZdZed��fdd�Z�ZS)�
AnnotatedItemzC
    Simple subclass of Group that creates an annotation label
    rcst�j|d�|�d�dS)Nz[{}]�rr)rr�format)r!rrr#r%r&r8szAnnotatedItem.__init__)r'r(r)r*�strrr+r%r%r#r&r,3sr,c@s`eZdZdZedefeed�dd�Ze	edefdd�dd	��Z
ed
d��Zed�d
d�Z
dS)�EditablePartialz�
    Acts like a functools.partial, but can be edited. In other words, it represents a type that hasn't yet been
    constructed.
    .��func�args�kwargscCs||_||_||_dS�Nr1)r!r2r3r4r%r%r&rEszEditablePartial.__init__�EditablePartial[T])r2�returncOst|t|�|d�S)z�
        If you call this function in the same way that you would call the constructor, it will store the arguments
        as you expect. For example EditablePartial.from_call(Fraction, 1, 3)() == Fraction(1, 3)
        r1)r0�list)�clsr2r3r4r%r%r&�	from_callJszEditablePartial.from_callcCs
|jdS)Nr)r4�r!r%r%r&rRszEditablePartial.name�r7cCsL|j��}|j��}t�|j�}|j|jvr<||�|j�7}|j|i|��S)z<
        Evaluate the partial and return the result
        )r3�copyr4�inspectZgetfullargspecr2Zvarargs�pop)r!r3r4Zarg_specr%r%r&�__call__Vs

zEditablePartial.__call__N)r'r(r)r*r	rr8�dictr�classmethodr:�propertyrr@r%r%r%r&r0<s
r0)�diagramsr7cKsdg}|D]F}t�}|j�|j�|j}|jdkr8|d7}|�|d|��d��qtj	fd|i|��S)z�
    Given a list of NamedDiagram, produce a single HTML string that visualises those diagrams
    :params kwargs: kwargs to be passed in to the template
    rz (root)�)�title�textZsvgrD)
r
rZwriteSvg�writerr�append�getvalue�templateZrender)rDr4�datar�iorFr%r%r&�railroad_to_htmlfs
rNr6)�partialr7cCsdt|t�r(t|j�|_t|j�|_|�St|t�r@dd�|D�St|t�r\dd�|��D�S|SdS)zS
    Recursively resolves a collection of Partials into whatever type they are
    cSsg|]}t|��qSr%��resolve_partial)�.0�xr%r%r&�
<listcomp>��z#resolve_partial.<locals>.<listcomp>cSsi|]\}}|t|��qSr%rP)rR�keyrSr%r%r&�
<dictcomp>�rUz#resolve_partial.<locals>.<dictcomp>N)�
isinstancer0rQr3r4r8rAr")rOr%r%r&rQws


rQ�F)�element�diagram_kwargs�vertical�show_results_namesr7cCs�t|pid�}t||d||d�t|�}||vrT|js@d||_||j||dd�t|j���}t	|�dkr�t
�}g}|D]:}	|	jdkr�q||	jdur||	j|vr||�|	j�|�|	�q|d	d
�|D�}
ndd
�|D�}
t
|
dd
�d�S)aO
    Convert a pyparsing element tree into a list of diagrams. This is the recommended entrypoint to diagram
    creation if you want to access the Railroad tree before it is converted to HTML
    :param element: base element of the parser being diagrammed
    :param diagram_kwargs: kwargs to pass to the Diagram() constructor
    :param vertical: (optional) - int - limit at which number of alternatives should be
       shown vertically instead of horizontally
    :param show_results_names - bool to indicate whether results name annotations should be
       included in the diagram
    �r[N)�lookup�parentr\r]rET)�forcerz...cSsg|]}t|��qSr%rP�rRrOr%r%r&rT�rUzto_railroad.<locals>.<listcomp>cSsg|]}t|��qSr%rPrbr%r%r&rT�rUcSs|jSr5�r)Zdiagr%r%r&�<lambda>�rUzto_railroad.<locals>.<lambda>�rV)�ConverterState�_to_diagram_element�id�
customNamer�mark_for_extractionr8rD�valuesr�set�addrI�sorted)rZr[r\r]r_Zroot_idZdiags�seenZ
deduped_diags�dZresolvedr%r%r&�to_railroad�s4�

rq)�
specification�exprsr7cCs |durdStt|��|kSdS)zF
    Returns true if we should return a vertical list of elements
    NF)r�_visible_exprs)rrrsr%r%r&�_should_vertical�sruc@sFeZdZdZdejeeeee	ed�dd�Z
dedeed�d	d
�ZdS)
�ElementStatez<
    State recorded for an individual pyparsing Element
    N)rZ�	convertedr`�numberr�parent_indexcCs4||_||_||_||_||_||_d|_d|_dS)NF)rZrrwr`rxry�extract�complete)r!rZrwr`rxrryr%r%r&r�s
zElementState.__init__Frf)�el_id�staterracCsTd|_|js2|r||_n|jjr,|jj|_nd|_|sF|jrPt|j�rP|�|�dS)a�
        Called when this instance has been seen twice, and thus should eventually be extracted into a sub-diagram
        :param el_id: id of the element
        :param state: element/diagram state tracker
        :param name: name to use for this element's text
        :param force: If true, force extraction now, regardless of the state of this. Only useful for extracting the
        root element when we know we're finished
        TrEN)rzrrZrir{�_worth_extracting�extract_into_diagram)r!r|r}rrar%r%r&rj�sz ElementState.mark_for_extraction)NN)NF)
r'r(r)r*�	pyparsing�
ParserElementr0�intr/rr�boolrjr%r%r%r&rv�s����rvc@s�eZdZdZdeed�dd�Zeed�dd�Z	eed	�d
d�Z
ed�d
d�Zed�dd�Zed�dd�Z
ed�dd�Zed�dd�ZdS)rfzR
    Stores some state that persists between recursions into the element tree
    Nr^cCs.i|_i|_d|_d|_|pi|_t�|_dS)Nrr)�_element_diagram_statesrD�
unnamed_indexrr[rlZextracted_diagram_names)r!r[r%r%r&rs
zConverterState.__init__)rV�valuecCs||j|<dSr5�r�)r!rVr�r%r%r&�__setitem__szConverterState.__setitem__)rVr7cCs
|j|Sr5r��r!rVr%r%r&�__getitem__szConverterState.__getitem__recCs|j|=dSr5r�r�r%r%r&�__delitem__szConverterState.__delitem__cCs
||jvSr5r�r�r%r%r&�__contains__"szConverterState.__contains__r<cCs|jd7_|jS)zT
        Generate a number used in the name of an otherwise unnamed diagram
        r)r�r;r%r%r&�generate_unnamed%szConverterState.generate_unnamedcCs|jd7_|jS)z;
        Generate a number used to index a diagram
        rrcr;r%r%r&�generate_index,szConverterState.generate_index)r|cCs�||}|jrXtjtj|jd�}d|jjvr:||jjd<nd|jjvrX||jjd|j<|jj	tj
krt|jjd}n|j}tjt|jtjtj|fi|j
��|jd�|j|<||=dS)z�
        Used when we encounter the same token twice in the same tree. When this
        happens, we replace all instances of that token with a terminal, and
        create a new subdiagram for the token
        �rGrr")rrrN)r`r0r:r�NonTerminalrr4ryrwr2�GrouprZDiagramr[rxrD)r!r|Zposition�retZcontentr%r%r&r3s*���	z#ConverterState.extract_into_diagram)N)r'r(r)r*rrArr�rvr�r�r�r�r�r�rr%r%r%r&rfs
rf)rZr7cCs|��}tdd�|D��S)z�
    Returns true if this element is worth having its own sub-diagram. Simply, if any of its children
    themselves have children, then its complex enough to extract
    css|]}|��VqdSr5)�recurse)rR�childr%r%r&�	<genexpr>[rUz$_worth_extracting.<locals>.<genexpr>)r��any)rZZchildrenr%r%r&r~Usr~c
s0dtjtttttttttd��fdd�
}|S)z�
    decorator to ensure enhancements to a diagram item (such as results name annotations)
    get applied on return from _to_diagram_element (we do this since there are several
    returns in _to_diagram_element)
    NrF�rZr`r_r\r�	name_hintr]r7c	sR�|||||||�}|rN|durN|j}|rN||jr6dnd7}tjtj||d�}|S)NrE�*r-)�resultsNameZmodalResultsr0r:rr�)	rZr`r_r\rr�r]r��element_results_name��fnr%r&�_inneres"
��z0_apply_diagram_item_enhancements.<locals>._inner)NNrNF)r�r�rr0rfr�r/r�)r�r�r%r�r&� _apply_diagram_item_enhancements^s 
�� r��rscs$tjtjtjjf��fdd�|D�S)Ncs&g|]}|js|jst|��s|�qSr%)rir�rX�rR�e�Znon_diagramming_exprsr%r&rT�s�z"_visible_exprs.<locals>.<listcomp>)r�ZParseElementEnhanceZ
PositionToken�AndZ
_ErrorStopr�r%r�r&rt�s�
�rtr�c	Cs�|��}|p|jp|jj}t|�}	|j}
|jspt|tjtj	f�rp|rp|djsT|}nd}t
|j||||||d�St|�r�|	|vr�||	}|j
|	||d�tjtj|jd�}
|
S|	|jvr�tjtj|j|	jdd�}
|
St|tj��rX|s�dSttdd�|D���d	k�r&tjtjd
tt|��d�}
n.t||��rDtjtjgd�}
ntjtjgd�}
�n�t|tjtjf��r�|�svdSt||��r�tjtjdgd�}
ntjtj gd�}
�n�t|tj!��r�|�s�dStjt"gd�}
�n^t|tj#��r�tjt$d
d
d�}
�n<t|tj%��rtjt$dd
d�}
�nt|tj&��r8tjt$dd
d�}
n�t|tj'��rXtjtj(d
d�}
n�t|tj��rxtjtjd
d�}
n�t|tj)��r�tjtj)d
d�}
n�t|tj*��r�tjtj*d|
d�}
nxt|tj+��r�|j�s�d}
n\t|�d	k�r�tjtjgd�}
n<t|�dk�r|
�stjtj*d
|d�}
nt�tj,|j-�}|}
|
du�r@dSt.||
|||�/�d�||	<|j�rv||	�
|	||j�d}|D]�}d|
jv�r�|
jd�0|d�t
||
||||d�}|du�r�d|
jv�r�||
jd<n"d|
jv�r||
jd|<|d	7}nd|
jv�r~|
jd|=�q~|
�rfd|
jv�r<t|
jd�dk�sXd|
jv�rf|
jddu�rft�tj,|�}
|	|v�rzd||	_1|	|v�r�||	j2�r�||	j1�r�|�3|	�|
du�r�tjtj|j|	jdd�}
|
S)a"
    Recursively converts a PyParsing Element to a railroad Element
    :param lookup: The shared converter state that keeps track of useful things
    :param index: The index of this element within the parent
    :param parent: The parent of this element in the output tree
    :param vertical: Controls at what point we make a list of elements vertical. If this is an integer (the default),
    it sets the threshold of the number of items before we go vertical. If True, always go vertical, if False, never
    do so
    :param name_hint: If provided, this will override the generated name
    :param show_results_names: bool flag indicating whether to add annotations for results names
    :returns: The converted version of the input element, but as a Partial that hasn't yet been constructed
    rN)r`r_r\rr�r])rr�rcss|]}|j|jfVqdSr5)rr�r�r%r%r&r��rUz&_to_diagram_element.<locals>.<genexpr>rrE)r�repeat)r"ZNOT)rrZ	LOOKAHEADZ
LOOKBEHINDrr-)rZrwr`ryrxr")r`r_r\rr]rT)4r�rir$r'rhr�rXr�ZTokenConverterZLocatedrg�exprr~rjr0r:rr�rrDr4r�rrlrr/ruZStack�SequenceZOrZ
MatchFirstrZHorizontalChoiceZEachrZNotAnyr,Z
FollowedByZ
PrecededByZOptrZ
ZeroOrMorer�ZEmptyZTerminalZdefaultNamervr��insertr{rzr)rZr`r_r\rr�r]rsrr|r�Zpropagated_nameZ	looked_upr�Zterminal�ir�rr%r%r&rg�s��	
�
���
�
�


����

"

�rg)NrYF)NNrNF).rr�Z
pkg_resourcesr�typingrrrrrrr	r
rZjinja2rrMr
r>�openr'�fp�readrKr/ZDiagramItemr�rrr�rr,r0rNrQr�rAr�rqrurvrfr~r�rtrgr%r%r%r&�<module>sh,*�	*��7
�>N	*
��

Youez - 2016 - github.com/yon3zu
LinuXploit