
    ffh                       d Z ddlmZ ddlZddlZ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 dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ej:                  j=                  d      Z ej>                  d      Z 	 dZ!dZ"ddZ# G d de      Z$ddZ%ejL                   G d d             Z'y)configuration    )annotationsN)Path)Any)Pattern)Protocol   )_log)_types)get_args_for_pyproject)read_pyproject)read_toml_overrides)Version)_validate_version_cls)	_VersionTconfigz@^(?:[\w-]+-)?(?P<version>[vV]?\d+(?:\.\d+){0,2}[^\+]*)(?:\+.*)?$zguess-next-devznode-and-datec                    | st         }nt        j                  |       }|j                  j	                         }|j
                  dk(  s|j
                  dkD  rd|vrt        j                  d       |S )Nr   r	   versionzvExpected tag_regex to contain a single match group or a group named 'version' to identify the version part of any tag.)DEFAULT_TAG_REGEXrecompile
groupindexkeysgroupswarningswarn)valueregexgroup_namess      n/var/dept/share/cheung/public_html/OutSchool/python/env/lib/python3.12/site-packages/setuptools_scm/_config.py_check_tag_regexr!   &   sc    !

5!""'')K||qU\\A-);2NB	

 L    c                       e Zd Z	 	 	 	 	 	 ddZy)ParseFunctionc                    y N )selfrootr   s      r    __call__zParseFunction.__call__7   s    "r"   N)r)   _t.PathTr   Configurationreturnz_t.SCMVERSION | None)__name__
__module____qualname__r*   r'   r"   r    r$   r$   6   s    ##)6#	#r"   r$   c                   t         j                  d| |       |r@t        j                  j	                  |       r_t        j                  j	                  |      r@t        j                  j                  | |g      | k(  st        j                  d|  d| d       t        j                  j                  |      rPt        j                  d| d       t         j                  d|       t        j                  j                  ||       } nSt         j                  d|       t        j                  j                  t        j                  j                  |      |       } t        j                  j                  |       S )	Nz%check absolute root=%s relative_to=%szabsolute root path 'z' overrides relative_to ''z8relative_to is expected to be a file, its the directory z)
assuming the parent directory was passedzdir %szfile %s)logdebugospathisabs
commonpathr   r   isdirjoindirnameabspath)r)   relative_tos     r    _check_absolute_rootr>   <   s
   II5t[IGGMM$k*GG&&k':;tCMM&tf,Ek]RST 77==%MM&&1] 3;;
 IIh,77<<T2DIIi-77<< <dCD77??4  r"   c                  j   e Zd ZU dZdZded<   dZded<   eZded	<   e	Z
ded
<   eZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   dZded<   eZded<   dZded<   dZded<   ed#d        Ze	 	 	 d$	 	 	 	 	 	 	 	 	 d%d!       Ze	 	 	 	 	 	 d&d"       Zy)'r,   zGlobal configuration modelN_t.PathT | Noner=   .r+   r)   z_t.VERSION_SCHEMEversion_schemelocal_schemePattern[str]	tag_regex
str | Noneparentdir_prefix_versionfallback_versionfallback_rootwrite_towrite_to_templateversion_fileversion_file_templatezParseFunction | Noneparsez_t.CMD_TYPE | Nonegit_describe_command	dist_nameztype[_VersionT]version_clsFboolsearch_parent_directoriesparentc                B    t        | j                  | j                        S r&   )r>   r)   r=   )r(   s    r    absolute_rootzConfiguration.absolute_rootm   s    #DIIt/?/?@@r"   c                    t        t        |      |      }t        |||      }|j                  t	        |d                |j                  d|      }| j                  ||      S )z
        Read Configuration from pyproject.toml (or similar).
        Raises exceptions when file is not found or toml is
        not installed or the file has invalid format or does
        not contain the [tool.setuptools_scm] section.
        )require_sectionrP   r=   )r=   data)_read_pyprojectr   _get_args_for_pyprojectupdater   pop	from_data)clsnamerP   _require_sectionkwargspyproject_dataargsr=   s           r    	from_filezConfiguration.from_fileq   s]     )dEUV&~y&I'[(9:;hh}d3}}4}@@r"   c                    t        |j                  dd            }t        |j                  dd      |j                  dd            } | d|||d|S )zt
        given configuration data
        create a config instance after validating tag regex/version class
        rE   NrQ   	normalizeT)r=   rQ   rE   r'   )r!   r]   r   )r_   r=   rY   rE   rQ   s        r    r^   zConfiguration.from_data   se     %TXXk4%@A	+HH]D)488K+F
  
##
 	
 	
r"   )r-   str)zpyproject.tomlNT)
r`   str | os.PathLike[str]rP   rF   ra   rR   rb   r   r-   r,   )r=   ri   rY   zdict[str, Any]r-   r,   ) r.   r/   r0   __doc__r=   __annotations__r)   DEFAULT_VERSION_SCHEMErB   DEFAULT_LOCAL_SCHEMErC   r   rE   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   _VersionrQ   rS   rT   propertyrV   classmethodre   r^   r'   r"   r    r,   r,   U   sY   $#'K'D((>N%>&:L#:/I|/+/j/#'j'!M8! $Ho$$(z($(L/((,:,"&E&/3,3 Iz #+K+&+t+"FO"A A  (8 $!%	A$A A 	A
 A 
A A* 
0
8F
	
 
r"   r,   )r   zstr | Pattern[str] | Noner-   rD   )r)   r+   r=   r@   r-   rh   )(rj   
__future__r   dataclassesr5   r   r   pathlibr   typingr   r   r    r
   r   _t_integration.pyproject_readingr   r[   r   rZ   
_overridesr   _version_clsr   rn   r   r   r3   getChildr   r   rl   rm   r!   r$   r>   	dataclassr,   r'   r"   r    <module>r|      s     "  	 	        N + - / #
hh!BJJG * * &  #H #!2 B
 B
 B
r"   