ó
.¿”Wc           @   s‚   d  d l  m Z d  d l m Z d  d l m Z d  d l Z d  d l Z d  d l m	 Z	 d  d l
 m Z d e f d „  ƒ  YZ d S(	   iÿÿÿÿ(   t   convert_path(   t   log(   t   DistutilsOptionErrorN(   t   six(   t   Commandt   rotatec           B   sD   e  Z d  Z d Z d d d g Z g  Z d „  Z d „  Z d „  Z RS(   s   Delete older distributionss2   delete older distributions, keeping N newest filess   match=t   ms   patterns to match (required)s	   dist-dir=t   ds%   directory where the distributions ares   keep=t   ks(   number of matching distributions to keepc         C   s   d  |  _ d  |  _ d  |  _ d  S(   N(   t   Nonet   matcht   dist_dirt   keep(   t   self(    (    s=   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/rotate.pyt   initialize_options   s    		c         C   sÒ   |  j  d  k r t d ƒ ‚ n  |  j d  k r< t d ƒ ‚ n  y t |  j ƒ |  _ Wn t k
 rq t d ƒ ‚ n Xt |  j  t j ƒ r¾ g  |  j  j	 d ƒ D] } t
 | j ƒ  ƒ ^ qš |  _  n  |  j d d ƒ d  S(   NsQ   Must specify one or more (comma-separated) match patterns (e.g. '.zip' or '.egg')s$   Must specify number of files to keeps   --keep must be an integert   ,t   bdistR   (   s   dist_dirs   dist_dir(   R
   R	   R   R   t   intt
   ValueErrort
   isinstanceR   t   string_typest   splitR    t   stript   set_undefined_options(   R   t   p(    (    s=   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/rotate.pyt   finalize_options   s    7c         C   s1  |  j  d ƒ d d l m } x|  j D]} |  j j ƒ  d | } | t j j |  j | ƒ ƒ } g  | D] } t j j	 | ƒ | f ^ qi } | j
 ƒ  | j ƒ  t j d t | ƒ | ƒ | |  j } x_ | D]W \ } } t j d | ƒ |  j sÎ t j j | ƒ rt j | ƒ q%t j | ƒ qÎ qÎ Wq' Wd  S(   Nt   egg_infoiÿÿÿÿ(   t   globt   *s   %d file(s) matching %ss   Deleting %s(   t   run_commandR   R
   t   distributiont   get_namet   ost   patht   joinR   t   getmtimet   sortt   reverseR   t   infot   lenR   t   dry_runt   isdirt   shutilt   rmtreet   unlink(   R   R   t   patternt   filest   ft   t(    (    s=   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/rotate.pyt   run/   s     +

	(   s   match=R   s   patterns to match (required)(   s	   dist-dir=R   s%   directory where the distributions are(   s   keep=R   s(   number of matching distributions to keep(	   t   __name__t
   __module__t   __doc__t   descriptiont   user_optionst   boolean_optionsR   R   R1   (    (    (    s=   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/rotate.pyR      s   			(   t   distutils.utilR    t	   distutilsR   t   distutils.errorsR   R    R*   t   setuptools.externR   t
   setuptoolsR   R   (    (    (    s=   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/rotate.pyt   <module>   s   