ó
È”Mc           @   sÌ   d  d l  m Z d  d l m Z d  d l m Z d  d l m Z d  d l m	 Z	 m
 Z
 m Z m Z d  d l m Z m Z d  d l Td  d l Z d  d l Z d  d l Z d	 e e f d
 „  ƒ  YZ d „  Z d S(   iÿÿÿÿ(   t   URPMISynthesisLoader(   t   RPMDescriptions(   t   URPMILoader(   t   getFileDigest(   t	   SUCCEEDEDt   FAILEDt   ALWAYSt   NEVER(   t   PackageChannelt   MirrorsChannel(   t   *Nt   URPMIChannelc           B   sM   e  Z i  Z d Z d Z d d d  „ Z d „  Z d „  Z d „  Z	 d „  Z
 RS(   c         G   sá   t  t |  ƒ j | Œ  | |  _ | |  _ | |  _ | rL | d | d 7} n  | r’ | d d k r† d | k r† t j | | ƒ |  _ qª | |  _ n t j |  j d ƒ |  _ t j	 |  j ƒ } t j | d ƒ |  _
 |  j |  _ d  S(   Nt   /i    s   :/s	   hdlist.czs   info.xml.lzma(   t   superR   t   __init__t   _baseurlt
   _directoryt
   _mirrorurlt	   posixpatht   joint   _hdlurlt   dirnamet   _infourlt   _compareurl(   t   selft   baseurlt   hdlurlt	   directoryt	   mirrorurlt   argst   hdldir(    (    s8   /usr/lib/python2.7/dist-packages/smart/channels/urpmi.pyR   )   s    			c         C   s
   |  j  g S(   N(   R   (   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/channels/urpmi.pyt   getCacheCompareURLs;   s    c         C   s   d S(   Ni   (    (   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/channels/urpmi.pyt   getFetchSteps>   s    c         C   s  d d l  m } | t j d ƒ t j d ƒ ƒ } g  } t | ƒ } x¸ | j ƒ  D]ª } i d  d 6d  d 6} x< | j d ƒ D]+ } | j d ƒ \ }	 }
 |
 j ƒ  | |	 <qz W| j	 t
 | d	 ƒ t
 | d
 ƒ d t d | d d | d ƒ| d <| j | ƒ qP W| j ƒ  | j d „  ƒ | S(   Niÿÿÿÿ(   t	   GeoLocatet   clocks   zone-tabt   countryt	   continentt   ,t   =t   latitudet	   longitudet	   randomizet	   proximityc         S   s   t  |  d | d ƒ S(   NR*   (   t   cmp(   t   xt   y(    (    s8   /usr/lib/python2.7/dist-packages/smart/channels/urpmi.pyt   <lambda>Q   s    (   t   smart.util.geolocateR!   t   sysconft   gett   opent	   readlinest   Nonet   splitt   stript   getProximityt   floatt   Truet   appendt   closet   sort(   R   t   pathR!   t   geoloct   mirrorst   fpt   linet   mirrort   itemt   keyt   entry(    (    s8   /usr/lib/python2.7/dist-packages/smart/channels/urpmi.pyt   loadMirrorsA   s"    !
c   0   	   C   s	  | j  ƒ  |  j rD|  j } | j | ƒ } | j d | ƒ | j ƒ  t k r | j |  j ƒ  d ƒ | j ƒ  t	 k r7t
 j t d ƒ ƒ q7n¨ |  j j ƒ  g  } |  j | j ƒ  ƒ } xd | D]\ } | d j d ƒ d } | j | d  ƒ só q¾ n  | d d k r	q¾ n  | j | d ƒ q¾ W| r7| |  j |  j <n  | j  ƒ  n | j d ƒ |  j |  _ t j j |  j ƒ \ }	 }
 t j j |  j ƒ d } t j |	 d	 ƒ } | j | ƒ } | j d | ƒ d  } d  } | j ƒ  } | sÈ| |  _ t | j ƒ  ƒ } | |  j k r| j d
 ƒ t  St j! |  j ƒ }
 t j! |  j ƒ } yr xk t" | j ƒ  ƒ D]W } | j# ƒ  } | rU| j ƒ  \ } } | |
 k r”| } n  | | k r¬| } q¬qUqUWWqÈt$ k
 rÄqÈXn  | j  ƒ  | j |  j d | d t  ƒ} | r| j |  j d | d t  ƒ} n | j d ƒ d  } |  j% ƒ  j& d ƒ d k r[| j d ƒ d  } n! t j |	 d ƒ } | j | ƒ } | j d | ƒ | j ƒ  t k rš| j ƒ  } | j ƒ  t	 k r–| j  ƒ  t j |	 d ƒ } | j | ƒ } | j d | ƒ | j ƒ  t k ry| j ƒ  } | j ƒ  t	 k rut d ƒ |  d | j' ƒ  | f d | j' ƒ  | f g } t( d j | ƒ ‚ n  t) S|	 j* d ƒ s•|	 d 7}	 n  xë t" | j ƒ  ƒ D]× } | j+ d ƒ rÀq¨| r¨| j ƒ  } t j, ƒ  d } | d k r÷d } n  t- j. d | | d ƒ } t- j. | d d | |	 ƒ }  t/ j0 d |  j1 ƒ  d f |  ƒ t j j |  |
 ƒ |  _ t j j |  | ƒ |  _ q¨q¨W|  j2 | | ƒ Sn  t) S| j ƒ  }! d  }" d  }# d  }$ |  j |  j k rÓ|! }" n  |" rût |" ƒ } | |  j k rût  Sn  |  j3 ƒ  |! j* d ƒ rŸt j j4 |! d  ƒ s=| j ƒ  t5 k r’| j6 | ƒ }% |% d  d  }% t j7 t j j8 |% ƒ t j9 ƒ såt j j t/ j: d! ƒ d ƒ }& t j j! |% ƒ }
 t j j; |& ƒ sÍt j< |& ƒ n  t j j |& |
 ƒ }% n  t j j4 |% ƒ rt j= |% ƒ n  t j> |! |% ƒ |% }! | j? ƒ  }' |' j |% ƒ }( y |( j@ |% ƒ Wn6 t( k
 r}) d" |) d k r‚t j= |% ƒ ‚  q‚n Xt j= |% ƒ n  |! d  }! n  | rÆ| j ƒ  tA k rÆ| j ƒ  }# nY | r| j ƒ  t k rt d ƒ |  d | j' ƒ  | j ƒ  f g } tB d j | ƒ ‚ n  i  }* | rn| j ƒ  tA k rn| j ƒ  }+ tC |+ ƒ }, |, jD ƒ  |, jE ƒ  }* n  |  j }- |  jF }. |. r›|- d |. d 7}- n  t" |! ƒ jG d ƒ d# k rËtH |! |- |$ ƒ }/ n tI |! |- |$ |# ƒ }/ |/ jJ |* ƒ |/ jK |  ƒ |  jL j |/ ƒ | |  _ t  S($   Nt   progressi   s:   Could not load mirror list. Continuing with base URL only.t   urlt   :i    t   typet   distribt   MD5SUMi   t   md5t   uncompt   Updatesiÿÿÿÿt   descriptionss   reconfig.urpmis&   Failed acquiring information for '%s':u   %s: %ss   
R   t   #i   t   i686t   i586s   \$ARCHt   $t   channelsR   s   .cziýÿÿÿiþÿÿÿt   gzs   user-data-dirs   Not a gzipped files   Ž­è(M   t   resetR   t   enqueuet   runt	   getStatusR   t   addR    t
   getCachingR   t   ifacet   warningt   _t   _mirrorst   clearRF   t   getTargetPathR5   t
   getHandlerR4   R:   R   R   R   t   osR=   R   R   R   t   getFailedReasonR   t   _digestR9   t   basenameR2   R6   t
   ValueErrort   getNamet   findt   getURLt   Errort   Falset   endswitht
   startswitht   unamet   ret   subR0   t   sett   getAliast   fetcht   removeLoaderst   isfileR   t   getLocalPatht   accessR   t   W_OKR1   t   isdirt   makedirst   unlinkt   symlinkt   getUncompressort
   uncompressR   t   WarningR   t   loadt   getErrataFlagsR   t   readR   R    t   setErrataFlagst
   setChannelt   _loaders(0   R   t   fetcherRG   t
   mirrorlistRC   t
   mirrorurlsR?   RB   t   schemet
   hdlbaseurlRg   t   infonamet   md5urlt   hdlmd5t   infomd5t   failedt   digestRA   RM   t   namet   hdlitemt   infoitemt   descitemt   descurlt   hdfailedt   reconfigurlt   reconfigitemt   refailedt   linest	   splitlinet   archt
   reconfarcht
   reconfpatht	   localpatht
   digestpatht   infopatht   listpatht   linkpathR   t   uncompressort   uncomphandlert   et   flagdictt   descpatht   errataR   R   t   loader(    (    s8   /usr/lib/python2.7/dist-packages/smart/channels/urpmi.pyRu   T   s:   
				
!	
   		
!	

			N(   t   __name__t
   __module__R`   R4   R   R   R   R   R    RF   Ru   (    (    (    s8   /usr/lib/python2.7/dist-packages/smart/channels/urpmi.pyR   "   s   			c         C   sI   t  | d | d | d | d | d |  | d | d | d | d	 ƒ
 S(
   NR   R   R   R   RJ   R“   t   manualt	   removablet   priority(   R   (   t   aliast   data(    (    s8   /usr/lib/python2.7/dist-packages/smart/channels/urpmi.pyt   create  s    
(   t   smart.backends.rpm.synthesisR    t   smart.backends.rpm.descriptionsR   t   smart.backends.rpm.headerR   t   smart.util.filetoolsR   t   smart.constR   R   R   R   t   smart.channelR   R	   t   smartR   Rq   Rd   R   R´   (    (    (    s8   /usr/lib/python2.7/dist-packages/smart/channels/urpmi.pyt   <module>   s   "
í