
    -Ph	                    r    d Z ddlm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ZddZddZddZdS )z>
Responsible for getting the version and name from a project.
    )annotationsN)import_module)PackageNotFoundError)
ModuleTypepackage_dirstrpackagereturnr   c                   	 t          |          }n# t          $ r t          j                            d|            	 t          |          }n-# t          $ r }d| d| }t          d|             d }~ww xY w	 t          j                            d           n$# t          j                            d           w xY wY nw xY w|S )Nr   ztried to import z, but ran into this error: zERROR: )r   ImportErrorsyspathinsertprintpop)r   r	   moduleeerrs        R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/towncrier/_project.py_get_packager      s    w''    	;'''	"7++FF 	 	 	LWLLLLC/C//"""		  HLLOOOOCHLLOOOOOO MsD    *CAB
A7A22A77B; C!B<<CC
str | Nonec                    t          j        t                    5  t          j                            |           x}r|cddd           S 	 ddd           n# 1 swxY w Y   dS )z;
    Try to get the version from the package metadata.
    N)
contextlibsuppressr   	importlibmetadataversion)r	   r   s     r   _get_metadata_versionr   (   s     
	1	2	2  (009997 	       	               4s   #AAAc                v   t          |          x}r|S t          | |          }t          |dd          }|st          d| d          t	          |t
                    r|                                S t	          |t                    r:d                    t          t
          |                                                    S t          |d          rZ	 t          |                                                                          }|                    dd          S # t          $ r Y nw xY wt          d	          )
z
    Get the version of a package.

    Try to extract the version from the distribution version metadata that matches
    `package`, then fall back to looking for the package in `package_dir`.
    __version__Nz1No __version__ or metadata version info for the 'z
' package..basez.rcrczVersion must be a string, tuple, or an Incremental Version. If you can't provide that, use the --version argument and specify one.)r   r   getattr	Exception
isinstancer   striptuplejoinmaphasattrr"   replace	TypeError)r   r	   r   r   s       r   get_versionr.   3   sN    (000w  +w//FfmT22G 
SSSS
 
 	
 '3 }}'5!! 3xxC))**00222 w 	',,..))//11G ??5$/// 	 	 	D	 	R  s   AD 
D)(D)c                    t          | |          }t          |dd           }t          j        t                    5  t          |j                  cd d d            S # 1 swxY w Y   |                                S )Nr    )r   r$   r   r   AttributeErrorr   r	   title)r   r	   r   r   s       r   get_project_namer2   ^   s    +w//FfmT22G		^	,	, $ $7?##$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ ==??s   AA #A )r   r   r	   r   r
   r   )r	   r   r
   r   )r   r   r	   r   r
   r   )__doc__
__future__r   r   importlib.metadatar   r   r   r   typesr   r   r   r.   r2        r   <module>r9      s     # " " " " "         



 # # # # # # 3 3 3 3 3 3         *   ( ( ( (V     r8   