ó
    &ÝNjé  ã                   ó†   • S SK r S SKrS SKJrJr  SSKJr   " S S\R                  5      r " S S\5      r	 " S	 S
\	5      r
g)é    N)Ú	GeneratorÚIterableé   )ÚResponseNotAcceptedc                   ó0   • \ rS rSrSrS\S\\   4S jrSrg)ÚStreamWatcheré   a%  
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                 ó   • [         e)zæ
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     ÚL/home/mande/repo/quber/.venv/lib/python3.13/site-packages/invoke/watchers.pyÚsubmitÚStreamWatcher.submit&   s
   € ô "Ð!ó    © N)	Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ústrr   r   Ú__static_attributes__r   r   r   r   r      s   † ñð:"˜Sð " X¨c¡]÷ "r   r   c            	       ól   • \ rS rSrSrS\S\SS4S jrS\S\S	\S\\   4S
 jrS\S\	\SS4   4S jr
Srg)Ú	Responderé5   z«
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                 ó*   • Xl         X l        SU l        g)a  
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__ÚResponder.__init__>   s   € ð ŒØ ŒØˆ�
r   r
   Ú
index_attrc                 ó¬   • [        X5      nXS n[        R                  " X%[        R                  5      nU(       a  [	        XU[        U5      -   5        U$ )az  
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_matchesÚResponder.pattern_matchesO   sF   € ô& ˜Ó)ˆØ�Vˆnˆä—*’*˜W¬2¯4©4Ó0ˆæÜ�D e¬c°#«hÑ&6Ô7Øˆr   c              #   ón   #   • U R                  XR                  S5       H  nU R                  v •  M     g 7f)Nr!   )r.   r   r   )r   r
   Ú_s      r   r   ÚResponder.submitk   s+   é € à×%Ñ% f¯l©l¸GÖDˆAØ—-‘-Ôò Eùs   ‚35)r!   r   r   )r   r   r   r   r   r   r"   r   r.   r   r   r   r   r   r   r   r   5   sh   † ñð ð ¨sð °tô ð"ØðØ$'ðØ58ðà	�#‰ôð8 ˜Sð   Y¨s°D¸$¨Ñ%?÷  r   r   c                   ód   ^ • \ rS rSrSrS\S\S\SS4U 4S jjrS	\S\\SS4   4U 4S
 jjrSr	U =r
$ )ÚFailingResponderéq   a  
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                 óL   >• [         TU ]  X5        X0l        SU l        SU l        g )Nr   F)Úsuperr"   r6   Úfailure_indexÚtried)r   r   r   r6   Ú	__class__s       €r   r"   ÚFailingResponder.__init__|   s$   ø€ Ü‰Ñ˜Ô+Ø ŒØˆÔØˆ�
r   r
   c                 ó  >• [         TU ]  U5      nU R                  XR                  S5      nU R                  (       a8  U(       a1  SR                  U R                  U R                  5      n[        U5      eU(       a  SU l        U$ )Nr9   z(Auto-response to r"{}" failed with {!r}!T)r8   r   r.   r6   r:   Úformatr   r   )r   r
   r   ÚfailedÚerrr;   s        €r   r   ÚFailingResponder.submit‚   si   ø€ ä‘7‘> &Ó)ˆà×%Ñ% f¯m©m¸_ÓMˆà�:�:ž&Ø<×CÑCØ—‘˜dŸm™móˆCô & cÓ*Ð*æØˆDŒJàˆr   )r9   r6   r:   )r   r   r   r   r   r   r"   r   r   r   Ú__classcell__)r;   s   @r   r4   r4   q   sL   ø† ñð ð ¨sð ¸cð Àd÷ ð˜Sð  Y¨s°D¸$¨Ñ%?÷ õ r   r4   )r'   Ú	threadingÚtypingr   r   Ú
exceptionsr   Úlocalr   r   r4   r   r   r   Ú<module>rG      s;   ðÛ 	Û ß &å +ô*"�I—O‘Oô *"ôZ9 �ô 9 ôx �yõ  r   