
N_c           @   s   d  Z  d d l m Z d d l Z d d l Z d d l Z d d l Z d d l m Z d d l	 Z
 d d l	 m Z d f  d     YZ d e f d	     YZ d
 e f d     YZ d e f d     YZ d   Z d   Z d e f d     YZ d S(   s;   
Classes for manipulating and querying groups of packages.
i(   t   PackageSackErrorN(   t   parsePackages(   t
   compareEVRt   PackageSackVersionc           B   s5   e  Z d    Z d   Z d   Z d   Z d   Z RS(   c         C   s"   d |  _  t j d g  |  _ d  S(   Ni    t   sha1(   t   _numt   misct	   Checksumst   _chksum(   t   self(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   __init__   s    	c         C   s   d |  j  |  j j   f S(   Ns   %u:%s(   R   R   t	   hexdigest(   R	   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   __str__#   s    c         C   s   | d  k r t St |  t d  t d  f k rD t |   | k S|  j | j k rZ t S|  j j   | j j   k r| t St S(   Nt    u    (   t   Nonet   Falset   typet   strR   R   t   digestt   True(   R	   t   other(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   __eq__&   s     $  c         C   s   |  | k S(   N(    (   R	   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   __ne__-   s    c         C   s`   |  j  d 7_  |  j j t |   | d  k	 r\ |  j j | d  |  j j | d  n  d  S(   Ni   i    (   R   R   t   updateR   R   (   R	   t   pkgt   csum(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR   0   s
    (   t   __name__t
   __module__R
   R   R   R   R   (    (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR      s
   				t   PackageSackBasec           B   s  e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d% d% d% d% d% d  Z g  e d	  Z d
   Z d   Z d% d% d% d% d% d% d  Z d% d& d  Z d% d' d  Z d   Z d   Z d   Z d   Z e d  Z d   Z d   Z d   Z d   Z d   Z d% d% e d  Z d   Z e i  d  Z d% d% e d  Z  d% d% e d  Z! d% e d  Z" d   Z# d    Z$ d!   Z% d"   Z& d#   Z' d% d$  Z( RS((   s8   Base class that provides the interface for PackageSacks.c         C   s   i  |  _  d  S(   N(   t   added(   R	   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR
   :   s    c         C   s   t  |  j    S(   N(   t   lent   returnPackages(   R	   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   __len__=   s    c         C   s3   |  j    } t | d  r% | j   St |  Sd  S(   Nt   __iter__(   R   t   hasattrR!   t   iter(   R	   t   ret(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR!   @   s    
c         C   s   | d  k r d St |  j  } t | j  } t |  t |  k rZ t |  t |  SxB t t |  t |   D]% \ } } t | |  } | rv | Sqv Wd S(   Ni   i    (   R   t   listR   R   t   zipt   sortedt   cmp(   R	   R   t   s_repost   o_repost   s_repot   o_repoR$   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   __cmp__G   s    (c         C   s   t     d  S(   N(   t   NotImplementedError(   R	   t   compatArchs(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   setCompatArchsU   s    c         C   s   t     d  S(   N(   R.   (   R	   t   repot   mdtypet   callbackt	   cacheOnly(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   populateX   s    c         C   s#   t  j d t d d |  j |  S(   s5   return a list of package objects by (n,a,e,v,r) tuples;   packagesByTuple() will go away in a future version of Yum.
t
   stackleveli   (   t   warningst   warnt   DeprecationWarningt   searchPkgTuple(   R	   t   pkgtup(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   packagesByTuple[   s    	c         C   s   t     d S(   s6   return list of pkgobjects matching the nevra requestedN(   R.   (   R	   t   namet   epocht   vert   relt   arch(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   searchNevrac   s    c         C   s   t     d  S(   N(   R.   (   R	   t   namest   return_pkgtups(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   searchNamesg   s    c         C   s7   |  j  d | j d | j d | j d | j d | j  S(   sr   return list of package objects matching the name, epoch, ver, rel,
           arch of the package object passed inR=   R>   R?   R@   RA   (   RB   R=   R>   R?   R@   RA   (   R	   t   po(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   searchPOj   s    $c         C   s=   | \ } } } } } |  j  d | d | d | d | d |  S(   s7   return list of pkgobject matching the (n,a,e,v,r) tupleR=   RA   R>   R?   R@   (   RB   (   R	   R;   t   nt   at   et   vt   r(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR:   q   s    c         C   sd   | r6 | j  } | j } | j } | j } | j } n  t |  j d | d | d | d | d |   S(   sp   return if there are any packages in the sack that match the given NAEVR 
           or the NAEVR of the given poR=   RA   R>   R?   R@   (   R=   RA   R>   t   versiont   releaset   boolRB   (   R	   R=   RA   R>   R?   R@   RF   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   containsv   s    				c         C   s   t     d S(   s5   return dict { packages -> list of matching provides }N(   R.   (   R	   R=   t   flagsRM   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   getProvides   s    c         C   s   t     d S(   s5   return dict { packages -> list of matching requires }N(   R.   (   R	   R=   RQ   RM   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   getRequires   s    c         C   s   t     d S(   s<   return list of package requiring the name (any evr and flag)N(   R.   (   R	   R=   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   searchRequires   s    c         C   s   t     d S(   s<   return list of package providing the name (any evr and flag)N(   R.   (   R	   R=   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   searchProvides   s    c         C   s   t     d S(   sC   return list of package conflicting with the name (any evr and flag)N(   R.   (   R	   R=   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   searchConflicts   s    c         C   s   t     d S(   s=   return list of package obsoleting the name (any evr and flag)N(   R.   (   R	   R=   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   searchObsoletes   s    c         C   s   t     d S(   sE   returns a dict of obsoletes dict[obsoleting pkgtuple] = [list of obs]N(   R.   (   R	   t   newest(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   returnObsoletes   s    c         C   s   t     d S(   sb    Is calling pkg.returnFileEntries(primary_only=True) faster than
            using searchFiles(). N(   R.   (   R	   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   have_fastReturnFileEntries   s    c         C   s   t     d S(   s#   return list of packages by filenameN(   R.   (   R	   R=   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   searchFiles   s    c         C   s   t     d S(   s"   add a pkgobject to the packageSackN(   R.   (   R	   t   obj(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt
   addPackage   s    c         C   s   t     d S(   s   builds the useful indexes for searching/querying the packageSack
           This should be called after all the necessary packages have been
           added/deletedN(   R.   (   R	   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   buildIndexes   s    c         C   s   t     d S(   s   delete a pkgobjectN(   R.   (   R	   R\   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt
   delPackage   s    c         C   s   t     d S(   s   return list of all packagesN(   R.   (   R	   t   repoidt   patternst   ignore_case(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR      s    c         G   s   t     d S(   s   Add an "excluder" for all packages in the repo/sack. Can basically
            do anything based on nevra, changes lots of exclude decisions from
            "preload package; test; delPackage" into "load excluder".
            Excluderid is used so the caller doesn't have to track
            "have I loaded the excluder for this repo.", it's probably only
            useful when repoid is None ... if it turns out utterly worthless
            then it's still not a huge wart. N(   R.   (   R	   R`   t
   excluderidt   excludert   args(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   addPackageExcluder   s    c         C   sV  d   } t    } i  } i  } i  } xt |  j    D] } | j   }	 | j | |	  x^ | D]V }
 | j | |
 k r` |
 | k r t    | |
 <i  | |
 <n  | |
 j | |	  q` q` W| r q7 n  | j j j } | | | j	 | | |	  xA | D]9 }
 | j | |
 k r | | |
 | j	 | | |	  q q Wq7 W| rL| | | | g S| | g S(   s5    Return a simple version for all available packages. c         S   so   |  j  | i   } | j  d  t    } | j | |  | d  k	 rk | j  | t    } | j | |  n  d  S(   N(   t
   setdefaultR   R   R   (   t   areposR`   t   revR   R   t   arevst   rpsv(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   _up_revs   s    (
   R   R'   R   t   returnIdSumR   R=   R1   t   repoXMLt   revisionR`   (   R	   t	   main_onlyt   groupsRl   t   mainRh   t	   main_grpst   arepos_grpsR   R   t   groupRi   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   simpleVersion   s0    		(c         C   s   t     d S(   s~  return list of newest packages based on name, arch matching
           this means(in name.arch form): foo.i386 and foo.noarch are not
           compared to each other for highest version only foo.i386 and
           foo.i386 will be compared
           Note that given: foo-1.i386; foo-2.i386 and foo-3.x86_64
           The last _two_ pkgs will be returned, not just one of them. N(   R.   (   R	   t   naTupRa   Rb   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   returnNewestByNameArch   s    c         C   s   t     d S(   s   return list of newest packages based on name matching
           this means(in name.arch form): foo.i386 and foo.noarch will
           be compared to each other for highest version.N(   R.   (   R	   R=   Ra   Rb   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   returnNewestByName   s    c         C   s   t     d S(   s,   returns a list of pkg tuples (n, a, e, v, r)N(   R.   (   R	   Ra   Rb   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   simplePkgList   s    c         C   s   t     d  S(   N(   R.   (   R	   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   printPackages   s    c         C   s   t     d S(   sD   exclude incompatible arches. archlist is a list of compatible archesN(   R.   (   R	   t   archlist(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   excludeArchs   s    c         C   s   t     d  S(   N(   R.   (   R	   t   fieldst   criteria_reR3   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   searchPackages  s    c         C   s   t     d  S(   N(   R.   (   R	   t   argt
   query_type(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt	   searchAll  s    c         C   s  g  } g  } t  |  } i  } x! | D] } t j |  | | <q% W|  j d |  } xKg  | D] } | j ^ q^ D]-}	 |	 \ }
 } } } } t  |
 d |
 | f d |
 | | | f d |
 | f d |
 | | f d | |
 | | | f d |
 | | | | f f  } x | j   D] \ } } | | k rS| j |  j |	  d  | j |  qxD | D]< }
 | |
  rZ| j |  j |	  d  | j |  qZqZWqWqq Wt j	 |  t j	 |  t
 |  f S(	   s{  take a list strings and match the packages in the sack against it
           this will match against:
           name
           name.arch
           name-ver-rel.arch
           name-ver
           name-ver-rel
           epoch:name-ver-rel.arch
           name-epoch:ver-rel.arch
           
           return [exact matches], [glob matches], [unmatch search terms]
           Ra   s   %s.%ss   %s-%s-%s.%ss   %s-%ss   %s-%s-%ss   %s:%s-%s-%s.%ss   %s-%s:%s-%s.%si    (   t   setR   t   compile_patternR   R;   t   itemst   appendR:   t   discardt   uniqueR%   (   R	   t   pkgspecst   matchedt
   exactmatcht	   unmatchedt   specst   pt   pkgsR   R;   RH   RI   RJ   RK   RL   RC   t   termt   query(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   matchPackageNames	  s4    #c   	      C   sA  d   } i  } g  } x |  j  d |  D]u } | j s= q( n  x] | j D]R } | | k ri t   | | <n  t | |  d k r qG n  | | j | j  qG Wq( Wx |  j  d |  D] } d } xZ | |  D]L } | | k r t | |  d k s| j | | k r| d 7} Pqq q W| d k r | j |  q q W| S(   sj   returns a list of package objects that are not required by
           any other package in this repositoryc         s   sh   x |  j  D] } | Vq
 Wx |  j D] } | Vq# Wx |  j D] } | Vq< Wx |  j D] } | VqU Wd S(   s&    Return all the provides, via. yield. N(   t   provides_namest   filelistt   dirlistt	   ghostlist(   RF   t   prov(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   _return_all_provides=  s    			R`   i   i    (   R   t   requires_namesR   R   t   addR=   R   (	   R	   R`   R   t   reqt   orphansRF   RL   t   preqR   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   returnLeafNodes9  s,    		)
N(   NNN(   NNN()   R   R   t   __doc__R
   R    R!   R-   R0   R5   R<   R   RB   R   RE   RG   R:   RP   RR   RS   RT   RU   RV   RW   RY   RZ   R[   R]   R^   R_   R   Rf   Rv   Rx   Ry   Rz   R{   R}   R   R   R   R   (    (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR   8   sL   																			
&						0t   MetaSackc           B   ss  e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d! d! d! d! d! d  Z g  e d	  Z d! d" d
  Z d! d# d  Z d   Z d   Z d   Z d   Z e d  Z d   Z d   Z d   Z d   Z d! d! e d  Z d   Z d! d! e d  Z d! d! e d  Z d! e d  Z d   Z d   Z d   Z  d   Z! d   Z" d   Z# d    Z$ RS($   sq   Represents the aggregate of multiple package sacks, such that they can
       all be treated as one unified sack.c         C   s#   t  j |   i  |  _ d  |  _ d  S(   N(   R   R
   t   sacksR   t   compatarchs(   R	   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR
   m  s    	c         C   s:   d } x- t  |  j j    D] } | t |  7} q W| S(   Ni    (   R'   R   t   valuesR   (   R	   R$   t   sack(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR    r  s    c         C   s:   x3 |  j  j   D]" } t | d  r | j   q q Wd  S(   Nt   dropCachedData(   R   R   R"   R   (   R	   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR   x  s    c         C   s!   | |  j  | <| j |  j  d S(   s1   Adds a repository's packageSack to this MetaSack.N(   R   R0   R   (   R	   R`   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   addSack}  s    c         C   s$   |  j  | j j | | | |  d  S(   N(   R   t   idR5   (   R	   R1   R2   R3   R4   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR5     s    c         C   s+   x$ |  j  j   D] } | j |  q Wd  S(   N(   R   R   R0   (   R	   R/   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR0     s    c         C   s&   t  j d t d d |  j d |  S(   s5   return a list of package objects by (n,a,e,v,r) tuples;   packagesByTuple() will go away in a future version of Yum.
R6   i   R<   (   R7   R8   R9   t   _computeAggregateListResult(   R	   R;   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR<     s    	c         C   s   |  j  d | | | | |  S(   s6   return list of pkgobjects matching the nevra requestedRB   (   R   (   R	   R=   R>   R?   R@   RA   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRB     s    c         C   s   |  j  d | |  S(   NRE   (   R   (   R	   RC   RD   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRE     s    c         C   s   |  j  d | | |  S(   s5   return dict { packages -> list of matching provides }RR   (   t   _computeAggregateDictResult(   R	   R=   RQ   RM   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRR     s    c         C   s   |  j  d | | |  S(   s5   return dict { packages -> list of matching requires }RS   (   R   (   R	   R=   RQ   RM   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRS     s    c         C   s   |  j  d |  S(   s<   return list of package requiring the name (any evr and flag)RT   (   R   (   R	   R=   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRT     s    c         C   s   |  j  d |  S(   s<   return list of package providing the name (any evr and flag)RU   (   R   (   R	   R=   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRU     s    c         C   s   |  j  d |  S(   sC   return list of package conflicting with the name (any evr and flag)RV   (   R   (   R	   R=   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRV     s    c         C   s   |  j  d |  S(   s=   return list of package obsoleting the name (any evr and flag)RW   (   R   (   R	   R=   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRW     s    c            s   | s |  j  d  S|  j  d  } t d   | D  } i  } d } d	 } d	 } d       f d   } x~ t |  j | d t d   D][ }	 |	 d }
 | |
 k r | | |	  r q n  |
 } |	 } |	 | k r | |	 | |	 <q q W| S(
   sE   returns a dict of obsoletes dict[obsoleting pkgtuple] = [list of obs]RY   c         s   s   |  ] } | d  Vq d S(   i    N(    (   t   .0t   obstup(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pys	   <genexpr>  s    R   c         S   sY   t  |  d | d  } | r! | St |  d |  d |  d f | d | d | d f  S(   s4    Compare two pkgtup's (ignore arch): n, a, e, v, r. i    i   i   i   (   R(   R   (   t   xt   yR$   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   _pkgtup_nevr_cmp  s     c            s     |  |  d k S(   Ni    (    (   R   R   (   R   (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   _pkgtup_nevr_eq  s    RD   R(   i    N(   R   R   R   R'   RE   R   (   R	   RX   t   obsdictRC   t   nobsdictt	   last_namet   last_pkgt   last_pkgtupR   R;   R=   (    (   R   s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRY     s(    	
c         C   s   |  j  d |  S(   s#   return list of packages by filenameR[   (   R   (   R	   R=   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR[     s    c         C   s   d S(   sa   Add a pkgobject to the packageSack.  This is a meaningless operation
           for the MetaSack.N(    (   R	   R\   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR]     s    c         C   s(   x! |  j  j   D] } | j   q Wd S(   s   builds the useful indexes for searching/querying the packageSack
           This should be called after all the necessary packages have been
           added/deletedN(   R   R   R^   (   R	   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR^     s    c         C   s   | j  j j |  d S(   s2   Delete a pkgobject if it exists in every sub-sack.N(   R1   R   R_   (   R	   R\   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR_     s    c         C   s9   | s |  j  d d | |  S|  j | j d | d |  S(   s   Returns a list of packages. Note that the packages are
           always filtered to those matching the patterns/case. An optional
           repoid allows you to easily get data for a specific repo. R   Ra   Rb   N(   R   R   R   R   (   R	   R`   Ra   Rb   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR     s
    	c         G   sB   | s% |  j  } | d d | | |  S|  j | j d | | |  S(   s   Add an "excluder" for all packages in the repo/sack. Can basically
            do anything based on nevra, changes lots of exclude decisions from
            "preload package; test; delPackage" into "load excluder".
            Excluderid is used so the caller doesn't have to track
            "have I loaded the excluder for this repo.", it's probably only
            useful when repoid is None ... if it turns out utterly worthless
            then it's still not a huge wart. Rf   N(   R   R   R   Rf   (   R	   R`   Rc   Rd   Re   t   calr(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRf     s
    	c         C   sf   |  j  } | d | | |  } t |  } | rb | s= | rb d j | pL g   } t d |  n  | S(   s  return list of newest packages based on name, arch matching
           this means(in name.arch form): foo.i386 and foo.noarch are not
           compared to each other for highest version only foo.i386 and
           foo.i386 will be compared.
           Note that given: foo-1.i386; foo-2.i386 and foo-3.x86_64
           The last _two_ pkgs will be returned, not just one of them. Rx   s   , s   No Package Matching %s(   R   t   packagesNewestByNameArcht   joinR    (   R	   Rw   Ra   Rb   R   R   t   ui_pats(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRx     s    	c         C   so   |  j  d | | |  } t |  } | rk | s7 | rk | rF | } n d j | pU g   } t d |  n  | S(   s   return list of newest packages based on name matching
           this means(in name.arch form): foo.i386 and foo.noarch will
           be compared to each other for highest version.Ry   s   , s   No Package Matching %s(   R   t   packagesNewestByNameR   R    (   R	   R=   Ra   Rb   R   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRy     s    	c         C   s   |  j  d | |  S(   s,   returns a list of pkg tuples (n, a, e, v, r)Rz   (   R   (   R	   Ra   Rb   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRz     s    	c         C   s(   x! |  j  j   D] } | j   q Wd  S(   N(   R   R   R{   (   R	   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR{   #  s    c         C   s+   x$ |  j  j   D] } | j |  q Wd S(   sD   exclude incompatible arches. archlist is a list of compatible archesN(   R   R   R}   (   R	   R|   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR}   '  s    c         C   s   |  j  d | | |  S(   NR   (   R   (   R	   R~   R   R3   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR   ,  s    c         C   s   |  j  d | |  S(   NR   (   R   (   R	   R   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR   /  s    c   	      C   s  g  } g  } d  } x |  j j   D] } t | d  r" g  g  g  } } } y | j |  \ } } } Wn t k
 r} q" n X| j |  | j |  | d  k r t |  } q | j t |   } q" q" Wt	 j
 |  } t	 j
 |  } | d  k rg  } n t |  } | | | f S(   NR   (   R   R   R   R"   R   R    t   extendR   t   intersectionR   R   R%   (	   R	   R   R   R   R   R   RJ   t   mt   u(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR   2  s*    	c         G   s   g  } x~ t  |  j j    D]g } t | |  r t | |  } y t | |  } Wn t k
 ri q n X| r | j |  q q q W| S(   N(   R'   R   R   R"   t   getattrt   applyR    R   (   R	   t
   methodNameRe   t   resultR   t   methodt
   sackResult(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR   M  s    c         G   s   i  } x~ t  |  j j    D]g } t | |  r t | |  } y t | |  } Wn t k
 ri q n X| r | j |  q q q W| S(   N(   R'   R   R   R"   R   R   R    R   (   R	   R   Re   R   R   R   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR   \  s    N(   NNN(   NNN(%   R   R   R   R
   R    R   R   R5   R0   R<   R   RB   R   RE   RR   RS   RT   RU   RV   RW   RY   R[   R]   R^   R_   R   Rf   Rx   Ry   Rz   R{   R}   R   R   R   R   R   (    (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR   i  sD   											"				
							t   PackageSackc           B   sv  e  Z d  Z d   Z d   Z d d  Z d   Z d   Z d" d" d" d" d" d  Z	 g  e
 d  Z d" d# d	  Z d" d$ d
  Z d   Z d   Z d   Z d   Z d   Z e
 d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z d" d" e
 d  Z d" d" e
 d  Z d" d" e
 d  Z  d" e
 d  Z! d   Z" d    Z# d!   Z$ RS(%   s*   represents sets (sacks) of Package Objectsc         C   sk   t  j |   i  |  _ i  |  _ i  |  _ i  |  _ i  |  _ i  |  _ i  |  _ i  |  _	 d  |  _ d |  _ d  S(   Ni    (   R   R
   t   nevrat	   obsoletest   requirest   providest	   conflictst	   filenamest
   pkgsByRepot   pkgsByIDR   R   t   indexesBuilt(   R	   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR
   n  s    									c         C   s5   d } x( |  j  D] } | t |  j  |  7} q W| S(   Ni    (   R   R   (   R	   R$   R1   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR      s    t   errorc         C   sA   |  j  s= | d k r! t d  q= | d k r= |  j   q= n  d S(   s   check to see if the indexes are built, if not do what failure demands
           either error out or build the indexes, default is to error outR   s$   Indexes not yet built, cannot searcht   buildN(   R   R    R^   (   R	   t   failure(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   _checkIndexes  s
    	c         C   s   |  j    d S(   s*    Do nothing, mainly for the testing code. N(   t   clearIndexes(   R	   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR     s    c         C   s   | |  _  d  S(   N(   R   (   R	   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR0     s    c   
      C   s?  |  j  d d  | | | | | f |  j k rH |  j | | | | | f S| d k	 r{ |  j j | d d d d f g   } n- g  } x$ |  j j   D] } | j |  q Wg  } x | D] }	 | r | |	 j k s | r | |	 j k s | r | |	 j	 k s | r| |	 j
 k s | r*| |	 j k r*q n  | j |	  q W| S(   s6   return list of pkgobjects matching the nevra requestedR   R   N(   R   R   R   t   getR   t
   itervaluesR   R=   R>   R?   R@   RA   R   (
   R	   R=   R>   R?   R@   RA   R   t
   pkgsbyRepoR   RF   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRB     s$    'c         C   s   |  j  d d  g  } t   } xX | D]P } | | k r> q& n  | j |  | j |  j j | d d d d f g    q& W| r g  | D] } | j ^ q S| S(   s6   return list of pkgobjects matching the names requestedR   R   N(   R   R   R   R   R   R   R   R;   (   R	   RC   RD   R   t   doneR=   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRE     s    	/c         C   s  |  j  d d  | d k r% d } n6 t |  t t d  t f k r[ t j j |  } n  i  } xK |  j j	 | g   D]4 } | j
 d | | | f  } | rw | | | <qw qw W| d d k r| d d f } x3 |  j |  D] } | j | g   j |  q Wn  | S(	   s5   return dict { packages -> list of matching provides }R   R   R   i    t   /N(   NNN(   NNN(   R   R   R   R   t   unicodet   rpmUtilst	   miscutilst   stringToVersionR   R   t   matchingPrcosR[   Rg   R   (   R	   R=   RQ   RM   R   RF   t   hitst   hit(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRR     s    	! c         C   s   |  j  d d  | d k r% d } n6 t |  t t d  t f k r[ t j j |  } n  i  } xK |  j j	 | g   D]4 } | j
 d | | | f  } | rw | | | <qw qw W| S(   s5   return dict { packages -> list of matching requires }R   R   R   N(   NNN(   R   R   R   R   R   R   R   R   R   R   R   (   R	   R=   RQ   RM   R   RF   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRS     s    	!c         C   s   |  j  d d  t |  |  } t j |  \ } } \ } } } g  }	 g  }
 | | k rl |	 j | |  n  xB |	 D]: } | j | | | | | | f f  rs |
 j |  qs qs W| d k r |
 St j |  s |
 S|
 j |  j |   t j	 |
  S(   NR   R   R   (
   R   R   R   t   string_to_prco_tupleR   t	   checkPrcoR   t   re_filenameR[   R   (   R	   R=   t   prcotypet   prcodictRH   t   fRJ   RK   RL   t   basic_resultst   resultsRF   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt
   searchPrco  s     !$c         C   s   |  j  | d  S(   s3   return list of package requiring the item requestedR   (   R   (   R	   R=   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRT     s    c         C   s   |  j  | d  S(   s3   return list of package providing the item requestedR   (   R   (   R	   R=   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRU     s    c         C   s   |  j  | d  S(   s6   return list of package conflicting with item requestedR   (   R   (   R	   R=   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRV     s    c         C   s   |  j  | d  S(   s4   return list of package obsoleting the item requestedR   (   R   (   R	   R=   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRW     s    c         C   s   i  } xN |  j    D]@ } t | j  d k r4 q n  | j | j g   j | j  q W| sa | St d   |  j   D  } g  } x* | D]" } | | k r | j |  q q Wx | D] } | | =q W| S(   sE   returns a dict of obsoletes dict[obsoleting pkgtuple] = [list of obs]i    c         s   s   |  ] } | j  Vq d  S(   N(   R;   (   R   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pys	   <genexpr>  s    (	   R   R   R   Rg   R;   R   R   Ry   R   (   R	   RX   t   obsRF   t   newest_tupst   togoR   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRY   	  s    #c         C   s   t  S(   sb    Is calling pkg.returnFileEntries(primary_only=True) faster than
            using searchFiles(). (   R   (   R	   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRZ   #  s    c         C   s2   |  j  d d  | |  j k r* |  j | Sg  Sd S(   s&    Return list of packages by filename. R   R   N(   R   R   (   R	   R=   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR[   (  s    c         C   s.   | | k r g  | | <n  | | j  |  d  S(   N(   R   (   R	   t   dictt   keyt   data(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   _addToDictAsList0  s    c         C   s]   | | k r d  Sy | | j  |  Wn t k
 r8 n Xt | |  d k rY | | =n  d  S(   Ni    (   t   removet
   ValueErrorR   (   R	   R   R   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   _delFromListOfDict7  s    c         C   sp   | j  } | j \ } } } } } |  j s: | |  j k rS |  j |  j | |  n  |  j rl |  j |  n  d S(   s"   add a pkgobject to the packageSackN(   R`   R;   R   R   R   R   t   _addPackageToIndex(   R	   R\   R`   R=   RA   R>   R?   R@   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR]   C  s    		c         C   sP   |  j    x6 |  j D]+ } x" |  j | D] } |  j |  q( Wq Wd |  _ d S(   s   builds the useful indexes for searching/querying the packageSack
           This should be called after all the necessary packages have been 
           added/deletedi   N(   R   R   R   R   (   R	   R`   R\   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR^   N  s
    
c         C   sL   i  |  _  i  |  _ i  |  _ i  |  _ i  |  _ i  |  _ i  |  _ d |  _ d  S(   Ni    (   R   R   R   R   R   R   R   R   (   R	   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR   [  s    							c         C   s  x? | j  d  D]. \ } } \ } } } |  j |  j | |  q Wx? | j  d  D]. \ } } \ } } } |  j |  j | |  qR Wx? | j  d  D]. \ } } \ } } } |  j |  j | |  q Wx? | j  d  D]. \ } } \ } } } |  j |  j | |  q WxD | j   D]6 } x- | j |  D] } |  j |  j | |  q+WqW|  j |  j	 | j
 |  | j \ }	 }
 } } } |  j |  j |	 | | | |
 f |  |  j |  j |	 d  d  d  d  f |  d  S(   NR   R   R   R   (   t
   returnPrcoR   R   R   R   R   t   returnFileTypest   returnFileEntriesR   R   R   R;   R   R   (   R	   R\   RH   t   flRJ   RK   RL   t   ftypet   fileR=   RA   R>   R?   R@   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR   g  s    ((((%c         C   s  x? | j  d  D]. \ } } \ } } } |  j |  j | |  q Wx? | j  d  D]. \ } } \ } } } |  j |  j | |  qR Wx? | j  d  D]. \ } } \ } } } |  j |  j | |  q Wx? | j  d  D]. \ } } \ } } } |  j |  j | |  q WxD | j   D]6 } x- | j |  D] } |  j |  j | |  q+WqW|  j |  j	 | j
 |  | j \ }	 }
 } } } |  j |  j |	 | | | |
 f |  |  j |  j |	 d  d  d  d  f |  d  S(   NR   R   R   R   (   R   R   R   R   R   R   R   R   R   R   R   R;   R   R   (   R	   R\   RH   R   RJ   RK   RL   R   R   R=   RA   R>   R?   R@   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   _delPackageFromIndexz  s    ((((%c         C   s6   |  j  |  j | j |  |  j r2 |  j |  n  d S(   s   delete a pkgobjectN(   R   R   R`   R   R   (   R	   R\   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR_     s    	c         C   s   g  } | d k r= xM |  j D] } | j |  j |  q Wn% y |  j | } Wn t k
 ra n X| r t | | | d d } | d | d } n  | S(   s2   return list of all packages, takes optional repoidR   s   repo-pkgkeyi    i   N(   R   R   R   t   KeyErrorR   (   R	   R`   Ra   Rb   t
   returnListR1   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR     s    	c         C   s)  i  } | rZ |  j  d d  |  j j | d d d d d f  } | sr t d |  qr n |  j d | d |  } x} | D]u } | j | j f | k r | | | j | j f <qy | | j | j f } | j |  ry | | | j | j f <qy qy W| r| | k r| | g St d |  n  | j	   S(   s  return list of newest packages based on name, arch matching
           this means(in name.arch form): foo.i386 and foo.noarch are not 
           compared to each other for highest version only foo.i386 and 
           foo.i386 will be compared
           Note that given: foo-1.i386; foo-2.i386 and foo-3.x86_64
           The last _two_ pkgs will be returned, not just one of them. R   R   i    s   No Package Matching %s.%sRa   Rb   N(
   R   R   R   R   R    R   R=   RA   t   verGTR   (   R	   Rw   Ra   Rb   t   highdictt   whereR   t   pkg2(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRx     s&    	%	c         C   s@  i  } | d k r3 | d k	 r3 |  j d |  } n |  j d | d |  } x | D] } | j | k rz | g | | j <qR | | j d } | j |  r | g | | j <n  | j |  rR | | j j |  qR qR W| r| | k r | | St d |  n  g  } x2 | j   D]$ }	 x |	 D] }
 | j |
  q!WqW| S(   s   return list of newest packages based on name matching
           this means(in name.arch form): foo.i386 and foo.noarch will
           be compared to each other for highest version.R=   Ra   Rb   i    s   No Package Matching  %sN(	   R   RB   R   R=   R   t   verEQR   R    R   (   R	   R=   Ra   Rb   R   R   R   R   t
   returnlistt   polstRF   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRy     s,    	c         C   s,   g  |  j  d | d t  D] } | j ^ q S(   sL   returns a list of pkg tuples (n, a, e, v, r) optionally from a single repoidRa   Rb   (   R   R   R;   (   R	   Ra   Rb   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyRz     s    c         C   s    x |  j    D] } | GHq Wd  S(   N(   R   (   R	   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR{     s    c         C   s:   x3 |  j    D]% } | j | k r |  j |  q q Wd S(   sD   exclude incompatible arches. archlist is a list of compatible archesN(   R   RA   R_   (   R	   R|   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR}     s    c   	      C   s   i  } x |  j    D] } g  } xB | D]: } t | |  } | r& | j |  r& | j |  q& q& Wt |  d k r | r | | |  n  | | | <q q W| S(   Ni    (   R   R   t   searchR   R   (	   R	   R~   R   R3   t   matchesRF   t	   tmpvaluest   fieldt   value(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR     s    N(   NNN(   NNN(%   R   R   R   R
   R    R   R   R0   R   RB   R   RE   RR   RS   R   RT   RU   RV   RW   RY   RZ   R[   R   R   R]   R^   R   R   R   R_   R   Rx   Ry   Rz   R{   R}   R   (    (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR   l  sD   		
																	$$		c         C   s   i  } x |  D]w } | j  } d } | | k rH | j | | d  } n  | d k rd | g | | <q | d k r | | j |  q q Wg  } x! | j   D] } | j |  q W| S(   st    Does the same as PackageSack.returnNewestByName().
        Note that given: foo-1.i386; foo-2.i386 and foo-3.x86_64i   i    (   R=   t   verCMPR   R   R   (   R   RX   R   R   t   cvalR$   t   vals(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR     s    	c         C   sb   i  } xO |  D]G } | j  | j f } | | k rJ | j | |  rJ q n  | | | <q W| j   S(   sz    Does the same as PackageSack.returnNewestByNameArch()
        The last _two_ pkgs will be returned, not just one of them.(   R=   RA   t   verLER   (   R   RX   R   R   (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR   "  s    t   ListPackageSackc           B   s#   e  Z d  Z d d  Z d   Z RS(   s   Derived class from PackageSack to build new Sack from list of
       pkgObjects - like one returned from self.returnNewestByNameArch()
       or self.returnNewestByName()c         C   s-   t  j |   | d  k	 r) |  j |  n  d  S(   N(   R   R
   R   t   addList(   R	   t   Objlist(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR
   2  s    c         C   s"   x | D] } |  j  |  q Wd  S(   N(   R]   (   R	   t   ObjListt   pkgobj(    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR  7  s    N(   R   R   R   R   R
   R  (    (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyR  -  s   (   R   t   ErrorsR    R7   t   ret   fnmatchR   t   packagesR   t   rpmUtils.miscutilsR   R   R   t   objectR   R   R   R   R   R  (    (    (    s3   /usr/lib/python2.7/site-packages/yum/packageSack.pyt   <module>   s$    2  		