3 ­ž‘ePã@sTddlmZddlmZddlmZddlZddlZddlm Z Gdd„de ƒZ dS)é)Ú convert_path)Úlog)ÚDistutilsOptionErrorN)ÚCommandc@s:eZdZdZdZdddgZgZd 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-vlmub77e/setuptools/setuptools/command/rotate.pyÚinitialize_optionsszrotate.initialize_optionscCs–|jdkrtdƒ‚|jdkr$tdƒ‚yt|jƒ|_Wn,tk r`}ztdƒ|‚WYdd}~XnXt|jtƒr†dd„|jjdƒDƒ|_|jdd ƒ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 integercSsg|]}t|jƒƒ‘qSr)rÚstrip)Ú.0Úprrrú )sz+rotate.finalize_options..ú,Úbdistr)rr) rrrÚintÚ ValueErrorÚ isinstanceÚstrÚsplitÚset_undefined_options)rÚerrrÚfinalize_optionss   zrotate.finalize_optionscCsÔ|jdƒddlm}x¸|jD]®}|jjƒd|}|tjj|j|ƒƒ}dd„|Dƒ}|j ƒ|j ƒt j dt |ƒ|ƒ||jd…}xD|D]<\}}t j d|ƒ|jsŒtjj|ƒr¾tj|ƒqŒtj|ƒqŒWqWdS) NÚegg_infor)ÚglobÚ*cSsg|]}tjj|ƒ|f‘qSr)ÚosÚpathÚgetmtime)rÚfrrrr4szrotate.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 sr) Údistutils.utilrÚ distutilsrZdistutils.errorsrr(r6Ú setuptoolsrrrrrrÚs