§
    xÅjé  ã                   ó�   — d dl Z d dlZd dlmZmZ ddlmZ  G d„ dej        ¦  «        Z G d„ de¦  «        Z	 G d	„ d
e	¦  «        Z
dS )é    N)Ú	GeneratorÚIterableé   )ÚResponseNotAcceptedc                   ó.   — e Zd ZdZdedee         fd„ZdS )ÚStreamWatchera}  
    A class whose subclasses may act on seen stream data from subprocesses.

    Subclasses must exhibit the following API; see `Responder` for a concrete
    example.

    * ``__init__`` is completely up to each subclass, though as usual,
      subclasses *of* subclasses should be careful to make use of `super` where
      appropriate.
    * `submit` must accept the entire current contents of the stream being
      watched, as a string, and may optionally return an iterable of strings
      (or act as a generator iterator, i.e. multiple calls to ``yield
      <string>``), which will each be written to the subprocess' standard
      input.

    .. note::
        `StreamWatcher` subclasses exist in part to enable state tracking, such
        as detecting when a submitted password didn't work & erroring (or
        prompting a user, or etc). Such bookkeeping isn't easily achievable
        with simple callback functions.

    .. note::
        `StreamWatcher` subclasses `threading.local` so that its instances can
        be used to 'watch' both subprocess stdout and stderr in separate
        threads.

    .. versionadded:: 1.0
    ÚstreamÚreturnc                 ó   — t           ‚)a  
        Act on ``stream`` data, potentially returning responses.

        :param str stream:
            All data read on this stream since the beginning of the session.

        :returns:
            An iterable of ``str`` (which may be empty).

        .. versionadded:: 1.0
        )ÚNotImplementedError)Úselfr	   s     ú@C:\Projects\Historical\venv\Lib\site-packages\invoke/watchers.pyÚsubmitzStreamWatcher.submit&   s
   € õ "Ð!ó    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústrr   r   © r   r   r   r      sD   € € € € € ðð ð:"˜Sð " X¨c¤]ð "ð "ð "ð "ð "ð "r   r   c            	       ól   — e Zd ZdZdededdfd„Zdedededee         fd	„Zdedeeddf         fd
„Z	dS )Ú	Responderz»
    A parameterizable object that submits responses to specific patterns.

    Commonly used to implement password auto-responds for things like ``sudo``.

    .. versionadded:: 1.0
    ÚpatternÚresponser
   Nc                 ó0   — || _         || _        d| _        dS )aY  
        Imprint this `Responder` with necessary parameters.

        :param pattern:
            A raw string (e.g. ``r"\[sudo\] password for .*:"``) which will be
            turned into a regular expression.

        :param response:
            The string to submit to the subprocess' stdin when ``pattern`` is
            detected.
        r   N)r   r   Úindex)r   r   r   s      r   Ú__init__zResponder.__init__>   s   € ð ˆŒØ ˆŒØˆŒ
ˆ
ˆ
r   r	   Ú
index_attrc                 óÀ   — t          | |¦  «        }||d…         }t          j        ||t          j        ¦  «        }|r!t	          | ||t          |¦  «        z   ¦  «         |S )aÂ  
        Generic "search for pattern in stream, using index" behavior.

        Used here and in some subclasses that want to track multiple patterns
        concurrently.

        :param str stream: The same data passed to ``submit``.
        :param str pattern: The pattern to search for.
        :param str index_attr: The name of the index attribute to use.
        :returns: An iterable of string matches.

        .. versionadded:: 1.0
        N)ÚgetattrÚreÚfindallÚSÚsetattrÚlen)r   r	   r   r   r   ÚnewÚmatchess          r   Úpattern_matcheszResponder.pattern_matchesO   s_   € õ& ˜˜jÑ)Ô)ˆØ�U�V�VŒnˆå”*˜W c­2¬4Ñ0Ô0ˆàð 	8Ý�D˜* e­c°#©h¬hÑ&6Ñ7Ô7Ð7Øˆr   c              #   óZ   K  — |                       || j        d¦  «        D ]}| j        V — Œd S )Nr   )r(   r   r   )r   r	   Ú_s      r   r   zResponder.submitk   sD   è è € à×%Ò% f¨d¬l¸GÑDÔDð 	 ð 	 ˆAØ”-ÐÐÐÐð	 ð 	 r   )
r   r   r   r   r   r   r   r(   r   r   r   r   r   r   r   5   s¬   € € € € € ðð ð ð ¨sð °tð ð ð ð ð"ØðØ$'ðØ58ðà	�#Œðð ð ð ð8 ˜Sð   Y¨s°D¸$¨Ô%?ð  ð  ð  ð  ð  ð  r   r   c                   óZ   ‡ — e Zd ZdZdedededdfˆ fd„Zdedeeddf         fˆ fd	„Zˆ xZS )
ÚFailingRespondera  
    Variant of `Responder` which is capable of detecting incorrect responses.

    This class adds a ``sentinel`` parameter to ``__init__``, and its
    ``submit`` will raise `.ResponseNotAccepted` if it detects that sentinel
    value in the stream.

    .. versionadded:: 1.0
    r   r   Úsentinelr
   Nc                 óv   •— t          ¦   «                              ||¦  «         || _        d| _        d| _        d S )Nr   F)Úsuperr   r-   Úfailure_indexÚtried)r   r   r   r-   Ú	__class__s       €r   r   zFailingResponder.__init__|   s7   ø€ Ý‰Œ×Ò˜ (Ñ+Ô+Ð+Ø ˆŒØˆÔØˆŒ
ˆ
ˆ
r   r	   c                 ó  •— t          ¦   «                              |¦  «        }|                      || j        d¦  «        }| j        r1|r/d                     | j        | j        ¦  «        }t          |¦  «        ‚|rd| _        |S )Nr0   z(Auto-response to r"{}" failed with {!r}!T)r/   r   r(   r-   r1   Úformatr   r   )r   r	   r   ÚfailedÚerrr2   s        €r   r   zFailingResponder.submit‚   s„   ø€ å‘7”7—>’> &Ñ)Ô)ˆà×%Ò% f¨d¬m¸_ÑMÔMˆàŒ:ð 	+˜&ð 	+Ø<×CÒCØ”˜dœmñô ˆCõ & cÑ*Ô*Ð*àð 	ØˆDŒJàˆr   )	r   r   r   r   r   r   r   r   Ú__classcell__)r2   s   @r   r,   r,   q   sš   ø€ € € € € ðð ð ð ¨sð ¸cð Àdð ð ð ð ð ð ð˜Sð  Y¨s°D¸$¨Ô%?ð ð ð ð ð ð ð ð ð ð r   r,   )r!   Ú	threadingÚtypingr   r   Ú
exceptionsr   Úlocalr   r   r,   r   r   r   ú<module>r<      sÐ   ðØ 	€	€	€	Ø Ð Ð Ð Ø &Ð &Ð &Ð &Ð &Ð &Ð &Ð &à +Ð +Ð +Ð +Ð +Ð +ð*"ð *"ð *"ð *"ð *"�I”Oñ *"ô *"ð *"ðZ9 ð 9 ð 9 ð 9 ð 9 �ñ 9 ô 9 ð 9 ðx ð  ð  ð  ð  �yñ  ô  ð  ð  ð  r   