ó
È”Mc           @   s]   d  d l  m Z d  d l Td  d l Z e d ƒ Z e d ƒ Z d „  Z d „  Z d „  Z	 d S(	   iÿÿÿÿ(   t   OptionParser(   t   *Ns   smart clean [options]sŽ   
This command cleans the package cache. You can use it to
delete old unused files that were left behind because of
an incomplete transaction.
c          C   s8   t  d t d t ƒ }  |  j d d d d t d ƒ ƒ|  S(   Nt   usaget   descriptions   --autot   actiont
   store_truet   helps%   remove packages not in other channels(   R    t   USAGEt   DESCRIPTIONt
   add_optiont   _(   t   parser(    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/clean.pyt   option_parser#   s
    	c         C   s+   t  ƒ  } | j |  ƒ \ } } | | _ | S(   N(   R   t
   parse_argst   args(   t   argvR   t   optsR   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/clean.pyt   parse_options*   s    		c         C   sÃ  t  j j t j d ƒ d ƒ } t  j j | ƒ sF t t d ƒ | ‚ n  t j	 t d ƒ ƒ | j
 rú i  } |  j ƒ  |  j ƒ  } xy | j ƒ  D]h } x_ | j D]T } | j ƒ  r³ q› n  | j | ƒ } x* | j ƒ  D] } | | t  j j | ƒ <qÏ Wq› Wq‹ Wn  xÂ t  j | ƒ D]± \ }	 }
 } xŸ | D]— } | j
 rD| | k rDq qDn  y7 t  j t  j j |	 | ƒ ƒ t j t d ƒ | ƒ Wq t  j k
 r¶} t j t d ƒ | t | ƒ f ƒ q Xq Wq
Wd  S(   Ns   data-dirs	   packages/s   Directory not found: %ss    Removing cached package files...s
   Removed %ss"   Can't remove cached package %s: %s(   t   ost   patht   joint   sysconft   gett   isdirt   ErrorR
   t   ifacet   infot   autot   reloadChannelst   getCachet   getPackagest   loaderst   getInstalledt   getInfot   getURLst   basenamet   walkt   unlinkt   debugt   errort   str(   t   ctrlR   t   packagesdirt	   availablet   cachet   pkgt   loaderR   t   urlt   roott   dirst   filest
   cached_pkgt   e(    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/clean.pyt   main0   s4    	
%		(
   t   smart.optionR    t   smartR   R
   R   R   R   R   R5   (    (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/clean.pyt   <module>   s   
			