%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/automat/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/automat/__pycache__/_methodical.cpython-312.pyc

�

�~�b�=����ddlZddlmZddlmZddlmZddlZddl	m
Z
mZddlm
Z
ejdgd	��Zd
�Zd�Zd�Zej&d
��Gd�de��Zd�Zd�Zd�Zd�Zd�Zej&dd��Gd�de��Zej&d
��Gd�de��Zej&dd��Gd�de��Ze�Zd�ZGd�d e�Z y)!�N��wraps)�count)�getfullargspec�)�Transitioner�	Automaton)�preserveName�ArgSpec��args�varargs�varkw�defaults�
kwonlyargs�kwonlydefaults�annotationsc��t|�}tt|j�|j|j
|jr|jndt|j�|jr#t|jj��ndt|jj����S)z�
    Normalize inspect.ArgSpec across python versions
    and convert mutable attributes to immutable types.

    :param Callable func: A function.
    :return: The function's ArgSpec.
    :rtype: ArgSpec
    �r)�getArgsSpecr�tupler
rrrrr�itemsr)�func�specs  �5/usr/lib/python3/dist-packages/automat/_methodical.py�_getArgSpecrs����t��D��
�4�9�9�
�����j�j�"&�-�-����R�����)��"�"�
�$�%�%�+�+�-�.�(*��$�*�*�0�0�2�3���c��t|j|jz|jrdndz|jrdndz|j
z�S)a0
    Get the name of all arguments defined in a function signature.

    The name of * and ** arguments is normalized to "*args" and "**kwargs".

    :param ArgSpec spec: A function to interrogate for a signature.
    :return: The set of all argument names in `func`s signature.
    :rtype: Set[str]
    )z*argsr)z**kwargs)�setr
rrrr)rs r�_getArgNamesr ,sV����	�	�
�/�/�	����:�2�	/�!�J�J�=�B�	0��
�
�		��rc�.��t���fd��}|S)a
    Decorate a function so all its arguments must be passed by keyword.

    A useful utility for decorators that take arguments so that they don't
    accidentally get passed the thing they're decorating as their first
    argument.

    Only works for methods right now.
    c����|fi|��S�Nr)�self�kw�fs  �r�gz_keywords_only.<locals>.gIs�����}��}�rr)r&r's` r�_keywords_onlyr(?s ����1�X�����HrT)�frozenc��eZdZdZej
d��Zej
�Zej
d��Zdde	fd�Z
d�Zy)�MethodicalStatez-
    A state for a L{MethodicalMachine}.
    F��reprNc��|�|}|�g}t|j�}|D]�}t|j�}|j|�r�*tdj	|j
j|j
jt|j
�t|j
�����|jj|||||�y)ac
        Declare a state transition within the :class:`automat.MethodicalMachine`
        associated with this :class:`automat.MethodicalState`:
        upon the receipt of the `input`, enter the `state`,
        emitting each output in `outputs`.

        :param MethodicalInput input: The input triggering a state transition.
        :param MethodicalState enter: The resulting state.
        :param Iterable[MethodicalOutput] outputs: The outputs to be triggered
            as a result of the declared state transition.
        :param Callable collector: The function to be used when collecting
            output return values.

        :raises TypeError: if any of the `outputs` signatures do not match
            the `inputs` signature.
        :raises ValueError: if the state transition from `self` via `input`
            has already been defined.
        Nzdmethod {input} signature {inputSignature} does not match output {output} signature {outputSignature})�input�output�inputSignature�outputSignature)
r �argSpec�issubset�	TypeError�format�method�__name__r�machine�_oneTransition)r$r/�enter�outputs�	collector�	inputArgsr0�
outputArgss        r�uponzMethodicalState.uponXs���&�=��E��?��G� ����/�	��	�F�%�f�n�n�5�J��&�&�y�1��2�28�&�#�l�l�3�3�%�}�}�5�5�'2�5�<�<�'@�(3�F�M�M�(B�	39�3���	�	
���#�#�D�%����Krc�.�|jjSr#�r7r8�r$s r�_namezMethodicalState._name~����{�{�#�#�#r)r8�
__module__�__qualname__�__doc__�attr�ibr9r7�
serialized�listr@rDrrrr+r+OsI����d�g�g�5�!�G�
�T�W�W�Y�F�����e�$�J� $�d�d�$L�L$rr+c�j�t||d�}|�#t||j�}t|||�|S)z
    Get a L{Transitioner}
    N)�getattrr�initialState�setattr)�oself�symbol�	automaton�transitioners    r�_transitionerFromInstancerU�sB���5�&�$�/�L���#���"�"�
��	��v�|�,��rc��yr#rrrr�_emptyrW�s��rc��y)�	docstringNrrrr�
_docstringrZ�s�rc��|jjtjjtjjfvrt	d��y)Nzfunction body must be empty)�__code__�co_coderWrZ�
ValueError)�inst�	attributer&s   r�assertNoCodera�sG��	�z�z���&�/�/�"9�"9�",�"5�"5�"=�"=�"?�?��6�7�7�?rc�f�tt|jdd|��}|jr|}n#|D��cgc]\}}||jvs�|��}}}t|�}|D]\}	}
||	|
fz
}�t|jddd�|jddd��}|D��cic]
\}}||vs�||��}}}|j|�|jr|}
||
fS|jdd|jz}|j�D��cic]\}}||vr||��}
}}||
fScc}}wcc}}wcc}}w)a�
    Filter out arguments that were passed to input that output won't accept.

    :param tuple args: The *args that input received.
    :param dict kwargs: The **kwargs that input received.
    :param ArgSpec inputSpec: The input's arg spec.
    :param ArgSpec outputSpec: The output's arg spec.
    :return: The args and kwargs that output will accept.
    :rtype: Tuple[tuple, dict]
    rN���)	r�zipr
rr�updaterrr)r
�kwargs�	inputSpec�
outputSpec�
named_args�return_args�n�v�passed_arg_names�name�valuer�full_kwargs�
return_kwargs�all_accepted_namess               r�_filterArgsrs�sf���s�9�>�>�!�"�-�t�4�5�J������&0�H�T�Q��1�
���3G�q�H��H��V�}��!�*���e��T�5�M�)��*��9�>�>�$�B�$�'��);�);�D�b�D�)A�B�H�$,�J�D�A�q��9I�0I�1�a�4�J�K�J����v�����#�
��
�%�%�	(�_�_�Q�R�0�:�3H�3H�H��*5�*;�*;�*=�5�$�!�Q��!3�3��A��5�
�5��
�%�%��'I��K��5s�D!�D!�"D'�/D'�	D-F)�eq�hashc�$�eZdZdZej
d��Zej
e��Zej
d��Z	ej
eje�d��Zej
dd��Z
e
jd��Zdd	�Zd
�Zy)�MethodicalInputz.
    An input for a L{MethodicalMachine}.
    Fr,)�	validator)�defaultr-��initr-c�,�t|j�Sr#�rr7rCs r�
_buildArgSpeczMethodicalInput._buildArgSpec�����4�;�;�'�'rNc�����t��j�j��t�j�t�j����fd���}|S)z�
        Return a function that takes no arguments and returns values returned
        by output functions produced by the given L{MethodicalInput} in
        C{oself}'s current state.
        c�d���j�g|��i|���
j}�
j��\}}�j|}g}|D]\}|r||j	��t||�j|j�\}}	|�g|��i|	��}
|j|
��^||�Sr#)r7�_state�
transition�
collectorsrDrsr3�append)r
rf�
previousStater<�	outTracerr=�valuesr0�a�krorQr$rTs           ���r�doInputz(MethodicalInput.__get__.<locals>.doInput�s����
�D�K�K��/��/��/�(�/�/�M�#/�#:�#:�4�#@� �W�i����
�6�I��F�!�
%����f�l�l�n�-�"�4�����v�~�~�N���1��u�.�q�.�A�.���
�
�e�$�
%��V�$�$r)rUrRrSr
r7r)r$rQ�typer�rTs``  @r�__get__zMethodicalInput.__get__�sR���1�����15���A��	�d�k�k�	"�	�t�{�{�	�	%�
�
#�	%��rc�.�|jjSr#rBrCs rrDzMethodicalInput._name�rErr#)r8rFrGrHrIrJrSrar7rR�Factory�dictr�r3ryr~r�rDrrrrwrw�s��������U�#�I�
�T�W�W�|�
,�F�
�T�W�W�%�
 �F���������d�!3�%�@�J��d�g�g�5�u�-�G��_�_�(��(��2$rrwc��eZdZdZej
d��Zej
�Zej
dd��Zejd��Z
d
d�Zd�Zd	�Z
y)�MethodicalOutputz/
    An output for a L{MethodicalMachine}.
    Fr,rzc�,�t|j�Sr#r}rCs rr~zMethodicalOutput._buildArgSpecrrNc�v�tdj|j|jj����)zX
        Outputs are private, so raise an exception when we attempt to get one.
        zf{cls}.{method} is a state-machine output method; to produce this output, call an input method instead.)�clsr7)�AttributeErrorr6r8r7�r$rQr�s   rr�zMethodicalOutput.__get__s=���
D�DJ�F��M�M��{�{�+�+�EK�E�
�	
rc�.�|j|g|��i|��S)z-
        Call the underlying method.
        )r7)r$rQr
rfs    r�__call__zMethodicalOutput.__call__s���t�{�{�5�2�4�2�6�2�2rc�.�|jjSr#rBrCs rrDzMethodicalOutput._namerErr#)r8rFrGrHrIrJr9r7r3ryr~r�r�rDrrrr�r��s]����d�g�g�5�!�G�
�T�W�W�Y�F��d�g�g�5�u�-�G��_�_�(��(�

�3�$rr�c�`�eZdZejd��Zejd��Zdd�Zy)�MethodicalTracerFr,Nc�T��t||j|j���fd�}|S)Nc�(���j|�yr#)�setTrace)�tracerrTs �rr�z*MethodicalTracer.__get__.<locals>.setTrace's����!�!�&�)r)rUrRrS)r$rQr�r�rTs    @rr�zMethodicalTracer.__get__$s'���0�����15���A��	*��rr#)r8rFrGrIrJrSrRr�rrrr�r�s'������U�#�I�
�T�W�W�%�
 �F�rr�c�8�dttt��zS)z,
    Create a unique Python identifier.
    �_symbol_)�str�next�counterrrr�gensymr�.s����D��M�*�*�*rc��eZdZdZd�Zd
d�Ze		dd��Zed��Zed��Z	d�Z
ed	��Zed
��Ze
d��Zd�Zy)�MethodicalMachinezj
    A :class:`MethodicalMachine` is an interface to an `Automaton`
    that uses methods on a class.
    c�N�t�|_i|_t�|_yr#)r	�
_automaton�	_reducersr��_symbolrCs r�__init__zMethodicalMachine.__init__<s��#�+�������x��rNc� �|�td��|S)z�
        L{MethodicalMachine} is an implementation detail for setting up
        class-level state; applications should never need to access it on an
        instance.
        z.MethodicalMachine is an implementation detail.)r�r�s   rr�zMethodicalMachine.__get__Bs!���� �@�B�
B��rc��������fd�}|S)a
        Declare a state, possibly an initial state or a terminal state.

        This is a decorator for methods, but it will modify the method so as
        not to be callable any more.

        :param bool initial: is this state the initial state?
            Only one state on this :class:`automat.MethodicalMachine`
            may be an initial state; more than one is an error.

        :param bool terminal: Is this state a terminal state?
            i.e. a state that the machine can end up in?
            (This is purely informational at this point.)

        :param Hashable serialized: a serializable value
            to be used to represent this state to external systems.
            This value should be hashable;
            :py:func:`unicode` is a good type to use.
        c�J��t�|���}�r|�j_|S)N)r9r7rK)r+r�rO)�stateMethod�state�initialr$rKs  ���r�	decoratorz*MethodicalMachine.state.<locals>.decoratords+���#�D�+6�/9�;�E��/4����,��Lrr)r$r��terminalrKr�s`` ` rr�zMethodicalMachine.stateNs���,	��rc����fd�}|S)zM
        Declare an input.

        This is a decorator for methods.
        c�H��t�j|�j��S)N)rSr7rR)rwr�r�)�inputMethodr$s �rr�z*MethodicalMachine.input.<locals>.decoratorus ���"�T�_�_�*5�*.�,�,�8�
8rr�r$r�s` rr/zMethodicalMachine.inputns���	8��rc����fd�}|S)z�
        Declare an output.

        This is a decorator for methods.

        This method will be called when the state machine transitions to this
        state as specified in the decorated `output` method.
        c���t�|��S)N)r9r7)r�)�outputMethodr$s �rr�z+MethodicalMachine.output.<locals>.decorator�s���#�D��F�Frrr�s` rr0zMethodicalMachine.output|s���	G��rc�p�|jj|||t|��||j|<y)z.
        See L{MethodicalState.upon}.
        N)r��
addTransitionrr�)r$�
startState�
inputToken�endState�outputTokensr=s      rr:z MethodicalMachine._oneTransition�s4��&	
���%�%�j�*�h�&+�L�&9�	;�,5�
���j�)rc����fd�}|S)�


        c�2���t����fd��}|S)Nc���t|�j�j�}�||jj�Sr#)rUr�r�r�rK)rQrT�	decorateer$s  ��r�	serializezBMethodicalMachine.serializer.<locals>.decorator.<locals>.serialize�s6���8�����9=��� J�� ���(;�(;�(F�(F�G�Grr)r�r�r$s` �rr�z/MethodicalMachine.serializer.<locals>.decorator�s$���
�9�
�
H��
H��rrr�s` r�
serializerzMethodicalMachine.serializer�s���
	��rc����fd�}|S)r�c�2���t����fd��}|S)Nc�����|g|��i|��}i}�jj�D]}|||j<�t|�j�j�}|||_yr#)r��statesrKrUr�r�)	rQr
rfr��mapping�	eachStaterTr�r$s	       ��r�unserializezFMethodicalMachine.unserializer.<locals>.decorator.<locals>.unserialize�sp���!�%�9�$�9�&�9����!%���!7�!7�!9�>�I�4=�G�I�0�0�1�>�8��4�<�<���� :��&-�e�n��#�rr)r�r�r$s` �rr�z1MethodicalMachine.unserializer.<locals>.decorator�s"���
�9�
�
��
��rrr�s` r�unserializerzMethodicalMachine.unserializer�s���
	��rc�B�t|j|j�Sr#)r�r�r�rCs r�	_setTracezMethodicalMachine._setTrace�s���������>�>rc�@�ddlm}||jd�d�d���S)a
        Generate a L{graphviz.Digraph} that represents this machine's
        states and transitions.

        @return: L{graphviz.Digraph} object; for more information, please
            see the documentation for
            U{graphviz<https://graphviz.readthedocs.io/>}

        r)�makeDigraphc�.�|jjSr#rB)r�s r�<lambda>z-MethodicalMachine.asDigraph.<locals>.<lambda>�������(=�(=�rc�.�|jjSr#rB)r/s rr�z-MethodicalMachine.asDigraph.<locals>.<lambda>�r�rc�.�|jjSr#rB)r0s rr�z-MethodicalMachine.asDigraph.<locals>.<lambda>�s��&�-�-�*@�*@�r)�
stateAsString�
inputAsString�outputAsString)�
_visualizer�r�)r$r�s  r�	asDigraphzMethodicalMachine.asDigraph�s$��	,���O�O�=�=�@�	
�	
rr#)FFN)r8rFrGrHr�r�r(r�r/r0r:r�r��propertyr�r�rrrr�r�6s����
 �	��,1�����>�
��
�����6�0��������$�?��?�
rr�)!�collections�	functoolsr�	itertoolsr�inspectrrrI�_corerr	�_introspectionr
�
namedtuplerrr r(�s�objectr+rUrWrZrarsrwr�r�r�r�r�rrr�<module>r�s�����1��*�(�!�+�
 �
 ��-N�O��
�0�&

� ����t��/$�f�/$��/$�d�	��8�"%&�P����5�u��($�f�($��($�V����t�� $�v� $�� $�D����5�u��
�v�
��
��'��+�b
��b
r

Zerion Mini Shell 1.0