î M“Reã@s|ddlZddlZddlmZddlmZddlmZddlmZddl TGdd„deƒZ dS) éN)ÚCommand)Ú basestring)Ú convert_path)Úlog)Ú*c@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ú4/tmp/pip-l4uy7dan-build/setuptools/command/rotate.pyÚinitialize_optionss  zrotate.initialize_optionsc Cs¾|jdkrtdƒ‚n|jdkr<tdƒ‚nyt|jƒ|_Wntk rrtdƒ‚YnXt|jtƒrªdd„|jjdƒDƒ|_n|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 integercSs"g|]}t|jƒƒ‘qSr)rÚstrip)Ú.0Úprrrú 's z+rotate.finalize_options..ú,Úbdistr)údist_dirr) rÚDistutilsOptionErrorrÚintÚ ValueErrorÚ isinstancerÚ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]5\}}t j d|ƒ|js¼tj|ƒq¼q¼Wq'WdS) NÚegg_infor)ÚglobrcSs(g|]}tjj|ƒ|f‘qSr)ÚosÚpathÚgetmtime)rÚfrrrr1s zrotate.run..z%d file(s) matching %sz Deleting %s)Ú run_commandr'rÚ distributionÚget_namer(r)ÚjoinrÚsortÚreverserÚinfoÚlenrÚdry_runÚunlink)rr'ÚpatternÚfilesÚtr+rrrÚrun+s    z rotate.runN)rr r )r r r )rrr) Ú__name__Ú __module__Ú __qualname__Ú__doc__Ú descriptionÚ user_optionsÚboolean_optionsrr%r9rrrrrs    r) Ú distutilsr(Ú setuptoolsrZsetuptools.compatrÚdistutils.utilrrÚdistutils.errorsrrrrrÚs