
    khu                         d dl Z d dlZd dlmZ d dlmZmZ d dlmZ d dl	m
Z
 d dlmZmZmZ ddlmZ dd	lmZ dd
lmZ  G d d      Z G d de      Zy)    N)
ModuleSpec)module_from_specspec_from_file_location)Path)
ModuleType)AnyOptionalTuple   )Config)CollectionNotFound)debugc                   `    e Zd ZdZd
ded   ddfdZdedee   fdZd
dee   de	e
ef   fd	Zy)Loaderzo
    Abstract class defining how to find/import a session's base `.Collection`.

    .. versionadded:: 1.0
    Nconfigr   returnc                 *    |
t               }|| _        y)a  
        Set up a new loader with some `.Config`.

        :param config:
            An explicit `.Config` to use; it is referenced for loading-related
            config options. Defaults to an anonymous ``Config()`` if none is
            given.
        N)r   r   )selfr   s     _/var/www/pru.catia.catastroantioquia-mas.com/tasa/lib/python3.12/site-packages/invoke/loader.py__init__zLoader.__init__   s     >XF    namec                     t         )a  
        Implementation-specific finder method seeking collection ``name``.

        Must return a ModuleSpec valid for use by `importlib`, which is
        typically a name string followed by the contents of the 3-tuple
        returned by `importlib.module_from_spec` (``name``, ``loader``,
        ``origin``.)

        For a sample implementation, see `.FilesystemLoader`.

        .. versionadded:: 1.0
        )NotImplementedError)r   r   s     r   findzLoader.find"   s
     "!r   c                 p   | | j                   j                  j                  }| j                  |      }|r|j                  r|j
                  rt        |j
                        }|j                  }|}|j                  r|j                  }t        |      }|t        j                  vr t        j                  j                  d|       t        |      }|t        j                  |j                  <   |j                  j                  |       |t        |      fS d}t!        |j#                  |             t$        )a  
        Load and return collection module identified by ``name``.

        This method requires a working implementation of `.find` in order to
        function.

        In addition to importing the named module, it will add the module's
        parent directory to the front of `sys.path` to provide normal Python
        import behavior (i.e. so the loaded module may load local-to-it modules
        or packages.)

        :returns:
            Two-tuple of ``(module, directory)`` where ``module`` is the
            collection-containing Python module object, and ``directory`` is
            the string path to the directory the module was found in.

        .. versionadded:: 1.0
        r   z-ImportError loading {!r}, raising ImportError)r   taskscollection_namer   loaderoriginr   parentstrsyspathinsertr   modulesr   exec_moduler   formatImportError)	r   r   specsource_fileenclosing_dirmodule_parentenclosing_strmodulemsgs	            r   loadzLoader.load1   s    & <;;$$44DyyDKKDKKt{{+K (..M
 *M{{ - 4 4.MCHH,=1%d+F%+CKK		"KK##F+3}---=cjjr   N)__name__
__module____qualname____doc__r	   r   r"   r   r   r
   r   r1    r   r   r   r      sW    x1 T " "*!5 "/# /%
C2H /r   r   c                   d     e Zd ZdZd
dee   deddf fdZedefd       Z	dedee
   fd	Z xZS )FilesystemLoaderz
    Loads Python files from the filesystem (e.g. ``tasks.py``.)

    Searches recursively towards filesystem root from a given start point.

    .. versionadded:: 1.0
    Nstartkwargsr   c                 v    t        |   di | | | j                  j                  j                  }|| _        y )Nr7   )superr   r   r   search_root_start)r   r:   r;   	__class__s      r   r   zFilesystemLoader.__init__p   s4    "6"=KK%%11Er   c                 F    | j                   xs t        j                         S r2   )r?   osgetcwd)r   s    r   r:   zFilesystemLoader.startv   s     {{)biik)r   r   c                    t        dj                  | j                               d }dj                  |      }| j                  j                  t        j
                        }	 t        t        t        |      dz               D ]  }t        j
                  j                  |d|       }|t	        j                  |      v r,t        |t        j                  j                  ||            } n|t	        j                  |      v st        j                  j                  t        j                  j                  ||d            st        j                  j                  ||      }t        |t        j                  j                  |d      |g      } n |rt        dj                  |             |S 	 y # t        t        f$ r4 d}t        |j                  |             t!        || j                  	      w xY w)
Nz&FilesystemLoader find starting at {!r}z{}.pyr   r   z__init__.py)submodule_search_locationszFound module: {!r}z4ImportError loading {!r}, raising CollectionNotFound)r   r:   )r   r(   r:   splitrB   sepreversedrangelenjoinlistdirr   r$   existsFileNotFoundErrorModuleNotFoundErrorr   )	r   r   r*   r/   pathsxr$   basepathr0   s	            r   r   zFilesystemLoader.find{   s   6==djjIJ%

  (	BeCJN34 vv{{51:.RZZ--2bggll48D RZZ--"''..GGLLt];3  "ww||D$7H2X}=4<:D
 !" *11$78  	 "#67 	BHC#**T"#$$djjAA	Bs   "B F2 >F2 A-F2 2AG5r2   )r3   r4   r5   r6   r	   r"   r   r   propertyr:   r   r   __classcell__)r@   s   @r   r9   r9   c   sY    hsm c d  *s * * *!5 r   r9   )rB   r#   importlib.machineryr   importlib.utilr   r   pathlibr   typesr   typingr   r	   r
    r   
exceptionsr   utilr   r   r9   r7   r   r   <module>r]      s?    	 
 * D   ' '  * R Rj7v 7r   