o
    èyAf¦  ã                   @  s@   d dl mZ d dlmZ d dlmZmZ ddd„Zdd
d„ZdS )é    )Úannotations)Úcast)Ú
EXCEPTIONSÚLICENSESÚreturnú dict[str, dict[str, str | bool]]c                  C  s8   t  ¡ } d}|ddœ| | ¡ < d}|ddœ| | ¡ < | S )NzLicenseRef-Public-DomainF)ÚidÚ
deprecatedzLicenseRef-Proprietary)r   ÚcopyÚlower)Úvalid_licensesZpublic_licenseZproprietary_license© r   ú=/usr/lib/python3.10/site-packages/hatchling/licenses/parse.pyÚget_valid_licenses   s   r   Úraw_license_expressionÚstrc                 C  sÈ  | s| S t ƒ }|  ¡ }| dd¡ dd¡}| ¡ }g }|D ]0}|dvr)| d¡ q|dkr3| d¡ q|dkrH|rH|d	 d
vrHd| › }t|ƒ‚| |¡ qd |¡}zt|ƒ}W n tyd   d}Y nw |dursd| › }t|ƒd ‚g }	|D ]]}|dv r…|	 | 	¡ ¡ qw|	r§|	d	 dkr§|t
vršd|› }t|ƒ‚|	 ttt
| d ƒ¡ qw| d¡rµ|d d	… }
d}n|}
d}|
|vrÆd|
› }t|ƒ‚|	 tt||
 d ƒ| ¡ qwd |	¡}| dd¡ dd¡S )Nú(z ( ú)z ) >   r   ÚorÚwithÚandr   ÚFalser   r   éÿÿÿÿ>   r   r   zinvalid license expression: ú TFZWITHzunknown license exception: r   ú+Ú zunknown license: z( z ))r   r   ÚreplaceÚsplitÚappendÚ
ValueErrorÚjoinÚevalÚ	ExceptionÚupperr   r   r   Úendswith)r   r   Zlicense_expressionÚtokensZpython_tokensÚtokenÚmessageZpython_expressionÚresultZnormalized_tokensZfinal_tokenÚsuffixZnormalized_expressionr   r   r   Únormalize_license_expression   s\   

ÿ





r*   N)r   r   )r   r   r   r   )	Ú
__future__r   Útypingr   Zhatchling.licenses.supportedr   r   r   r*   r   r   r   r   Ú<module>   s
    
