ó
È”Mc           @   s@  d  d l  m Z d  d l m Z m Z d  d l Ty d  d l m Z WnE e k
 r‹ y d  d l Z WqŒ e k
 r‡ d  d l	 m Z qŒ Xn Xd  d l
 Td  d l Z d  d l Z d  d l Z d  d l m Z e j d ƒ Z e j d ƒ Z e j d	 ƒ Z d
 e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z e j d e ƒ d S(   iÿÿÿÿ(   t	   splitarch(   t   PackageInfot   Loader(   t   *(   t   cElementTreeN(   t   expats   ^([^[]*)(\[\*\])?(\[.*\])?s   \[([<>=]*) *(.+)?\]s   [0-9]+:t   URPMISynthesisPackageInfoc           B   sb   e  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  j |  | ƒ | |  _ | |  _ d  S(   N(   R   t   __init__t   _loadert   _info(   t   selft   packaget   loadert   info(    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyR   4   s    	c         C   s%   t  j |  j j |  j j |  ƒ ƒ g S(   N(   t	   posixpatht   joinR   t   _baseurlt   getFileName(   R
   (    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyt   getURLs9   s    c         C   s   |  j  j d ƒ S(   Nt   filesize(   R	   t   get(   R
   t   url(    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyt   getSize=   s    c         C   s   t  |  j j d ƒ ƒ S(   Nt   size(   t   intR	   R   (   R
   (    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyt   getInstalledSize@   s    c         C   s   |  j  j d d ƒ S(   Nt   summaryt    (   R	   R   (   R
   (    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyt
   getSummaryC   s    c         C   s   |  j  j d d ƒ S(   Nt   groupR   (   R	   R   (   R
   (    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyt   getGroupF   s    c         C   s   |  j  j d ƒ S(   Nt   description(   R	   R   (   R
   (    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyt   getDescriptionI   s    c         C   s   |  j  j d d ƒ g S(   NR   R   (   R	   R   (   R
   (    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyt   getReferenceURLsL   s    c         C   sI   |  j  j d d ƒ } | j d d ƒ } | j d d ƒ } | j d d ƒ S(   Nt	   sourcerpmR   s   .srcs   .nosrcs   .rpm(   R	   R   t   replace(   R
   R"   (    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyt	   getSourceO   s    c         C   s   |  j  j d d ƒ S(   Nt   licenseR   (   R	   R   (   R
   (    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyt
   getLicenseU   s    (   t   __name__t
   __module__R   R   R   R   R   R   R    R!   R$   R&   (    (    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyR   3   s   									t   URPMISynthesisLoaderc           B   sf   e  Z e j d  Z d	 d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 e e d „ Z d „  Z RS(
   i   c         C   s>   t  j |  ƒ | |  _ | |  _ i  |  _ | |  _ d  |  _ d  S(   N(   R   R   t	   _filenameR   t   _prefixt	   _infofilet   Nonet	   _flagdict(   R
   t   filenamet   baseurlt   listfilet   infofile(    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyR   \   s    				c         C   s   | |  _  d  S(   N(   R.   (   R
   t   flagdict(    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyt   setErrataFlagsd   s    c         C   s†   t  j |  | | | | | ƒ } | d } t |  d ƒ r‚ |  j r‚ | |  j k r‚ t j ƒ  s‚ t j |  j | | d | d ƒ q‚ n  | S(   Ni   R.   t   =i   (   R   t   buildPackaget   hasattrR.   t   sysconft   getReadOnlyt   pkgconft   setFlag(   R
   t   pkgargst   prvargst   reqargst   upgargst   cnfargst   pkgt   name(    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyR6   g   s    
''c         C   s   t  | |  | j |  ƒ S(   N(   R   t   loaders(   R
   RA   (    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyt   getInfoo   s    c         C   s{   | j  j } t | j  j ƒ \ } } t j d | ƒ } d | | | f } | |  j k rw t j j	 |  j | | ƒ } n  | S(   NR   s   %s-%s.%s.rpm(
   t   _packageRB   R    t   versiont   EPOCHREt   subR+   t   ost   pathR   (   R
   R   RB   RF   t   archR/   (    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyR   r   s    c         C   sP   t  |  j ƒ } d } x* | D]" } | j d ƒ r | d 7} q q W| j ƒ  | S(   Ni    s   @info@i   (   t   openR*   t
   startswitht   close(   R
   t	   indexfilet   totalt   line(    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyt   getLoadSteps{   s    
c         C   sÝ   g  } xÐ | D]È } | j  | ƒ } | r | j ƒ  \ } } }	 d  }
 d  } |	 r³ | j  |	 ƒ } | r³ | j ƒ  \ }
 } |
 d k r‹ d }
 n  | r° | j d ƒ r° | d } q° q³ n  | j | |
 | t | ƒ f ƒ q q W| S(   Ns   ==R5   s   0:i   (   t   matcht   groupsR-   RM   t   appendt   bool(   R
   t	   depsarrayt
   _dependsret   _operationret   resultt   depst   dependsRB   t   flagt	   conditiont	   operationRF   t   o(    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyt   splitDepends„   s"    	&c   /      C   s  t  } t } t } t } t } t } t } d  } d  }	 d  }
 d! } d" } d# } t j	 |  j
 ƒ } |  j rü yO |  j } | j d ƒ r¢ d d  l } | j | ƒ } n  t j | ƒ j ƒ  } Wqt j t f k
 rø } t t d ƒ |  j t | ƒ f ‚ qXn d  } xt |  j ƒ D]} | d d !j d ƒ } | j d ƒ } | d k rV| d } q| d k rut | d ƒ }	 q| d	 k r“|  j | ƒ } q| d
 k r±|  j | ƒ }
 q| d k rÏ|  j | ƒ } q| d k rí|  j | ƒ } q| d k rd } d } d } d } | rÙ| d } | j d ƒ | d k rqx4 | D]) } | j d ƒ | d k rA| } PqAqAWn  | j d ƒ | d k rÙ| j j  ƒ  } | j d ƒ } | j d ƒ } | j d ƒ } | j! | ƒ qÙn  | d j d ƒ } d j" | d ƒ } | d } | d k r(d | | f } n  | j# d ƒ } | d k rLd }  n | |  | | d } }  d j" | |  f ƒ }! t$ j% |  ƒ d k r•qn  d j" | d d !ƒ }" i | d 6|	 d 6| d d 6| d d 6| d 6| d 6| d 6| d 6}# i  }$ x] | D]U \ }% }& }' }( |% |" k r:|' | k r:| |% |! f }) n | |% |' f }) t& |$ |) <qþWi  }* x” |
 D]Œ \ }% }& }' }( |& d  k sŽd |& k r£| |% |' f |$ k pµt' j( |% |& |' ƒ sd|( r×t& |* | |% |& |' f <qðt& |* | |% |& |' f <qdqdWi  }+ x0 | D]( \ }% }& }' }( t& |+ | |% |& |' f <qWi  }, t& |, | |" d |! f <x@ | D]8 \ }% }& }' }( | |% |& |' f }- t& |, |- <t& |+ |- <qPW|  j) | |" |! f |$ j* ƒ  |* j* ƒ  |, j* ƒ  |+ j* ƒ  ƒ }. |# |. j+ |  <| j, d ƒ | j- ƒ  d  } d  }	 d$ } d% }
 d& } d' } qqWd  S((   Ns   .lzmaiÿÿÿÿs   Invalid XML file:
  %s
  %si   t   @i    R   R   t   providest   requirest	   conflictst	   obsoletesR   R   t   fnR"   R   R%   t   -iþÿÿÿt   0s   %s:%st   .t   unknowni   R   i   R   R   R5   t   <(    (    (    (    (    (    (    (    (.   t
   RPMPackaget   RPMProvidest   RPMNameProvidest   RPMPreRequirest   RPMRequirest   RPMObsoletest   RPMConflictsR-   t   ifacet   getProgresst   _cacheR,   t   endswitht   lzmat   LZMAFileR   t   parset   getrootR   t   errort   SyntaxErrort   Errort   _t   strRL   R*   t   splitt   popR   Ra   R   t   textt   stript   removeR   t   rfindt   rpmt	   archscoret   Truet   system_providesRS   R6   t   keysRC   t   addt   show(/   R
   t   Pkgt   Prvt   NPrvt   PreReqt   Reqt   Obst   CnfR   R   Rd   Rc   Re   Rf   t   progR2   Rx   t   infoxmlt   eRQ   t   elementt   idR   R"   R   R%   t   infoelementt   elemt   rpmnamepartsRF   t   epocht   dotRK   t   versionarchRB   R   t   prvdictt   nt   rt   vt   ft   prvt   reqdictt   cnfdictt   upgdictt   upgRA   (    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyt   load˜   sä    		

	



N(   R'   R(   R   t   __stateversion__R-   R   R4   R6   RD   R   RR   t	   DEPENDSREt   OPERATIONRERa   Rª   (    (    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyR)   X   s   							c         C   s4   |  j  t j ƒ |  j  t j ƒ |  j  t j ƒ d  S(   N(   t   bindR)   RR   Ra   Rª   (   t   psyco(    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyt   enablePsyco5  s    s   enable-psyco(   t   smart.backends.rpm.rpmverR    t   smart.cacheR   R   t   smart.backends.rpm.baset	   xml.etreeR   t   ImportErrort
   smart.utilt   smartR   RI   t   ret   xml.parsersR   t   compileR¬   R­   RG   R   R)   R°   t   hookst   register(    (    (    s@   /usr/lib/python2.7/dist-packages/smart/backends/rpm/synthesis.pyt   <module>   s*   

%Ý	