ôY]ã@s~ddlmZddlmZddlmZddlZddlZddlZddl m Z Gdd„de ƒZ dS)é)Ú convert_path)Úlog)ÚDistutilsOptionErrorN)ÚCommandc@sUeZdZdZdZdddgZgZd d „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 keepcCsd|_d|_d|_dS)N)ÚmatchÚdist_dirÚkeep)Úself©rú?/tmp/pip-build-3puug3g5/setuptools/setuptools/command/rotate.pyÚinitialize_optionss  zrotate.initialize_optionsc Cs¸|jdkrtdƒ‚|jdkr6tdƒ‚yt|jƒ|_Wntk rltdƒ‚YnXt|jtjƒr¤dd„|jjdƒDƒ|_|j dd ƒdS) 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 integercSs"g|]}t|jƒƒ‘qSr)rÚstrip)Ú.0Úprrrú +s z+rotate.finalize_options..ú,Úbdistr)údist_dirr) rrrÚintÚ ValueErrorÚ isinstanceÚsixÚ string_typesÚsplitÚset_undefined_options)rrrrÚfinalize_optionss   "zrotate.finalize_optionscCs|jdƒddlm}xø|jD]í}|jjƒd|}|tjj|j|ƒƒ}dd„|Dƒ}|j ƒ|j ƒt j dt |ƒ|ƒ||jd…}x\|D]T\}}t j d|ƒ|js¼tjj|ƒrtj|ƒq¼tj|ƒq¼Wq'WdS) NÚegg_infor)ÚglobÚ*cSs(g|]}tjj|ƒ|f‘qSr)ÚosÚpathÚgetmtime)rÚfrrrr6s zrotate.run..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)rr'ÚpatternÚfilesÚtr,rrrÚrun/s     z rotate.runN)rrr )r r r )r rr) Ú__name__Ú __module__Ú __qualname__Ú__doc__Ú descriptionÚ user_optionsÚboolean_optionsrr%r=rrrrr s    r) Údistutils.utilrÚ distutilsrÚdistutils.errorsrr)r7r!Ú setuptoolsrrrrrrÚs