%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/pyparsing/diagram/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/pyparsing/diagram/__pycache__/__init__.cpython-312.pyc

�

&
�d�^���ddlZddlZddlZddlmZmZmZmZmZmZm	Z	m
Z
ddlmZddl
mZddlZdZee�Zeddefdej&ej(fd	efg�Z	ed
�ZGd�dej0�ZGd
�dej0�ZGd�dee�Zd+deedefd�Zdddefd�Z				d,dej<dej&edede de deefd�Z!dede
ej<de fd�Z"Gd �d!�Z#Gd"�d#�Z$dej<de fd$�Z%d%�Z&de
ej<fd&�Z'e&						d-dej<d'ej&ed(e$ded	ed)ede de dej&efd*��Z(y).�N)�List�
NamedTuple�Generic�TypeVar�Dict�Callable�Set�Iterable)�Template)�StringIOa�{% if not embed %}
<!DOCTYPE html>
<html>
<head>
{% endif %}
    {% if not head %}
        <style>
            .railroad-heading {
                font-family: monospace;
            }
        </style>
    {% else %}
        {{ head | safe }}
    {% endif %}
{% if not embed %}
</head>
<body>
{% endif %}
{{ body | safe }}
{% for diagram in diagrams %}
    <div class="railroad-group">
        <h1 class="railroad-heading">{{ diagram.title }}</h1>
        <div class="railroad-description">{{ diagram.text }}</div>
        <div class="railroad-svg">
            {{ diagram.svg }}
        </div>
    </div>
{% endfor %}
{% if not embed %}
</body>
</html>
{% endif %}
�NamedDiagram�name�diagram�index�Tc�&��eZdZdZdZ�fd�Z�xZS)�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]c���tjt|�dz
g|���}tj|��}t�|�||j��y)N���item)�label)�railroad�Choice�len�	OneOrMore�super�__init__�	all_label)�self�items�choice_item�one_or_more_item�	__class__s    ��</usr/lib/python3/dist-packages/pyparsing/diagram/__init__.pyrzEachItem.__init__PsF����o�o�c�%�j�1�n�=�u�=��#�-�-�;�?��
���)�����@�)�__name__�
__module__�__qualname__�__doc__rr�
__classcell__�r$s@r%rrEs�����I�A�Ar&rc�(��eZdZdZdef�fd�Z�xZS)�
AnnotatedItemzC
    Simple subclass of Group that creates an annotation label
    rc�Z��t�|�||rdj|���y|��y)Nz[{}]�rr)rr�format)r rrr$s   �r%rzAnnotatedItem.__init__[s(���
���d�%�&�-�-��*>��S�U��Sr&)r'r(r)r*�strrr+r,s@r%r.r.Vs����T�c�T�Tr&r.c�n�eZdZdZdedefdedefd�Ze	dedefddfd	��Z
ed
��Zdefd�Z
y)
�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�kwargsc�.�||_||_||_y�N�r5r6r7)r r5r6r7s    r%rzEditablePartial.__init__hs����	���	���r&�return�EditablePartial[T]c�0�t|t|�|��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)
        r:)r4�list)�clsr5r6r7s    r%�	from_callzEditablePartial.from_callms���D�t�D�z�&�I�Ir&c� �|jdS)Nr)r7�r s r%rzEditablePartial.nameus���{�{�6�"�"r&c�8�|jj�}|jj�}tj|j
�}|j|jvr||j|j�z
}|j
|i|��S)z<
        Evaluate the partial and return the result
        )r6�copyr7�inspect�getfullargspecr5�varargs�pop)r r6r7�arg_specs    r%�__call__zEditablePartial.__call__ys}���y�y�~�~������!�!�#���)�)�$�)�)�4�����t�{�{�*��F�J�J�x�/�/�0�0�D��t�y�y�$�)�&�)�)r&N)r'r(r)r*rrr>�dictr�classmethodr@�propertyrrJ�r&r%r4r4_sz����X�c�1�f�-��T��4��
�J�X�c�1�f�-�J�CW�J��J��#��#�
*�!�
*r&r4�diagramsr;c���g}|D]�}|j��t�}	|jd�}|jj|j|��|j}|jdk(r|dz
}|j|d|j�d����tjd||d�|��S#t
$r(|jj
|j�Y��wxYw)	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
    �css)rQrz (root)�)�title�text�svg)rO�embedrN)
rr�get�writeStandalone�write�AttributeError�writeSvgrr�append�getvalue�template�render)rOrVr7�datar�iorQrSs        r%�railroad_to_htmlrb�s���
�D��H���?�?�"��
�Z��	/��*�*�U�#�C��O�O�+�+�B�H�H�#�+�>������=�=�A���Y��E����e�R����
�F�G�H��?�?�@�D��@��@�@���	/��O�O�$�$�R�X�X�.�	/�s�8B5�5.C&�%C&�partialr<c�~�t|t�r;t|j�|_t|j�|_|�St|t
�r|D�cgc]
}t|���c}St|t�r-|j�D��cic]\}}|t|���c}}S|Scc}wcc}}w)zS
    Recursively resolves a collection of Partials into whatever type they are
    )�
isinstancer4�resolve_partialr6r7r>rKr!)rc�x�keys   r%rfrf�s����'�?�+�&�w�|�|�4���(����8����y��	�G�T�	"�,3�4�q���"�4�4�	�G�T�	"�6=�m�m�o�F�F�C���_�Q�'�'�F�F����	5��Fs� B4�B9�element�diagram_kwargs�vertical�show_results_names�show_groupsc��t|xsi��}t||d|||��t|�}||vr-|js
d||_||j||d��t
|jj��}t|�dkDr�t�}g}	|D]Z}
|
jdk(r�|
j�� |
j|vs�/|j|
j�|	j|
��\|	D�cgc]
}t|���}}n|D�cgc]
}t|���}}t|d	��
�Scc}wcc}w)a�
    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
    :param show_groups - bool to indicate whether groups should be highlighted with an unlabeled
       surrounding box
    )rjN)�lookup�parentrkrlrmrRT)�forcerz...c��|jSr9�r)�diags r%�<lambda>zto_railroad.<locals>.<lambda>�s
��T�Z�Z�r&)rh)�ConverterState�_to_diagram_element�id�
customNamer�mark_for_extractionr>rO�valuesr�set�addr\rf�sorted)
rirjrkrlrmro�root_id�diags�seen�
deduped_diags�drc�resolveds
             r%�to_railroadr��s>��(�>�+?�R�
@�F������-��
���k�G��&���!�!�#%�F�7�O� ��w��+�+�G�V�4�+�H�
����'�'�)�*�E�
�5�z�A�~��u���
��	(�A��v�v�����v�v�!�a�f�f�D�&8������� ��$�$�Q�'�
	(�=J�J��O�G�,�J��J�=B�B��O�G�,�B��B��(� 7�8�8��K��Cs�>D9�D>�
specification�exprsc�6�|�ytt|��|k\S)zF
    Returns true if we should return a vertical list of elements
    F)r�_visible_exprs)r�r�s  r%�_should_verticalr��s"������>�%�(�)�]�:�:r&c��eZdZdZ		ddej
dedededede	jefd	�Z	dd
eddded
efd�Z
y)�ElementStatez<
    State recorded for an individual pyparsing Element
    Nri�	convertedrp�numberr�parent_indexc�t�||_||_||_||_||_||_d|_d|_y�NF)rirr�rpr�r��extract�complete)r rir�rpr�rr�s       r%rzElementState.__init__�s=��18���*.��	�*3���'-���!���2>���"���#��
r&�el_id�statervrqc��d|_|jsC|r||_n9|jjr|jj|_nd|_|s!|jr(t|j�r|j
|�yyy)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
        TrRN)r�rriryr��_worth_extracting�extract_into_diagram)r r�r�rrqs     r%rzz ElementState.mark_for_extractionsp������y�y�� ��	����(�(� �L�L�3�3��	���	�
�T�]�]�'8����'F��&�&�u�-�(G�]r&)NNr�)r'r(r)r*�	pyparsing�
ParserElementr4�intr2�typing�Optionalr�boolrzrNr&r%r�r��s�����-1�$��(�(�$�#�$� �	$�
�$��
$��o�o�c�*�$�6TY�.��.�!1�.�9<�.�LP�.r&r�c��eZdZdZddej
efd�Zdede	fd�Z
dede	fd	�Zdefd
�Zdefd�Z
defd�Zdefd
�Zdefd�Zy)rvzR
    Stores some state that persists between recursions into the element tree
    Nrjc�p�i|_i|_d|_d|_|xsi|_t�|_y)Nrr)�_element_diagram_statesrO�
unnamed_indexrrjr|�extracted_diagram_names)r rjs  r%rzConverterState.__init__9s7��@B��$�BD��
�"#�����
�$2�$8�b���14���$r&rh�valuec�"�||j|<yr9�r�)r rhr�s   r%�__setitem__zConverterState.__setitem__Fs��,1��$�$�S�)r&r;c� �|j|Sr9r��r rhs  r%�__getitem__zConverterState.__getitem__Is���+�+�C�0�0r&c��|j|=yr9r�r�s  r%�__delitem__zConverterState.__delitem__Ls���(�(��-r&c��||jvSr9r�r�s  r%�__contains__zConverterState.__contains__Os���d�2�2�2�2r&c�D�|xjdz
c_|jS)zT
        Generate a number used in the name of an otherwise unnamed diagram
        r)r�rBs r%�generate_unnamedzConverterState.generate_unnamedRs!��	
���a����!�!�!r&c�D�|xjdz
c_|jS)z;
        Generate a number used to index a diagram
        rrsrBs r%�generate_indexzConverterState.generate_indexYs��	
�
�
�a��
��z�z�r&r�c	���||}|jr�tjtj|j
��}d|jjvr||jjd<n>d|jjvr&||jjd|j<|jjtjk(r|jjd}n|j}tjt|j
tjtj|fi|j��|j��|j|<||=y)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
        �rTrr!)rrrN)rpr4r@r�NonTerminalrr7r�r�r5�Groupr
�Diagramrjr�rO)r r��position�ret�contents     r%r�z#ConverterState.extract_into_diagram`s(����;���?�?�!�+�+�H�,@�,@�x�}�}�+�U�C�����/�/�/�14����&�&�v�.��H�O�O�2�2�2�IL����&�&�w�/��0E�0E�F����"�"�h�n�n�4��(�(�/�/��7�G��(�(�G�.�8�8�����#�-�-�� � �'��-1�-@�-@���/�/�
 9� 
��
�
�e��
��Kr&r9)r'r(r)r*r�r�rKrr�r�r�r�r�r�r�r�r�rNr&r%rvrv4s~���7�v���t�'<�7�2�s�2�<�2�1�s�1�|�1�.�s�.�3��3�"�#�"�����#�r&rvc�F�|j�}td�|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
    c3�<K�|]}|j����y�wr9)�recurse)�.0�childs  r%�	<genexpr>z$_worth_extracting.<locals>.<genexpr>�s����5�5�u�}�}��5�s�)r��any)ri�childrens  r%r�r��s!��
��� �H��5�H�5�5�5r&c����						ddtjdtjtdt
dtdtdtdtdtd	tjtf�fd
�
}|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)
    rirprorkr�	name_hintrlrmr;c
����
||||||||�}|rI|�G|j}	|	r9|	|jrdndz
}	tjtj
||	��}|S)NrR�*r0)�resultsName�modalResultsr4r@rr�)rirprorkrr�rlrmr��element_results_name�fns          �r%�_innerz0_apply_diagram_item_enhancements.<locals>._inner�s|������������	
���#�/�#*�#6�#6� �#�$�g�.B�.B���K�$�%�/�/��N�N��4H�0����
r&�NNrNFF)	r�r�r�r�r4rvr�r2r�)r�r�s` r%� _apply_diagram_item_enhancementsr��s����"&����#(�!���(�(������0�����	�
���
�!����
����	)��B�Mr&c���tjtjtjjf}|D�cgc](}|j
s|jst||�s|��*c}Scc}wr9)r��ParseElementEnhance�
PositionToken�And�
_ErrorStopryr�re)r��non_diagramming_exprs�es   r%r�r��sb���%�%�����
�
� � �����
�����
�
��A�?T�1U�	
����s�-A.rpror�c
���|j�}|xs$|jxs|jj}	t	|�}
|j
}|jsNt
|tjf�r3|r1|djs|	}nd}t|j|||||||��St|�r�|
|vrJ||
}
|
j|
||��tjtj |
j"��}|S|
|j$vrAtjtj |j$|
j&d��}|St
|tj(�r�|syt+t-d�|D���dk(r:tjtj.d	t1t+|���
�}�n�t3||�r'tjtj4g��}�n�tjtj6g��}�n\t
|tj8tj:f�r^|syt3||�r(tjtj<dg��}�n�tjtj>g��}�n�t
|tj@�r |sytjtBg��}�n�t
|tjD�rtjtFdd	�
�}�nbt
|tjH�rtjtFdd	�
�}�n*t
|tjJ�rtjtFdd	�
�}�n�t
|tjL�rH|rtjtFd	d	�
�}�n�tjtjLd	d	�
�}�n�t
|tjN�rmtQ|�jjS�}|dk(r'tjtj6g��}�n'tjtF|d	�
�}�n	t
|tjT�r'tjtjVd	��}�n�t
|tj.�r'tjtj.d	��}�n�t
|tjX�r'tjtjXd	��}�nFt
|tjL�r(tjtjLd|��}�nt
|tjZ�r|jsd}n�t
|tj\�r&tjtj6g��}n�t+|�dkDr)|s'tjtjLd	|	��}ndt+|�dkDr&tjtj6g��}n0tjtj^|j`�}|}|�ytc|||||je���||
<|jr ||
j|
||j�d}|D]�}d|j&vr|j&djg|d�t|||||||��}|�Ed|j&vr||j&d<�bd|j&vs�q||j&d|<|dz
}��d|j&vs��|j&d|=��|rjd|j&vrt+|j&d�dk(sd|j&vr3|j&d�$tjtj^|	�}|
|vr
d||
_4|
|vrp||
jjra||
jhrR|jm|
�|�?tjtj |j$|
j&d��}|S)ay
    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
    :param show_groups: bool flag indicating whether to show groups using bounding box
    rN)rprorkrr�rlrm)rr�rc3�LK�|]}|j|jf���y�wr9)rr�)r�r�s  r%r�z&_to_diagram_element.<locals>.<genexpr>s����:�q�A�F�F�A�M�M�*�:�s�"$rrR)r�repeat)r!�NOT)rr�	LOOKAHEAD�
LOOKBEHIND�tokenconverterrr0)rir�rpr�r�r!)rprorkrrlrmrT)7r�ryr$r'rxr�rer��Locatedrw�exprr�rzr4r@rr�rrOr7r�rr|rr2r��Stack�Sequence�Or�
MatchFirstr�HorizontalChoice�Eachr�NotAnyr.�
FollowedBy�
PrecededByr��TokenConverter�type�lower�Optr��
ZeroOrMore�Emptyr��Terminal�defaultNamer�r��insertr�r�r�)rirprorkrr�rlrmr�rr�r��propagated_name�	looked_upr�r�terminal�ir�rs                    r%rwrw�s���0
�O�O��E��H��*�*�H�g�.?�.?�.H�.H�D�
�w�K�E�"�.�.��������!�!�
�
���Q�x�*�*�&*�O�&*�O�*��L�L�!�!�%��-�'9� +�	�	���!��F�?��u�
�I��)�)�%��i�)�H�!�+�+�H�,@�,@�y�~�~�+�V�C��J�
�f�o�o�
%�"�+�+��$�$�6�?�?�5�+A�+H�+H��+P�,��C��J�
�'�9�=�=�)����s�:�E�:�:�;�q�@�!�+�+��"�"��C��E�
�O�,��C��h��
.�!�+�+�H�N�N�"�+�E�C�!�+�+�H�,=�,=�R�+�H�C�	�G�i�l�l�I�,@�,@�A�	B����H�e�,�!�+�+�H�O�O�Q�b�+�I�C�!�+�+�H�,E�,E�R�+�P�C�	�G�Y�^�^�	,����'�'���'�;��	�G�Y�-�-�	.��'�'�
�U��'�L��	�G�Y�1�1�	2��'�'�
�[�r�'�R��	�G�Y�1�1�	2��'�'�
�\�PR�'�S��	�G�Y�_�_�	-��!�+�+�M��"�+�M�C�!�+�+�H�N�N�"�2�+�N�C�	�G�Y�5�5�	6��W�
�&�&�,�,�.���$�$�!�+�+�H�,=�,=�R�+�H�C�!�+�+�M��R�+�P�C�	�G�Y�]�]�	+��'�'��(9�(9��'�C��	�G�Y�0�0�	1��'�'��(:�(:��'�D��	�G�Y�1�1�	2��'�'��(;�(;�"�'�E��	�G�Y�_�_�	-��'�'��N�N��-A�(�
��
�G�Y�_�_�	-�g�6H�6H���	�G�Y�:�:�	;��'�'��(9�(9��'�D��	�U��a�� 4��'�'����R�t�'�L��	�U��a���'�'��(9�(9��'�D��"�,�,�X�->�->��@S�@S�T����
�{��!������$�$�&��F�5�M�����u�
�)�)�%���9K�9K�L�	�A��'���c�j�j� ��J�J�w��&�&�q�$�/�"������1�#�
��������#�%)��
�
�6�"��C�J�J�&�)-��
�
�7�#�A�&��Q���
��
�
�
"��
�
�7�#�A�&�3'�8�	�C�J�J�	�3�s�z�z�'�':�#;�q�#@��c�j�j� �S�Z�Z��%7�%?��'�'��(9�(9�4�@��
���!%��u�
�����6�%�=�0�0�V�E�]�5K�5K��#�#�E�*��?�!�+�+��$�$�6�?�?�5�+A�+H�+H��+P�,��C��Jr&)F)N�FFr�))rr�r�rrrrrrr	r
�jinja2rrarrE�jinja2_template_sourcer^r2r��DiagramItemr�r
rr�rr.r4rbrfr�rKr�r�r�r�rvr�r�r�rwrNr&r%�<module>r�s_����
�	�	�	����!��F�*�+�����c�]�Y�����0D�0D� E�F��RU��W�����C�L��A�x�~�~�A�"T�H�N�N�T�'*�g�a�j�'*�TA�t�L�1�A�S�A�.
�1�
�a�
�$-1��$��79�
�
$�
$�79��O�O�D�)�79��79��	79�
�79�
�,��
79�t	;��	;�'�	�(?�(?�@�	;�	�	;�;.�;.�|K�K�\6�y�6�6�6�4�6�(�V
�(�9�#:�#:�;�
�"�"����$��L�
�
$�
$�L��O�O�O�,�L�
�L��	L�
�L��
L��L��L��_�_�_�%�L�"�Lr&

Zerion Mini Shell 1.0