
    E^e                         d Z ddlZddlZddlmZ ddlmZ ddlmZ  ej	        dej
                  Zd Zd Zd	 Zd
 Z	 	 ddZdS )z"Cookiecutter repository functions.    N)RepositoryNotFound)clone)unzipz
# something like git:// ssh:// file:// etc.
((((git|hg)\+)?(git|ssh|file|https?):(//)?)
 |                                      # or
 (\w+@[\w\.]+)                          # something like user@...
)
c                 P    t          t                              |                     S )z)Return True if value is a repository URL.)bool
REPO_REGEXmatchvalues    7lib/python3.11/site-packages/cookiecutter/repository.pyis_repo_urlr      s    
  ''(((    c                 P    |                                                      d          S )z#Return True if value is a zip file.z.zip)lowerendswithr
   s    r   is_zip_filer      s    ;;==!!&)))r   c                     | |v r||          S |                      d          \  }}}||v r||                             |          S | S )zExpand abbreviations in a template name.

    :param template: The project template name.
    :param abbreviations: Abbreviation definitions.
    :)	partitionformat)templateabbreviationsprefixseprests        r   expand_abbreviationsr      s_     =  X&& !**3//FCV$++D111Or   c                     t           j                            |           }t           j                            t           j                            | d                    }|o|S )zDetermine if `repo_directory` contains a `cookiecutter.json` file.

    :param repo_directory: The candidate repository directory.
    :return: True if the `repo_directory` is valid, else False.
    zcookiecutter.json)ospathisdirisfilejoin)repo_directoryrepo_directory_existsrepo_config_existss      r    repository_has_cookiecutter_jsonr&   1   sP     GMM.99
^%899  !7%77r   c                    t          | |          } t          |           r't          | t          |           |||          }|g}d}	nLt          |           rt	          | |||          }
|
g}d}	n$| t
          j                            ||           g}d}	rfd|D             }|D ]}t          |          r||	fc S t          d
                    | d                    |                              )aj  
    Locate the repository directory from a template reference.

    Applies repository abbreviations to the template reference.
    If the template refers to a repository URL, clone it.
    If the template is a path to a local repository, use it.

    :param template: A directory containing a project template directory,
        or a URL to a git repository.
    :param abbreviations: A dictionary of repository abbreviation
        definitions.
    :param clone_to_dir: The directory to clone the repository into.
    :param checkout: The branch, tag or commit ID to checkout after clone.
    :param no_input: Do not prompt for user input and eventually force a refresh of
        cached resources.
    :param password: The password to use when extracting the repository.
    :param directory: Directory within repo where cookiecutter.json lives.
    :return: A tuple containing the cookiecutter template directory, and
        a boolean describing whether that directory should be cleaned up
        after the template has been instantiated.
    :raises: `RepositoryNotFound` if a repository directory could not be found.
    )zip_uriis_urlclone_to_dirno_inputpasswordT)repo_urlcheckoutr*   r+   Fc                 P    g | ]"}t           j                            |          #S  )r   r   r"   ).0s	directorys     r   
<listcomp>z&determine_repo_dir.<locals>.<listcomp>x   s6     !
 !
 !
+,BGLLI&&!
 !
 !
r   zMA valid repository for "{}" could not be found in the following locations:
{}
)r   r   r   r   r   r   r   r"   r&   r   r   )r   r   r*   r.   r+   r,   r3   unzipped_dirrepository_candidatescleanupcloned_reporepo_candidates         `     r   determine_repo_dirr;   ?   s^   > $Hm<<H8 x((%
 
 
 ".	X		 %	
 
 
 "-!)27<<h+O+O P 
!
 !
 !
 !
0E!
 !
 !
 0 + ++N;; 	+!7****	+ 	$))4I*J*JKK  r   )NN)__doc__r   recookiecutter.exceptionsr   cookiecutter.vcsr   cookiecutter.zipfiler   compileVERBOSEr   r   r   r   r&   r;   r0   r   r   <module>rC      s    ( ( 				 				 6 6 6 6 6 6 " " " " " " & & & & & &RZ J	 	
) ) )
* * *
  $8 8 8( D D D D D Dr   