ó
È”Mc           @   s‹   d  d l  Z  d  d l m Z d  d l m Z d  d l m Z m Z d  d l m	 Z	 d  d l
 m Z m Z d e	 f d „  ƒ  YZ d	 „  Z d S(
   iÿÿÿÿN(   t   YaST2Loader(   t   getFileDigest(   t   FAILEDt   NEVER(   t   PackageChannel(   t   Errort   _t   YaST2Channelc           B   s8   e  Z d  „  Z d „  Z d „  Z e d „ Z d „  Z RS(   c         G   s,   t  t |  ƒ j | Œ  | |  _ | |  _ d  S(   N(   t   superR   t   __init__t   _baseurlt   _compressed(   t   selft   baseurlt
   compressedt   args(    (    s8   /usr/lib/python2.7/dist-packages/smart/channels/yast2.pyR	   !   s    	c         C   s   t  j |  j d ƒ g S(   Ns   media.1/media(   t	   posixpatht   joinR
   (   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/channels/yast2.pyt   getCacheCompareURLs&   s    c         C   s   d S(   Ni   (    (   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/channels/yast2.pyt   getFetchSteps)   s    c         C   s¶   | j  ƒ  | j | d | ƒ} | j d | ƒ | j ƒ  } | r² | j |  j ƒ  d ƒ | j ƒ  | j ƒ  t k r² t	 d ƒ |  d | j
 ƒ  | f g } t d j | ƒ ‚ q² n  | S(   Nt   uncompt   progressi   s&   Failed acquiring information for '%s':s   %s: %ss   
(   t   resett   enqueuet   runt   getFailedReasont   addR   t   showt
   getCachingR   R   t   getURLR   R   (   R   t   filet   fetcherR   t
   uncompresst   itemt   failedt   lines(    (    s8   /usr/lib/python2.7/dist-packages/smart/channels/yast2.pyt   __fetchFile,   s    

c         C   sý  t  j |  j d ƒ } |  j | | | ƒ } | j ƒ  t k r@ t St | j ƒ  ƒ } | |  j	 k re t
 St  j |  j d ƒ } |  j | | | ƒ } | j ƒ  t k r¥ t Sd } d } |  j } xÂ t | j ƒ  ƒ D]® }	 |	 j ƒ  }	 y |	 j d  d ƒ \ }
 } Wn t k
 rqÍ n X|
 d k r'| } qÍ |
 d k r<| } qÍ |
 d k rÍ | j d	 ƒ r`t } q{| j d
 ƒ r{t
 } q{qÍ qÍ Wt  j |  j d | ƒ } | r«| d 7} n  |  j | | | | ƒ } | j ƒ  t k rÙt S|  j ƒ  | j ƒ  } t | ƒ j ƒ  j ƒ  } | d k rÝt  j |  j d | ƒ } | r?| d 7} n  |  j | | | | ƒ } | j ƒ  t k st | j ƒ  ƒ j ƒ  j ƒ  d k r™t d ‚ n$ | j ƒ  } t |  j | | | ƒ } | j |  ƒ |  j j | ƒ n t t d | ƒ ‚ | |  _	 t
 S(   Ns   media.1/mediat   contents   suse/setup/descrt   RPMSi   t   DESCRDIRt   DATADIRt   METAt   packagess   packages.gzs   %s/packagess   .gzs	   =Ver: 2.0s   %s/packages.ens&   YaST2 package descriptions not loaded.s    Invalid package file header (%s)(   R   R   R
   t   _YaST2Channel__fetchFilet	   getStatusR   t   FalseR   t   getTargetPatht   _digestt   TrueR   t   opent   stript   splitt   Nonet
   ValueErrort   endswitht   removeLoaderst   readlineR   R    t
   setChannelt   _loaderst   appendR   (   R   R   R   t	   fetchitemt   fetchedt   digestt   descrdirt   datadirR    t   linet   keyt   restt   pkginfofilet   headert   pkgdescfilet   loader(    (    s8   /usr/lib/python2.7/dist-packages/smart/channels/yast2.pyt   fetch:   sp    				
$	(   t   __name__t
   __module__R	   R   R   R-   R+   RH   (    (    (    s8   /usr/lib/python2.7/dist-packages/smart/channels/yast2.pyR      s
   			c      
   C   s;   t  | d | d | d |  | d | d | d | d ƒ S(   NR   R   t   typet   namet   manualt	   removablet   priority(   R   (   t   aliast   data(    (    s8   /usr/lib/python2.7/dist-packages/smart/channels/yast2.pyt   create‹   s    
(   R   t   smart.backends.rpm.yast2R    t   smart.util.filetoolsR   t   smart.constR   R   t   smart.channelR   t   smartR   R   R   RR   (    (    (    s8   /usr/lib/python2.7/dist-packages/smart/channels/yast2.pyt   <module>   s   l