3
Q'íct ã @ s` d dl mZ d dlmZ d dlmZ d dlZd dlZd dlm Z d dl
mZ G dd deZdS ) é )Úconvert_path)Úlog)ÚDistutilsOptionErrorN)Úsix)ÚCommandc @ s: e Zd ZdZdZdddgZg Zdd
Zdd Zdd Z dS )ÚrotatezDelete older distributionsz2delete older distributions, keeping N newest filesúmatch=Úmúpatterns to match (required)ú dist-dir=Údú%directory where the distributions areúkeep=Úkú(number of matching distributions to keepc C s d | _ d | _d | _d S )N)ÚmatchÚdist_dirÚkeep)Úself© r ú?/tmp/pip-build-l_bcah40/setuptools/setuptools/command/rotate.pyÚinitialize_options s zrotate.initialize_optionsc C s | j d krtd| jd kr$tdyt| j| _W n tk
rP tdY nX t| j tjrxdd | j jdD | _ | j dd 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 |j qS r )r Ústrip)Ú.0Úpr r r ú
<listcomp>+ s z+rotate.finalize_options.<locals>.<listcomp>ú,Úbdistr )r r )
r r r ÚintÚ
ValueErrorÚ
isinstancer Ústring_typesÚsplitÚset_undefined_options)r r r r Úfinalize_options s
zrotate.finalize_optionsc C sÔ | j d ddlm} x¸| jD ]®}| jj d | }|tjj| j|}dd |D }|j |j
tjdt
|| || jd
}xD|D ]<\}}tjd| | jstjj|r¾tj| qtj| qW qW d S ) NÚegg_infor )ÚglobÚ*c S s g | ]}t jj||fqS r )ÚosÚpathÚgetmtime)r Úfr r r r 6 s zrotate.run.<locals>.<listcomp>z%d file(s) matching %szDeleting %s)Úrun_commandr&