
    7f`                    n    d dl mZ d dlmZ d dlmZ d dlmZ d dlZd dl	Z	d dl
mZ  G d de          ZdS )	    )annotations)convert_path)log)DistutilsOptionErrorN)Commandc                  @    e Zd ZU dZdZg dZg Zded<   d Zd Z	d Z
d	S )
rotatezDelete older distributionsz2delete older distributions, keeping N newest files))zmatch=mzpatterns to match (required))z	dist-dir=dz%directory where the distributions are)zkeep=kz(number of matching distributions to keepz	list[str]boolean_optionsc                0    d | _         d | _        d | _        d S )N)matchdist_dirkeep)selfs    W/home/feoh/.local/pipx/shared/lib/python3.11/site-packages/setuptools/command/rotate.pyinitialize_optionszrotate.initialize_options   s    
			    c                   | j         t          d          | j        t          d          	 t          | j                  | _        n"# t          $ r}t          d          |d }~ww xY wt          | j         t                    r)d | j                             d          D             | _         |                     dd           d S )NzQMust specify one or more (comma-separated) match patterns (e.g. '.zip' or '.egg')z$Must specify number of files to keepz--keep must be an integerc                P    g | ]#}t          |                                          $S  )r   strip).0ps     r   
<listcomp>z+rotate.finalize_options.<locals>.<listcomp>*   s(    QQQa,qwwyy11QQQr   ,bdist)r   r   )	r   r   r   int
ValueError
isinstancestrsplitset_undefined_options)r   es     r   finalize_optionszrotate.finalize_options   s    :&*   9&'MNNN	KDIDII 	K 	K 	K&'BCCJ	Kdj#&& 	RQQ4:;K;KC;P;PQQQDJ""7,DEEEEEs   A 
A'A""A'c                   |                      d           ddlm} | j        D ]"}| j                                        dz   |z   } |t
          j                            | j        |                    }d |D             }|	                                 |
                                 t          j        dt          |          |           || j        d          }|D ]i\  }}t          j        d|           | j        sHt
          j                            |          rt#          j        |           Ut          j        |           j$d S )Negg_infor   )glob*c                P    g | ]#}t           j                            |          |f$S r   )ospathgetmtime)r   fs     r   r   zrotate.run.<locals>.<listcomp>4   s-    ===!bg&&q))1-===r   z%d file(s) matching %szDeleting %s)run_commandr)   r   distributionget_namer,   r-   joinr   sortreverser   infolenr   dry_runisdirshutilrmtreeunlink)r   r)   patternfilestr/   s         r   runz
rotate.run-   sE   $$$z 	% 	%G'0022S87BGDdmW==>>E==u===EJJLLLMMOOOH-s5zz7CCC$)++&E % %1***| %w}}Q'' %a((((	!%	% 	%r   N)__name__
__module____qualname____doc__descriptionuser_optionsr   __annotations__r   r&   r@   r   r   r   r	   r	      su         $$FK  L "$O####  
F F F % % % % %r   r	   )
__future__r   distutils.utilr   	distutilsr   distutils.errorsr   r,   r:   
setuptoolsr   r	   r   r   r   <module>rM      s    " " " " " " ' ' ' ' ' '       1 1 1 1 1 1 				       4% 4% 4% 4% 4%W 4% 4% 4% 4% 4%r   