o
    >i                     @  sh   d dl mZ d dlZd dlmZ ddlmZmZ d dlm	Z	 d dl
mZ d dlmZ G d	d
 d
eZdS )    )annotationsN)ClassVar   )Command_shutil)log)DistutilsOptionError)convert_pathc                   @  sF   e Zd ZU dZdZg dZg Zded< dd Zdd
dZ	dd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ClassVar[list[str]]boolean_optionsc                 C  s   d | _ d | _d | _d S )N)matchdist_dirkeep)self r   h/var/www/html/eduruby.in/lip-sync/lip-sync-env/lib/python3.10/site-packages/setuptools/command/rotate.pyinitialize_options   s   
zrotate.initialize_optionsreturnNonec              
   C  s   | j d u r	td| jd u rtdzt| j| _W n ty+ } ztd|d }~ww t| j tr>d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                 S  s   g | ]}t | qS r   )r	   strip).0pr   r   r   
<listcomp>+   s    z+rotate.finalize_options.<locals>.<listcomp>,Zbdist)r   r   )	r   r   r   int
ValueError
isinstancestrsplitZset_undefined_options)r   er   r   r   finalize_options   s   


zrotate.finalize_optionsc                 C  s   |  d ddlm} | jD ]U}| j d | }|tj| j|}dd |D }|	  |
  tdt|| || jd  }|D ]\}}td| | jsbtj|r]t| qDt| qDqd S )	Negg_infor   )glob*c                 S  s   g | ]
}t j||fqS r   )ospathgetmtime)r   fr   r   r   r   5   s    zrotate.run.<locals>.<listcomp>z%d file(s) matching %szDeleting %s)run_commandr%   r   distributionget_namer'   r(   joinr   sortreverser   infolenr   dry_runisdirr   rmtreeunlink)r   r%   patternfilestr*   r   r   r   run.   s&   


z
rotate.runN)r   r   )__name__
__module____qualname____doc__descriptionZuser_optionsr   __annotations__r   r#   r:   r   r   r   r   r
      s   
 
r
   )
__future__r   r'   typingr    r   r   	distutilsr   Zdistutils.errorsr   Zdistutils.utilr	   r
   r   r   r   r   <module>   s    