§
    xÅjEe  ã                   óÞ   — d dl Z d dlZd dlmZ d dlmZ d dl mZ d dlmZm	Z	m
Z
mZmZmZ d dlmZ ddlmZmZ dd	lmZmZmZ dd
lmZmZ ddlmZ  G d„ de¦  «        Z G d„ de¦  «        ZdS )é    N)Úcontextmanager)Úcycle)ÚPathLike)ÚAnyÚ	GeneratorÚIteratorÚListÚOptionalÚUnion)ÚMocké   )ÚConfigÚ	DataProxy)ÚAuthFailureÚFailureÚResponseNotAccepted)ÚResultÚRunner)ÚFailingResponderc                   ó¢  — e Zd ZU dZee         ed<   ee         ed<   eed<   	 	 ddee         deddfd	„Z	e
defd
„¦   «         Zej        deddfd„¦   «         Zdededefd„Zdddededefd„Zdededefd„Zdddededefd„Zdedefd„Zededed         fd„¦   «         Ze
defd„¦   «         Zedeeef         ded         fd„¦   «         ZdS )ÚContexta  
    Context-aware API wrapper & state-passing object.

    `.Context` objects are created during command-line parsing (or, if desired,
    by hand) and used to share parser and configuration state with executed
    tasks (see :ref:`why-context`).

    Specifically, the class offers wrappers for core API calls (such as `.run`)
    which take into account CLI parser flags, configuration files, and/or
    changes made at runtime. It also acts as a proxy for its `~.Context.config`
    attribute - see that attribute's documentation for details.

    Instances of `.Context` may be shared between tasks when executing
    sub-tasks - either the same context the caller was given, or an altered
    copy thereof (or, theoretically, a brand new one).

    .. versionadded:: 1.0
    Úcommand_prefixesÚcommand_cwdsÚ	remainderNÚ ÚconfigÚreturnc                 ó\   — |�|nt          ¦   «         }|                      |g g |¬¦  «         dS )a+  
        :param config:
            `.Config` object to use as the base configuration.

            Defaults to an anonymous/default `.Config` instance.

        :param remainder:
            The invoking program's :ref:`parser remainder <remainder>` value,
            if any was obtained.
        N)Ú_configr   r   r   )r   Ú_set)Úselfr   r   s      ú?C:\Projects\Historical\venv\Lib\site-packages\invoke/context.pyÚ__init__zContext.__init__;   sG   € ð "Ð-��µ6±8´8ˆØ�	Š	ØØØØð	 	ñ 	
ô 	
ð 	
ð 	
ð 	
ó    c                 ó   — | j         S )aÖ  
        The fully merged `.Config` object appropriate for this context.

        `.Config` settings (see their documentation for details) may be
        accessed like dictionary keys (``c.config['foo']``) or object
        attributes (``c.config.foo``).

        As a convenience shorthand, the `.Context` object proxies to its
        ``config`` attribute in the same way - e.g. ``c['foo']`` or
        ``c.foo`` returns the same value as ``c.config['foo']``.
        ©r   )r!   s    r"   r   zContext.configR   s   € ð Œ|Ðr$   Úvaluec                 ó2   — |                       |¬¦  «         d S )Nr&   )r    )r!   r'   s     r"   r   zContext.configc   s   € ð 	�	Š	˜%ˆ	Ñ Ô Ð Ð Ð r$   ÚcommandÚkwargsc                 ó^   — | j         j                             | ¦  «        } | j        ||fi |¤ŽS )a   
        Execute a local shell command, honoring config options.

        Specifically, this method instantiates a `.Runner` subclass (according
        to the ``runner`` config option; default is `.Local`) and calls its
        ``.run`` method with ``command`` and ``kwargs``.

        See `.Runner.run` for details on ``command`` and the available keyword
        arguments.

        .. versionadded:: 1.0
        )r   ÚrunnersÚlocalÚ_run©r!   r)   r*   Úrunners       r"   ÚrunzContext.runl   s8   € ð ”Ô$×*Ò*¨4Ñ0Ô0ˆØˆtŒy˜ Ð3Ð3¨FÐ3Ð3Ð3r$   r0   r   c                 óH   — |                       |¦  «        } |j        |fi |¤ŽS ©N)Ú_prefix_commandsr1   )r!   r0   r)   r*   s       r"   r.   zContext._run   s/   € Ø×'Ò'¨Ñ0Ô0ˆØˆvŒz˜'Ð,Ð, VÐ,Ð,Ð,r$   c                 ó^   — | j         j                             | ¦  «        } | j        ||fi |¤ŽS )a¥  
        Execute a shell command via ``sudo`` with password auto-response.

        **Basics**

        This method is identical to `run` but adds a handful of
        convenient behaviors around invoking the ``sudo`` program. It doesn't
        do anything users could not do themselves by wrapping `run`, but the
        use case is too common to make users reinvent these wheels themselves.

        .. note::
            If you intend to respond to sudo's password prompt by hand, just
            use ``run("sudo command")`` instead! The autoresponding features in
            this method will just get in your way.

        Specifically, `sudo`:

        * Places a `.FailingResponder` into the ``watchers`` kwarg (see
          :doc:`/concepts/watchers`) which:

            * searches for the configured ``sudo`` password prompt;
            * responds with the configured sudo password (``sudo.password``
              from the :doc:`configuration </concepts/configuration>`);
            * can tell when that response causes an authentication failure
              (e.g. if the system requires a password and one was not
              configured), and raises `.AuthFailure` if so.

        * Builds a ``sudo`` command string using the supplied ``command``
          argument, prefixed by various flags (see below);
        * Executes that command via a call to `run`, returning the result.

        **Flags used**

        ``sudo`` flags used under the hood include:

        - ``-S`` to allow auto-responding of password via stdin;
        - ``-p <prompt>`` to explicitly state the prompt to use, so we can be
          sure our auto-responder knows what to look for;
        - ``-u <user>`` if ``user`` is not ``None``, to execute the command as
          a user other than ``root``;
        - When ``-u`` is present, ``-H`` is also added, to ensure the
          subprocess has the requested user's ``$HOME`` set properly.

        **Configuring behavior**

        There are a couple of ways to change how this method behaves:

        - Because it wraps `run`, it honors all `run` config parameters and
          keyword arguments, in the same way that `run` does.

            - Thus, invocations such as ``c.sudo('command', echo=True)`` are
              possible, and if a config layer (such as a config file or env
              var) specifies that e.g. ``run.warn = True``, that too will take
              effect under `sudo`.

        - `sudo` has its own set of keyword arguments (see below) and they are
          also all controllable via the configuration system, under the
          ``sudo.*`` tree.

            - Thus you could, for example, pre-set a sudo user in a config
              file; such as an ``invoke.json`` containing ``{"sudo": {"user":
              "someuser"}}``.

        :param str password: Runtime override for ``sudo.password``.
        :param str user: Runtime override for ``sudo.user``.

        .. versionadded:: 1.0
        )r   r,   r-   Ú_sudor/   s       r"   ÚsudozContext.sudoƒ   s9   € ðJ ”Ô$×*Ò*¨4Ñ0Ô0ˆØˆtŒz˜& 'Ð4Ð4¨VÐ4Ð4Ð4r$   c                 ó”  — | j         j        j        }|                     d| j         j        j        ¦  «        }|                     d| j         j        j        ¦  «        }|                     di ¦  «        }d}|�d                     |¦  «        }d}	|r:d                     d                     | 	                    ¦   «         ¦  «        ¦  «        }	|  
                    |¦  «        }d                     ||	||¦  «        }
t          t          j        |¦  «        d	                     |¦  «        d
¬¦  «        }|                     dt          | j         j        j        ¦  «        ¦  «        }|                     |¦  «         	  |j        |
fd|i|¤ŽS # t$          $ r8}t'          |j        t*          ¦  «        rt-          |j        |¬¦  «        }|‚‚ d }~ww xY w)NÚpasswordÚuserÚenvr   z	-H -u {} z--preserve-env='{}' ú,zsudo -S -p '{}' {}{}{}z{}
zSorry, try again.
)ÚpatternÚresponseÚsentinelÚwatchers)ÚresultÚprompt)r   r7   rB   Úpopr9   r:   ÚgetÚformatÚjoinÚkeysr4   r   ÚreÚescapeÚlistr1   r@   Úappendr   Ú
isinstanceÚreasonr   r   rA   )r!   r0   r)   r*   rB   r9   r:   r;   Ú
user_flagsÚ	env_flagsÚcmd_strÚwatcherr@   ÚfailureÚerrors                  r"   r6   zContext._sudoÌ   sÁ  € Ø”Ô!Ô(ˆØ—:’:˜j¨$¬+Ô*:Ô*CÑDÔDˆØ�zŠz˜& $¤+Ô"2Ô"7Ñ8Ô8ˆØ�jŠj˜ Ñ#Ô#ˆð ˆ
ØÐØ$×+Ò+¨DÑ1Ô1ˆJØˆ	Øð 	LØ.×5Ò5°c·h²h¸s¿xºx¹z¼zÑ6JÔ6JÑKÔKˆIØ×'Ò'¨Ñ0Ô0ˆØ*×1Ò1Ø�I˜z¨7ñ
ô 
ˆõ #Ý”I˜fÑ%Ô%Ø—]’] 8Ñ,Ô,Ø*ð
ñ 
ô 
ˆð —:’:˜j­$¨t¬{¬Ô/GÑ*HÔ*HÑIÔIˆØ�Š˜Ñ Ô Ð ð	Ø�6”:˜gÐCÐC°ÐC¸FÐCÐCÐCøÝð 	ð 	ð 	õ ˜'œ.Õ*=Ñ>Ô>ð å#¨7¬>À&ÐIÑIÔI�Ø�ð øøøøð	øøøs   Å5F Æ
GÆ3GÇGc                 óÀ   — t          | j        ¦  «        }| j        }|r)|                     dd                     |¦  «        ¦  «         d                     ||gz   ¦  «        S )zÅ
        Prefixes ``command`` with all prefixes found in ``command_prefixes``.

        ``command_prefixes`` is a list of strings which is modified by the
        `prefix` context manager.
        r   zcd {}z && )rJ   r   ÚcwdÚinsertrE   rF   )r!   r)   ÚprefixesÚcurrent_directorys       r"   r4   zContext._prefix_commands
  s_   € õ ˜Ô-Ñ.Ô.ˆØ œHÐØð 	BØ�OŠO˜A˜wŸ~š~Ð.?Ñ@Ô@ÑAÔAÐAà�{Š{˜8 w iÑ/Ñ0Ô0Ð0r$   )NNNc              #   ó¶   K  — | j                              |¦  «         	 dV — | j                              ¦   «          dS # | j                              ¦   «          w xY w)a¦  
        Prefix all nested `run`/`sudo` commands with given command plus ``&&``.

        Most of the time, you'll want to be using this alongside a shell script
        which alters shell state, such as ones which export or alter shell
        environment variables.

        For example, one of the most common uses of this tool is with the
        ``workon`` command from `virtualenvwrapper
        <https://virtualenvwrapper.readthedocs.io/en/latest/>`_::

            with c.prefix('workon myvenv'):
                c.run('./manage.py migrate')

        In the above snippet, the actual shell command run would be this::

            $ workon myvenv && ./manage.py migrate

        This context manager is compatible with `cd`, so if your virtualenv
        doesn't ``cd`` in its ``postactivate`` script, you could do the
        following::

            with c.cd('/path/to/app'):
                with c.prefix('workon myvenv'):
                    c.run('./manage.py migrate')
                    c.run('./manage.py loaddata fixture')

        Which would result in executions like so::

            $ cd /path/to/app && workon myvenv && ./manage.py migrate
            $ cd /path/to/app && workon myvenv && ./manage.py loaddata fixture

        Finally, as alluded to above, `prefix` may be nested if desired, e.g.::

            with c.prefix('workon myenv'):
                c.run('ls')
                with c.prefix('source /some/script'):
                    c.run('touch a_file')

        The result::

            $ workon myenv && ls
            $ workon myenv && source /some/script && touch a_file

        Contrived, but hopefully illustrative.

        .. versionadded:: 1.0
        N)r   rK   rC   )r!   r)   s     r"   ÚprefixzContext.prefix  sd   è è € ðd 	Ô×$Ò$ WÑ-Ô-Ð-ð	(ØˆEˆEˆEàÔ!×%Ò%Ñ'Ô'Ð'Ð'Ð'øˆDÔ!×%Ò%Ñ'Ô'Ð'Ð'øøøs	   ž= ½Ac                 óF  — | j         sdS t          t          t          | j         ¦  «        ¦  «        ¦  «        D ]1\  }}|                     d¦  «        s|                     d¦  «        r nŒ2d„ | j         |d…         D ¦   «         }t          t          j        j        |Ž ¦  «        S )zs
        Return the current working directory, accounting for uses of `cd`.

        .. versionadded:: 1.0
        r   ú~ú/c                 ó:   — g | ]}|                      d d¦  «        ‘ŒS )ú z\ )Úreplace)Ú.0Úpaths     r"   ú
<listcomp>zContext.cwd.<locals>.<listcomp>d  s&   € ÐLÐLÐL¨d�—’˜c 5Ñ)Ô)ÐLÐLÐLr$   N)	r   ÚreversedrJ   Ú	enumerateÚ
startswithÚstrÚosrb   rF   )r!   Úirb   Úpathss       r"   rU   zContext.cwdP  s°   € ð Ô ð 	ð �2õ  ¥¥Y¨tÔ/@Ñ%AÔ%AÑ BÔ BÑCÔCð 	ð 	‰GˆAˆtØ�Š˜sÑ#Ô#ð  t§¢°sÑ';Ô';ð Ø�ðð
 MÐL°dÔ6GÈÈÈÔ6KÐLÑLÔLˆÝ•2”7”< Ð'Ñ(Ô(Ð(r$   rb   c              #   óÔ   K  — t          |¦  «        }| j                             |¦  «         	 dV — | j                             ¦   «          dS # | j                             ¦   «          w xY w)aq  
        Context manager that keeps directory state when executing commands.

        Any calls to `run`, `sudo`, within the wrapped block will implicitly
        have a string similar to ``"cd <path> && "`` prefixed in order to give
        the sense that there is actually statefulness involved.

        Because use of `cd` affects all such invocations, any code making use
        of the `cwd` property will also be affected by use of `cd`.

        Like the actual 'cd' shell builtin, `cd` may be called with relative
        paths (keep in mind that your default starting directory is your user's
        ``$HOME``) and may be nested as well.

        Below is a "normal" attempt at using the shell 'cd', which doesn't work
        since all commands are executed in individual subprocesses -- state is
        **not** kept between invocations of `run` or `sudo`::

            c.run('cd /var/www')
            c.run('ls')

        The above snippet will list the contents of the user's ``$HOME``
        instead of ``/var/www``. With `cd`, however, it will work as expected::

            with c.cd('/var/www'):
                c.run('ls')  # Turns into "cd /var/www && ls"

        Finally, a demonstration (see inline comments) of nesting::

            with c.cd('/var/www'):
                c.run('ls') # cd /var/www && ls
                with c.cd('website1'):
                    c.run('ls')  # cd /var/www/website1 && ls

        .. note::
            Space characters will be escaped automatically to make dealing with
            such directory names easier.

        .. versionadded:: 1.0
        .. versionchanged:: 1.5
            Explicitly cast the ``path`` argument (the only argument) to a
            string; this allows any object defining ``__str__`` to be handed in
            (such as the various ``Path`` objects out there), and not just
            string literals.
        N)rg   r   rK   rC   )r!   rb   s     r"   Úcdz
Context.cdg  so   è è € õ^ �4‰yŒyˆØÔ× Ò  Ñ&Ô&Ð&ð	$ØˆEˆEˆEàÔ×!Ò!Ñ#Ô#Ð#Ð#Ð#øˆDÔ×!Ò!Ñ#Ô#Ð#Ð#øøøs   ­A ÁA')Nr   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   rg   Ú__annotations__r
   r   r#   Úpropertyr   Úsetterr   r   r1   r.   r7   r6   r4   r   r   rZ   rU   r   r   rl   © r$   r"   r   r      s^  € € € € € € ðð ð6 ˜3”iÐÐÑð �s”)ÐÐÑð €N€N�Nð $(Øð
ð 
à˜Ô ð
ð ð
ð 
ð	
ð 
ð 
ð 
ð. ð˜ð ð ð ñ „Xðð  „]ð!˜Fð ! tð !ð !ð !ñ „]ð!ð4˜3ð 4¨#ð 4°&ð 4ð 4ð 4ð 4ð&-˜8ð -¨cð -¸Sð -ÀVð -ð -ð -ð -ðF5˜Cð F5¨3ð F5°6ð F5ð F5ð F5ð F5ðR9˜Hð 9¨sð 9¸cð 9Àfð 9ð 9ð 9ð 9ð|1¨ð 1°ð 1ð 1ð 1ð 1ð ð5(˜cð 5( iÐ0@Ô&Að 5(ð 5(ð 5(ñ „^ð5(ðn ð)�Sð )ð )ð )ñ „Xð)ð, ð3$�u˜X s˜]Ô+ð 3$°	Ð:JÔ0Kð 3$ð 3$ð 3$ñ „^ð3$ð 3$ð 3$r$   r   c                   ó¶   ‡ — e Zd ZdZddee         deddfˆ fd„Zdedee         fd„Z	d	e
d
e
defd„Zd
e
dededefd„Zd
e
dededefd„Zd	e
d
e
deddfd„Zˆ xZS )ÚMockContextaÇ  
    A `.Context` whose methods' return values can be predetermined.

    Primarily useful for testing Invoke-using codebases.

    .. note::
        This class wraps its ``run``, etc methods in `unittest.mock.Mock`
        objects. This allows you to easily assert that the methods (still
        returning the values you prepare them with) were actually called.

    .. note::
        Methods not given `Results <.Result>` to yield will raise
        ``NotImplementedError`` if called (since the alternative is to call the
        real underlying method - typically undesirable when mocking.)

    .. versionadded:: 1.0
    .. versionchanged:: 1.5
        Added ``Mock`` wrapping of ``run`` and ``sudo``.
    Nr   r*   r   c           
      ó  •— t          ¦   «                              |¦  «         |                      d|                     dd¦  «        ¦  «         |                     ¦   «         D �]$\  }}t
          t          t          f}t          |t          ¦  «        r3|                     ¦   «         D ]\  }}|  
                    |¦  «        ||<   Œngt          ||¦  «        st          |d¦  «        r|  
                    |¦  «        }n1d}t          |                     t          |¦  «        ¦  «        ¦  «        ‚|                      d                     |¦  «        |¦  «         |                      |t          t!          | |¦  «        ¬¦  «        ¦  «         �Œ&dS )	aì  
        Create a ``Context``-like object whose methods yield `.Result` objects.

        :param config:
            A Configuration object to use. Identical in behavior to `.Context`.

        :param run:
            A data structure indicating what `.Result` objects to return from
            calls to the instantiated object's `~.Context.run` method (instead
            of actually executing the requested shell command).

            Specifically, this kwarg accepts:

            - A single `.Result` object.
            - A boolean; if True, yields a `.Result` whose ``exited`` is ``0``,
              and if False, ``1``.
            - An iterable of the above values, which will be returned on each
              subsequent call to ``.run`` (the first item on the first call,
              the second on the second call, etc).
            - A dict mapping command strings or compiled regexen to the above
              values (including an iterable), allowing specific
              call-and-response semantics instead of assuming a call order.

        :param sudo:
            Identical to ``run``, but whose values are yielded from calls to
            `~.Context.sudo`.

        :param bool repeat:
            A flag determining whether results yielded by this class' methods
            repeat or are consumed.

            For example, when a single result is indicated, it will normally
            only be returned once, causing ``NotImplementedError`` afterwards.
            But when ``repeat=True`` is given, that result is returned on
            every call, forever.

            Similarly, iterable results are normally exhausted once, but when
            this setting is enabled, they are wrapped in `itertools.cycle`.

            Default: ``True``.

        :raises:
            ``TypeError``, if the values given to ``run`` or other kwargs
            aren't of the expected types.

        .. versionchanged:: 1.5
            Added support for boolean and string result values.
        .. versionchanged:: 1.5
            Added support for regex dict keys.
        .. versionchanged:: 1.5
            Added the ``repeat`` keyword argument.
        .. versionchanged:: 2.0
            Changed ``repeat`` default value from ``False`` to ``True``.
        Ú__repeatÚrepeatTÚ__iter__z)Not sure how to yield results from a {!r}ú__{})ÚwrapsN)Úsuperr#   r    rC   Úitemsr   Úboolrg   rL   ÚdictÚ
_normalizeÚhasattrÚ	TypeErrorrE   Útyper   Úgetattr)
r!   r   r*   ÚmethodÚresultsÚ
singletonsÚkeyr'   ÚerrÚ	__class__s
            €r"   r#   zMockContext.__init__³  sq  ø€ õp 	‰Œ×Ò˜Ñ Ô Ð à�	Š	�*˜fŸjšj¨°4Ñ8Ô8Ñ9Ô9Ð9à%Ÿ|š|™~œ~ð 	Añ 	A‰OˆF�Gõ !¥$­Ð,ˆJÝ˜'¥4Ñ(Ô(ð 
;Ø")§-¢-¡/¤/ð :ð :‘J�C˜Ø#'§?¢?°5Ñ#9Ô#9�G˜C‘L�Lð:å˜G ZÑ0Ô0ð ;µGØ˜ñ5ô 5ð ;ð Ÿ/š/¨'Ñ2Ô2��ð B�Ý §
¢
­4°©=¬=Ñ 9Ô 9Ñ:Ô:Ð:à�IŠI�f—m’m FÑ+Ô+¨WÑ5Ô5Ð5à�IŠI�f�d­°°vÑ)>Ô)>Ð?Ñ?Ô?Ñ@Ô@Ð@Ñ@ð%	Að 	Ar$   r'   c                 ó‚  — t          |d¦  «        rt          |t          ¦  «        r|g}g }|D ]e}t          |t          ¦  «        rt	          |rdnd¬¦  «        }n$t          |t          ¦  «        rt	          |¦  «        }|                     |¦  «         Œft          | d¦  «        rt          |¦  «        nt          |¦  «        S )Nrz   r   r   )Úexitedrx   )	r‚   rL   rg   r   r   rK   r…   r   Úiter)r!   r'   r‡   Úobjs       r"   r�   zMockContext._normalize  sÃ   € å�u˜jÑ)Ô)ð 	­Z¸½sÑ-CÔ-Cð 	Ø�GˆEàˆØð 	 ð 	 ˆCÝ˜#�tÑ$Ô$ð "Ý¨ O A A°!Ð4Ñ4Ô4��Ý˜C¥Ñ%Ô%ð "Ý˜S‘k”k�Ø�NŠN˜3ÑÔÐÐå!(¨¨zÑ!:Ô!:ÐM�u�W‰~Œ~ˆ~ÅÀWÁÄÐMr$   Úattnamer)   c                 ó´  — 	 t          | |¦  «        }t          |t          ¦  «        rd	 ||         }nZ# t          $ rM |                     ¦   «         D ].\  }}t          |d¦  «        r|                     |¦  «        r|} nŒ/t          ‚Y nw xY wt          |¦  «        }|j        s||_        |S # t          t          t          t          f$ r t          |¦  «        ‚w xY w)NÚmatch)r…   rL   r€   ÚKeyErrorr~   r‚   r’   Únextr)   ÚAttributeErrorÚ
IndexErrorÚStopIterationÚNotImplementedError)r!   r�   r)   r�   r‰   r'   rA   s          r"   Ú_yield_resultzMockContext._yield_result  s  € ð	/Ý˜$ Ñ(Ô(ˆCå˜#�tÑ$Ô$ð 'ð'Ø˜gœ,�C�CøÝð 	'ð 	'ð 	'ð '*§i¢i¡k¤kð 'ð '™
˜˜UÝ" 3¨Ñ0Ô0ð "°S·Y²Y¸wÑ5GÔ5Gð "Ø"'˜CØ!˜Eøõ '˜ð "˜Eð	'øøøõ " #™YœYˆFð ”>ð )Ø!(�”ØˆMøÝ¥
­HµmÐDð 	/ð 	/ð 	/å% gÑ.Ô.Ð.ð	/øøøs,   ‚%B* ¨1 °B* ±ABÂB* ÂBÂ!B* Â*-CÚargsc                 ó.   — |                       d|¦  «        S )NÚ__run©r™   ©r!   r)   rš   r*   s       r"   r1   zMockContext.run5  s   € ð
 ×!Ò! '¨7Ñ3Ô3Ð3r$   c                 ó.   — |                       d|¦  «        S )NÚ__sudor�   rž   s       r"   r7   zMockContext.sudo<  s   € ð
 ×!Ò! (¨GÑ4Ô4Ð4r$   rA   c                 óð   — d                      |¦  «        }t          d¦  «        }	 t          | |¦  «        }n# t          $ r |‚w xY wt	          |t
          ¦  «        s|‚|                      |¦  «        ||<   dS )aå  
        Modify the stored mock results for given ``attname`` (e.g. ``run``).

        This is similar to how one instantiates `MockContext` with a ``run`` or
        ``sudo`` dict kwarg. For example, this::

            mc = MockContext(run={'mycommand': Result("mystdout")})
            assert mc.run('mycommand').stdout == "mystdout"

        is functionally equivalent to this::

            mc = MockContext()
            mc.set_result_for('run', 'mycommand', Result("mystdout"))
            assert mc.run('mycommand').stdout == "mystdout"

        `set_result_for` is mostly useful for modifying an already-instantiated
        `MockContext`, such as one created by test setup or helper methods.

        .. versionadded:: 1.0
        r{   z>Can't update results for non-dict or nonexistent mock results!N)rE   rƒ   r…   r•   rL   r€   r�   )r!   r�   r)   rA   Úheckr'   s         r"   Úset_result_forzMockContext.set_result_forC  s�   € ð. —-’- Ñ(Ô(ˆÝØLñ
ô 
ˆð	Ý˜D 'Ñ*Ô*ˆEˆEøÝð 	ð 	ð 	ØˆJð	øøøå˜%¥Ñ&Ô&ð 	ØˆJàŸš¨Ñ0Ô0ˆˆg‰ˆˆs	   ¦7 ·Ar3   )rm   rn   ro   rp   r
   r   r   r#   r   r�   rg   r   r™   r1   r7   r£   Ú__classcell__)r‹   s   @r"   rv   rv   ž  sd  ø€ € € € € ðð ð(NAð NA˜x¨Ô/ð NAÀ#ð NAÈ$ð NAð NAð NAð NAð NAð NAð`N ð N¨°¬ð Nð Nð Nð Nð(/ Sð /°3ð /¸6ð /ð /ð /ð /ð<4˜3ð 4 sð 4°cð 4¸fð 4ð 4ð 4ð 4ð5˜Cð 5¨ð 5°sð 5¸vð 5ð 5ð 5ð 5ð%1Øð%1Ø%(ð%1Ø28ð%1à	ð%1ð %1ð %1ð %1ð %1ð %1ð %1ð %1r$   rv   )rh   rH   Ú
contextlibr   Ú	itertoolsr   r   Útypingr   r   r   r	   r
   r   Úunittest.mockr   r   r   r   Ú
exceptionsr   r   r   r,   r   r   r@   r   r   rv   rt   r$   r"   ú<module>rª      s‚  ðØ 	€	€	€	Ø 	€	€	€	Ø %Ð %Ð %Ð %Ð %Ð %Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð Ð Ð Ð Ð Ð à %Ð %Ð %Ð %Ð %Ð %Ð %Ð %Ø AÐ AÐ AÐ AÐ AÐ AÐ AÐ AÐ AÐ AØ #Ð #Ð #Ð #Ð #Ð #Ð #Ð #Ø &Ð &Ð &Ð &Ð &Ð &ðE$ð E$ð E$ð E$ð E$ˆiñ E$ô E$ð E$ðPJ1ð J1ð J1ð J1ð J1�'ñ J1ô J1ð J1ð J1ð J1r$   