§
    xÅ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dS )é    )ÚTYPE_CHECKINGÚAnyÚDictÚListÚOptionalÚTupleÚUnioné   )ÚConfig)ÚParserContextÚParseResult)ÚCallÚTask)Údebug)Ú
Collection)ÚResultc            	       óD  — 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dS )Ú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                 óp   — || _         |�|nt          ¦   «         | _        |�|nt          ¦   «         | _        dS )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       ú@C:\Projects\Historical\venv\Lib\site-packages\invoke/executor.pyÚ__init__zExecutor.__init__   s7   € ð2 %ˆŒØ &Ð 2�f�f½¹¼ˆŒØ Ð,�D�Dµ+±-´-ˆŒ	ˆ	ˆ	ó    Útasks)r   r   c                 ó\  — t          d                     d„ |D ¦   «         ¦  «        ¦  «         |                      |¦  «        }t          d                     |¦  «        ¦  «         t          |¦  «        }|                      |¦  «        }	 | j        j        j        }n# t          $ r d}Y nw xY w|r|                      |¦  «        n|}i }|D ]á}||v o|j	        }t          d                     |¦  «        ¦  «         | j        }	| j
                             |j        ¦  «        }
|	                     |
¦  «         |	                     ¦   «          t          d¦  «         |                     |	| j        ¬¦  «        }|g|j        ¢R } |j        |i |j        ¤Ž}|rt)          |¦  «         |||j        <   Œâ|S )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}c                 ó   — g | ]}|‘ŒS © r!   )Ú.0Úxs     r   ú
<listcomp>z$Executor.execute.<locals>.<listcomp>f   s   € Ð6HÐ6HÐ6H¸Q°qÐ6HÐ6HÐ6Hr   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   ÚcallsÚdirectÚexpandedr*   ÚresultsÚcallr,   r   Úcollection_configÚcontextr2   Úresults                 r   ÚexecutezExecutor.execute4   sá  € õd 	Ð.×5Ò5Ð6HÐ6HÀ%Ð6HÑ6HÔ6HÑIÔIÑJÔJÐJØ—’˜uÑ%Ô%ˆÝÐ3×:Ò:¸5ÑAÔAÑBÔBÐBõ �e‘”ˆð ×$Ò$ UÑ+Ô+ˆð	Ø”[Ô&Ô-ˆFˆFøÝð 	ð 	ð 	ØˆFˆFˆFð	øøøð *0Ð=�—’˜HÑ%Ô%Ð%°Xˆàˆð ð 	(ð 	(ˆDØ ˜Ð9¨4¬>ˆIÝÐ"×)Ò)¨$Ñ/Ô/Ñ0Ô0Ð0ð ”[ˆFð
 !%¤× =Ò =¸d¼nÑ MÔ MÐØ×"Ò"Ð#4Ñ5Ô5Ð5Ø×!Ò!Ñ#Ô#Ð#ÝÐCÑDÔDÐDð ×'Ò'¨À$Ä)Ð'ÑLÔLˆGØÐ(˜dœiÐ(Ð(ˆDØ�T”Y Ð4¨¬Ð4Ð4ˆFØð Ý�f‘”�ð "(ˆG�D”IÑÐØˆs   Â	B ÂB*Â)B*.r   c                 ód  — g }|D ]w}t          |t          ¦  «        r|}i }n)t          |t          ¦  «        r|j        }|j        }n|\  }}t          | j        |         ||¬¦  «        }|                     |¦  «         Œx|s1| 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
        )r4   r.   )	Ú
isinstanceÚstrr   ÚnameÚ	as_kwargsr   r   ÚappendÚdefault)r   r   r6   r3   rB   r4   Úcs          r   r'   zExecutor.normalize—   sÁ   € ð ˆØð 	ð 	ˆDå˜$¥Ñ$Ô$ð $Ø�Ø��Ý˜D¥-Ñ0Ô0ð $Ø”y�Øœ��à#‘��fÝ�T”_ TÔ*°6ÀTÐJÑJÔJˆAØ�LŠL˜‰OŒOˆOˆOØð 	E˜œÔ0Ð<Ý˜$œ/¨$¬/Ô*AÔBÑCÔCÐDˆEØˆr   r6   c                 óî   — g }t          d¦  «         |D ]`}||vr8t          d                     |¦  «        ¦  «         |                     |¦  «         Œ>t          d                     |¦  «        ¦  «         Œa|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&   rD   )r   r6   Údedupedr:   s       r   r*   zExecutor.dedupeµ   s‹   € ð ˆÝÐ&Ñ'Ô'Ð'Øð 	Lð 	LˆDØ˜7Ð"Ð"ÝÐ5×<Ò<¸TÑBÔBÑCÔCÐCØ—’˜tÑ$Ô$Ð$Ð$åÐ=×DÒDÀTÑJÔJÑKÔKÐKÐKØˆr   c                 ó~  — g }|D ]·}t          |t          ¦  «        rt          |¦  «        }t          d                     |¦  «        ¦  «         |                     |                      |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)   ÚprerD   Úpost)r   r6   Úretr:   s       r   r)   zExecutor.expand_callsÉ   s´   € ð ˆØð 	5ð 	5ˆDõ ˜$¥Ñ%Ô%ð "Ý˜D‘z”z�ÝÐ,×3Ò3°DÑ9Ô9Ñ:Ô:Ð:ð �JŠJ�t×(Ò(¨¬Ñ2Ô2Ñ3Ô3Ð3Ø�JŠJ�tÑÔÐØ�JŠJ�t×(Ò(¨¬Ñ3Ô3Ñ4Ô4Ð4Ð4Øˆ
r   )NN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r	   rA   r   r   r   r   r>   r   r'   r*   r)   r!   r   r   r   r      sp  € € € € € ðð ð &*Ø(,ð	@ð @à ð@ð ˜Ô"ð@ð �}Ô%ð	@ð
 
ð@ð @ð @ð @ð:aØ˜C  s¨D°°c°¬NÐ':Ô!;¸]ÐJÔKðaà	ÐÔ	ðað að 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   r!   r   r   ú<module>rV      s÷   ðØ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ IÐ Ià Ð Ð Ð Ð Ð Ø .Ð .Ð .Ð .Ð .Ð .Ð .Ð .Ø Ð Ð Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð àð  Ø&Ð&Ð&Ð&Ð&Ð&ØÐÐÐÐÐð[ð [ð [ð [ð [ñ [ô [ð [ð [ð [r   