Ë
    zñ�jU#  ã                   ó�   — d dl mZ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 ddlmZ erddlmZ ddlmZ  G d	„ d
«      Zy)é    )ÚTYPE_CHECKINGÚAnyÚDictÚListÚOptionalÚTupleÚUnioné   )ÚConfig)ÚParserContextÚParseResult)ÚCallÚTask)Údebug)Ú
Collection)ÚResultc            	       óè   — e Zd ZdZ	 	 dddded   ded   d	dfd
„Zdeeeee	ee
f   f   ef   d	e	d   fd„Zdeeeeee	ee
f   f   ef   df   d	ed   fd„Zded   d	ed   fd„Zded   d	ed   fd„Zy)ÚExecutorz©
    An execution strategy for Task objects.

    Subclasses may override various extension points to change, add or remove
    behavior.

    .. versionadded:: 1.0
    NÚ
collectionr   Úconfigr   Úcorer   Úreturnc                 ój   — || _         |�|n	t        «       | _        |�|| _        yt        «       | _        y)a�  
        Initialize executor with handles to necessary data structures.

        :param collection:
            A `.Collection` used to look up requested tasks (and their default
            config data, if any) by name during execution.

        :param config:
            An optional `.Config` holding configuration state. Defaults to an
            empty `.Config` if not given.

        :param core:
            An optional `.ParseResult` holding parsed core program arguments.
            Defaults to ``None``.

        .. versionchanged:: 3.0
            The ``core`` attribute now defaults to an 'empty' `.ParseResult` if
            ``None`` was given.
        N)r   r   r   r   r   )Úselfr   r   r   s       úP/var/www/api.ozpay.ru/ozpay/venv/lib/python3.12/site-packages/invoke/executor.pyÚ__init__zExecutor.__init__   s/   € ð2 %ˆŒØ &Ð 2‘f¼»ˆŒØ Ð,�Dˆ�	´+³-ˆ�	ó    Útasks)r   r   c                 ól  — t        dj                  |D �cg c]  }|‘Œ c}«      «       | j                  |«      }t        dj                  |«      «       t        |«      }| j	                  |«      }	 | j
                  j                  j                  }|r| j                  |«      n|}i }|D ]ð  }||v xr |j                  }	t        dj                  |«      «       | j
                  }
| j                  j                  |j                  «      }|
j                  |«       |
j                  «        t        d«       |j                  |
| j                   ¬«      }|g|j"                  ¢­} |j$                  |i |j&                  ¤Ž}|	rt)        |«       |||j$                  <   Œò |S c c}w # t        $ r d}Y �Œ!w xY w)a  
        Execute one or more ``tasks`` in sequence.

        :param tasks:
            An all-purpose iterable of "tasks to execute", each member of which
            may take one of the following forms:

            **A string** naming a task from the Executor's `.Collection`. This
            name may contain dotted syntax appropriate for calling namespaced
            tasks, e.g. ``subcollection.taskname``. Such tasks are executed
            without arguments.

            **A two-tuple** whose first element is a task name string (as
            above) and whose second element is a dict suitable for use as
            ``**kwargs`` when calling the named task. E.g.::

                [
                    ('task1', {}),
                    ('task2', {'arg1': 'val1'}),
                    ...
                ]

            is equivalent, roughly, to::

                task1()
                task2(arg1='val1')

            **A `.ParserContext`** instance, whose ``.name`` attribute is used
            as the task name and whose ``.as_kwargs`` attribute is used as the
            task kwargs (again following the above specifications).

            .. note::
                When called without any arguments at all (i.e. when ``*tasks``
                is empty), the default task from ``self.collection`` is used
                instead, if defined.

        :returns:
            A dict mapping task objects to their return values.

            This dict may include pre- and post-tasks if any were executed. For
            example, in a collection with a ``build`` task depending on another
            task named ``setup``, executing ``build`` will result in a dict
            with two keys, one for ``build`` and one for ``setup``.

        .. versionadded:: 1.0
        zExamining top level tasks {!r}z#Tasks (now Calls) with kwargs: {!r}TzExecuting {!r}z/Finished loading collection & shell env configs)Úcore_parse_result)r   ÚformatÚ	normalizeÚlistÚexpand_callsr   r   ÚdedupeÚAttributeErrorÚ	autoprintr   ÚconfigurationÚ	called_asÚload_collectionÚload_shell_envÚmake_contextr   ÚargsÚtaskÚkwargsÚprint)r   r   ÚxÚcallsÚdirectÚexpandedr%   ÚresultsÚcallr'   r   Úcollection_configÚcontextr-   Úresults                  r   ÚexecutezExecutor.execute4   sš  € ôd 	Ð.×5Ñ5À%Ö6H¸Q²qÒ6HÓIÔJØ—‘˜uÓ%ˆÜÐ3×:Ñ:¸5ÓAÔBô �e“ˆð ×$Ñ$ UÓ+ˆð	Ø—[‘[×&Ñ&×-Ñ-ˆFñ *0�—‘˜HÔ%°Xˆàˆð ò 	(ˆDØ ˜Ò9¨4¯>©>ˆIÜÐ"×)Ñ)¨$Ó/Ô0ð —[‘[ˆFð
 !%§¡× =Ñ =¸d¿n¹nÓ MÐØ×"Ñ"Ð#4Ô5Ø×!Ñ!Ô#ÜÐCÔDð ×'Ñ'¨À$Ç)Á)Ð'ÓLˆGØÐ(˜dŸi™iÑ(ˆDØ�T—Y‘Y Ð4¨¯©Ñ4ˆFÙÜ�f”ð "(ˆG�D—I‘IÒð1	(ð2 ˆùò_ 7Iøô ò 	Ø‹Fð	ús   •	FÁ1 F$ Æ$F3Æ2F3.r   c                 ó€  — g }|D ]q  }t        |t        «      r|}i }n.t        |t        «      r|j                  }|j                  }n|\  }}t        | j                  |   ||¬«      }|j                  |«       Œs |sC| j                  j                  �-t        | j                  | j                  j                     «      g}|S )z³
        Transform arbitrary task list w/ various types, into `.Call` objects.

        See docstring for `~.Executor.execute` for details.

        .. versionadded:: 1.0
        )r/   r)   )	Ú
isinstanceÚstrr   ÚnameÚ	as_kwargsr   r   ÚappendÚdefault)r   r   r2   r.   r>   r/   Úcs          r   r"   zExecutor.normalize—   s¬   € ð ˆØò 	ˆDä˜$¤Ô$Ø�Ø‘Ü˜D¤-Ô0Ø—y‘y�ØŸ™‘à#‘��fÜ�T—_‘_ TÑ*°6ÀTÔJˆAØ�L‰L˜�Oð	ñ ˜Ÿ™×0Ñ0Ð<Ü˜$Ÿ/™/¨$¯/©/×*AÑ*AÑBÓCÐDˆEØˆr   r2   c                 óÂ   — g }t        d«       |D ]L  }||vr,t        dj                  |«      «       |j                  |«       Œ3t        dj                  |«      «       ŒN |S )zÏ
        Deduplicate a list of `tasks <.Call>`.

        :param calls: An iterable of `.Call` objects representing tasks.

        :returns: A list of `.Call` objects.

        .. versionadded:: 1.0
        zDeduplicating tasks...z{!r}: no duplicates found, okz%{!r}: found in list already, skipping)r   r!   r@   )r   r2   Údedupedr6   s       r   r%   zExecutor.dedupeµ   sf   € ð ˆÜÐ&Ô'Øò 	LˆDØ˜7Ñ"ÜÐ5×<Ñ<¸TÓBÔCØ—‘˜tÕ$äÐ=×DÑDÀTÓJÕKð	Lð ˆr   c                 óL  — g }|D ]œ  }t        |t        «      rt        |«      }t        dj	                  |«      «       |j                  | j                  |j                  «      «       |j                  |«       |j                  | j                  |j                  «      «       Œž |S )a¯  
        Expand a list of `.Call` objects into a near-final list of same.

        The default implementation of this method simply adds a task's
        pre/post-task list before/after the task itself, as necessary.

        Subclasses may wish to do other things in addition (or instead of) the
        above, such as multiplying the `calls <.Call>` by argument vectors or
        similar.

        .. versionadded:: 1.0
        zExpanding task-call {!r})
r<   r   r   r   r!   Úextendr$   Úprer@   Úpost)r   r2   Úretr6   s       r   r$   zExecutor.expand_callsÉ   sŒ   € ð ˆØò 	5ˆDô ˜$¤Ô%Ü˜D“z�ÜÐ,×3Ñ3°DÓ9Ô:ð �J‰J�t×(Ñ(¨¯©Ó2Ô3Ø�J‰J�tÔØ�J‰J�t×(Ñ(¨¯©Ó3Õ4ð!	5ð" ˆ
r   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r	   r=   r   r   r   r   r:   r   r"   r%   r$   © r   r   r   r      s  „ ñð &*Ø(,ñ	@à ð@ð ˜Ñ"ð@ð �}Ñ%ð	@ð
 
ó@ð:aØ˜C  s¨D°°c°©NÐ':Ñ!;¸]ÐJÑKðaà	ÐÑ	óaðFàØ�#�u˜S $ s¨C x¡.Ð0Ñ1°=Ð@ÑAÀ3ÐFñ
ðð
 
ˆf‰óð<˜D ™Lð ¨T°&©\ó ð( $ v¡,ð °4¸±<ô r   r   N)Útypingr   r   r   r   r   r   r	   r   r   Úparserr   r   r   r   r   Úutilr   r   r   Úrunnersr   r   rN   r   r   ú<module>rS      s/   ðß I× IÑ Iå ß .ß Ý áÝ&Ý÷[ò [r   