ó
ČMc           @   s  d  d l  Td  d l Z d e f d     YZ d e f d     YZ d e f d     YZ d	 e f d
     YZ d e d  e d e d  f d e d  e d e d  f d e d  e d e d  f d e d  e
 e e d  f d e d  e
 e e d  f d e d  e
 e e d  f g Z i d e d  e d  e d!  f g d" 6Z d#   Z d$   Z d%   Z d&   Z d'   Z d(   Z d)   Z d S(*   i˙˙˙˙(   t   *Nt   Channelc           B   st   e  Z d e e d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d   Z d	   Z d
   Z RS(   c         C   s=   | |  _  | |  _ | |  _ | |  _ | |  _ t   |  _ d  S(   N(   t   _typet   _aliast   _namet   _manualupdatet
   _removablet   objectt   _digest(   t   selft   typet   aliast   namet   manualupdatet	   removable(    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt   __init__   s    					c         C   s   |  j  S(   N(   R   (   R	   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt   getType$   s    c         C   s   |  j  S(   N(   R   (   R	   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt   getAlias'   s    c         C   s   |  j  S(   N(   R   (   R	   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt   getName*   s    c         C   s   |  j  p |  j S(   N(   R   R   (   R	   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt   hasManualUpdate-   s    c         C   s   |  j  S(   N(   R   (   R	   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt   isRemovable0   s    c         C   s   d S(   Ni    (    (   R	   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt   getFetchSteps3   s    c         C   s   |  j  S(   sš   
        Having the same channel digest means that information in
        the channel haven't changed at all, thus reprocessing
        information contained in it is optional.
        (   R   (   R	   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt	   getDigest6   s    c         C   s   g  S(   są   
        URLs returned by this method are used to check if a
        repository is currently available by comparing fetched
        information with cached information.
        (    (   R	   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt   getCacheCompareURLs>   s    c         C   s   t  S(   sţ   
        Fetch metafiles and set loader. This method implements a
        scheme that allows one to use a single logic to fetch remote
        files and also to load local cached information, depending
        on the caching mode of the fetcher.
        (   t   True(   R	   t   fetchert   progress(    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt   fetchF   s    c         C   s   |  j  p |  j S(   N(   R   R   (   R	   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt   __str__O   s    N(   t   __name__t
   __module__t   Nonet   FalseR   R   R   R   R   R   R   R   R   R   R   (    (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyR      s   										t   PackageChannelc           B   sA   e  Z d e e d  d  Z d   Z d   Z d   Z d   Z RS(   i    c         C   s8   t  t |   j | | | | |  g  |  _ | |  _ d  S(   N(   t   superR!   R   t   _loaderst	   _priority(   R	   R
   R   R   R   R   t   priority(    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyR   T   s    
	c         C   s   |  j  S(   N(   R#   (   R	   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt
   getLoaders[   s    c         C   s%   x |  j  D] } | j |  q
 Wd  S(   N(   R#   t	   addLoader(   R	   t   cachet   loader(    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt
   addLoaders^   s    c         C   sS   x9 |  j  D]. } | j   } | d  k	 r
 | j |  q
 q
 W|  j  2t   |  _ d  S(   N(   R#   t   getCacheR   t   removeLoaderR   R   (   R	   R)   R(   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt   removeLoadersb   s    c         C   s   |  j  S(   N(   R$   (   R	   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt   getPriorityj   s    N(	   R   R   R   R    R   R&   R*   R-   R.   (    (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyR!   S   s   			t   FileChannelc           B   s    e  Z d d  d  Z d   Z RS(   i    c         C   s   t  j j |  |  _ } | d  k r: t  j j |  } n  t  j j |  sb t t d  |  n  t	 t
 |   j d | | d t d | d  S(   Ns   File not found: %st   fileR   R%   (   t   ost   patht   abspatht	   _filenameR   t   basenamet   isfilet   Errort   _R"   R/   R   R   (   R	   t   filenameR   R%   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyR   n   s    c         C   s   |  j  S(   N(   R4   (   R	   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt   getFileNamew   s    N(   R   R   R   R   R:   (    (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyR/   m   s   	t   MirrorsChannelc           B   s#   e  Z d e e d   Z d   Z RS(   c         C   s/   t  t |   j | | | | |  i  |  _ d  S(   N(   R"   R;   R   t   _mirrors(   R	   R
   R   R   R   R   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyR   {   s    
c         C   s   |  j  S(   N(   R<   (   R	   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt
   getMirrors   s    N(   R   R   R   R    R   R=   (    (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyR;   z   s   R   t   Aliass&   Unique identification for the channel.R
   t   Types   Channel typeR   t   Namet    s   Channel namet   manuals   Manual updatessV   If set to a true value, the given channel will only be updated when manually selected.t   disabledt   Disableds8   If set to a true value, the given channel won't be used.R   t	   Removablesr   If set to a true value, the given channel will be considered as being available in a removable media (cdrom, etc).R%   t   Priorityi    s˛   Default priority assigned to all packages available in this channel (0 if not set). If the exact same package is available in more than one channel, the highest priority is used.t   packagec         C   sL  t  |  } | j d d  j d d  j   } y2 t d |  } t | d  } t | |  } Wnh t t f k
 rĚ d d l m	 } t
 j d	  | k rś d d  l } | j   n  t t d
  |  n X| j   } t | j d   } xK | j D]@ \ }	 }
 } } } |	 d k rqř n  |	 | k rř | | |	 <qř qř W| j |  |  S(   NR
   RA   t   -R8   s   smart.channels.t   channelsi˙˙˙˙(   t   DEBUGs	   log-levels%   Unable to create channel of type '%s'R   (   t   parseChannelDatat   gett   replacet   lowert
   __import__t   getattrt   ImportErrort   AttributeErrort   smart.constRJ   t   sysconft	   tracebackt	   print_excR7   R8   t   copyt   getChannelInfot   fieldst   create(   R   t   dataR
   t   smartRI   t   channelRJ   RU   t   infot   keyt   labelt   ftypet   defaultt   descr(    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt   createChannel   s(    $c         C   sq  | j  d  } | s' t t d   n  t |  } | sO t t d  |  n  d |  g } x| j D]ú \ } } } } }	 | d k r qf n  | j  |  }
 t |
  t k r˝ |
 j   }
 n  |
 sĐ |
 | k r| d  k rf t t d  | | | f  qf qf n  t |
  t	 k r(|
 rd p"d }
 n! t |
  t k	 rIt |
  }
 n  | j
 d	 | |
 f  qf Wd
 j |  S(   NR
   s   Channel has no types   Unknown channel type: %ss   [%s]R   s+   %s (%s) is a needed field for '%s' channelst   yest   nos   %s = %ss   
(   RL   R7   R8   RX   RY   R
   t   strt   stripR   t   boolt   appendt   join(   R   R[   t   ctypeR^   t   linesR_   R`   Ra   Rb   Rc   t   value(    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt   createChannelDescriptionł   s0    c   
      C   s  |  j  d  } | s' t t d   n  t |  } | sO t t d  |  n  t | d  rp | j |   }  n  i  } x÷| j D]ě\ } } } } } | d k r§ q n  |  j  |  }	 t |	  t k r× |	 j	   }	 n  |	 sę |	 | k r| d  k r t t d  | | | f  q q n  t |	  t k r0| t k rÝ|	 j   }	 |	 d d d	 d
 t d  t d  t d	  f k rt }	 q-|	 d d d d t d  t d  t d  f k r˝t }	 q-t t d  | | |	 f  qb| t k	 rby | |	  }	 Wq-t k
 r)t t d  | | |	 f  q-Xqbn2 t |	  | k	 rbt t d  | | |	 f  n  |	 | | <q Wt | d  r| j |  } n  | S(   NR
   s   Channel has no types   Unknown channel type: %st   preParseR   s+   %s (%s) is a needed field for '%s' channelst   yRe   t   truet   1t   nRf   t   falset   0s%   Invalid value for '%s' (%s) field: %st	   postParse(   RL   R7   R8   RX   t   hasattrRp   RY   R
   Rg   Rh   R   Ri   RN   R   R    t
   ValueErrorRw   (
   R[   Rl   R^   t   newdataR_   R`   Ra   Rb   Rc   Rn   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyRK   Í   sX    $	$	c         C   sJ  i  } d  } d  } x|  j   D]ţ } | j   } | s= q n  t |  d k r˝ | d d k r˝ | d d k r˝ | r d | k r t t d  |  n  | d d !j   } i  } | | | <q | d  k	 r | d d	 k r d
 | k r | j d
 d  \ } } | j   | | j   j   <q q Wx" | D] } t | |  | | <q(W| S(   Ni   i    t   [i˙˙˙˙t   ]R
   s   Channel '%s' has no typei   t   #t   =(	   R   t
   splitlinesRh   t   lenR7   R8   t   splitRN   RK   (   R[   RI   t   currentR   t   lineR_   Rn   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt   parseChannelsDescriptionü   s&    2)#c         C   s2  yN |  j  d d  j   d } t d |  } t | d  } t | |  } Wnh t t f k
 r¸ d d l m } t j	 d  | k r˘ d d  l
 } | j   n  t t d	  |   n Xt | d
  s.t | _ g  } | j t  | j t j	 | j g    t | d  r"| j | j  n  | | _ n  | S(   NRH   R8   t   _infos   smart.channels.RI   i˙˙˙˙(   RJ   s	   log-levels   Invalid channel type '%s't   _fixedRY   (   RM   RN   RO   RP   RQ   RR   RS   RJ   RT   RL   RU   RV   R7   R8   Rx   R   R   t   extendt   DEFAULTFIELDSt
   KINDFIELDSt   kindRY   (   R
   t   infonameR\   RI   R^   RJ   RU   RY   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyRX     s(    	c          C   s´   d d l  m }  t j t j j |  j   } i  } t j d t	  } xg | D]_ } | j
 d  rM | d  j d d  } | t	 k s | t |  k rŹ t |  | | <qŹ qM qM W| S(   Ni˙˙˙˙(   RI   s   display-channelss   _info.pyiř˙˙˙R8   RH   (   R\   RI   R1   t   listdirR2   t   dirnamet   __file__RT   RL   R   t   endswithRM   Rg   RX   (   RI   t	   filenamest   infost   display_channelsR9   R
   (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt   getAllChannelInfos'  s    c         C   s   d d l  m } |   } t   } g  } t j d d  } |  d f g } xĐ| r| j d  \ } } | j | d t }	 |	 r |	 j   n  t	 j
 j |  s§ qL n  t	 j
 j | d  }
 t	 j
 j |
  r.t |
  } t | j    } | j   x/ | D]' } | | } | | d <| j |  qý WqL n  x} | D]u } | | } t | d	  r5xS | j | |	  D]< } | | d
 <|	 r|	 j   rt | d <n  | j |  qgWq5q5W| | k  rL x[ t	 j |  D]G } t	 j
 j | |  } t	 j
 j |  rĘ| j | | d f  qĘqĘWqL qL W| S(   Ni˙˙˙˙(   t   MediaSets   detectlocalchannels-maxdepthi   i    t   subpaths	   .channelsR   t   detectLocalChannelsR
   R   i   (   t   smart.mediaR   R   RT   RL   t   popt   findMountPointR   t   mountR1   R2   t   isdirRk   R6   t   openR   t   readt   closeRj   Rx   R   R   R   (   R2   R   t   mediasetR   RI   t   maxdeptht   rootst   roott   deptht   mediat   channelsfileR0   t   descriptionsR   R]   R
   R^   t   entryt	   entrypath(    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyR   3  sJ    			




%(   R\   R1   R   R   R!   R/   R;   R8   Rg   R   Ri   R    R   t   intR   Rd   Ro   RK   R   RX   R   R   (    (    (    s1   /usr/lib/python2.7/dist-packages/smart/channel.pyt   <module>   s6   
9			/			