
N_c           @   s   d  d l  Z  d  d l 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 f  d     YZ d f  d	     YZ d S(
   iN(   t   MetaSack(   t   proxyt   _wrap_ayum_getKeyForRepoc           B   s&   e  Z d  Z e d  Z d d  Z RS(   sc   This is a wrapper for calling YumBase.getKeyForRepo() because
        otherwise we take a real reference through the bound method and
        that is d00m (this applies to YumBase and RepoStorage, hence why
        we have a separate class).
        A "better" fix might be to explicitly pass the YumBase instance to
        the callback ... API change! c         C   s   t  |  |  _ | |  _ d  S(   N(   t   weakreft   ayumt   ca(   t   selfR   R   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   __init__$   s    c         C   s/   |  j  r |  j j | |  S|  j j | |  S(   N(   R   R   t   getCAKeyForRepot   getKeyForRepo(   R   t   repot   callback(    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   __call__'   s    	N(   t   __name__t
   __module__t   __doc__t   FalseR   t   NoneR   (    (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR      s   t   RepoStoragec           B   s   e  Z d  Z d   Z d   Z d d  Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z e e d  Z d   Z d   Z d   Z d   Z d   Z d   Z d d  Z d   Z d   Z d   Z d   Z d d d d d  Z RS(   sX   This class contains multiple repositories and core configuration data
       about them.c         C   s   i  |  _  d  |  _ d |  _ t   |  _ t j d  |  _ t	 |  _
 t |  |  _ t |  |  _ t | d t |  _ d  |  _ g  |  _ i  |  _ t	 |  _ d  S(   Ni    s   yum.RepoStorageR   (   t   reposR   R   t   cacheR    t   pkgSackt   loggingt	   getLoggert   loggerR   t   _setupR   R   R   t   gpg_import_funct   Truet   gpgca_import_funct   confirm_funct   _cache_enabled_repost   quick_enable_disablet   _list_enabled_hasrun(   R   R   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR   0   s    							c      	   C   s  t  t j d  s d Sg  } x |  j   D] } | j r> q) n  y | j oV | j |  } Wn; t j k
 r } | j	 s~   n  |  j
 | j  t } n X| r) | j   } | j |  } | j | | t g f  q) q) Wx t t f D] } xk | D]c \ } } } | d  }	 xE | D]= \ }
 } |
 j d k | k r| j | d t d |	 qqWq Wt j j   q Wx; | D]3 \ } } } | d r| j   qr| j |  qrWd S(   sX    Download metadata for all enabled repositories,
            based on mdpolicy.
        t   parallel_waitNc         S   s   t  | d <d  S(   Ni    (   R   (   t   objt   error(    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   failfuncf   s    t   asyncR$   i    (   t   hasattrt
   urlgrabbert   grabbert   listEnabledR   t   _asynct   _commonLoadRepoXMLt   Errorst	   RepoErrort   skip_if_unavailablet   disableRepot   idR   t   _mdpolicy2mdtypest   _commonRetrieveDataMD_listt   appendR   t   sizeR   t   _retrieveMDR!   t   _revertOldRepoXMLt   _commonRetrieveDataMD_done(   R   R   R
   t   dlt   et   mdtypest   downloadingt   no_sizeR#   R$   t   ndatat   nmdtype(    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   retrieveAllMDK   s8    		
 $
c   	   
   C   s  | d  k r |  j   n  |  j j j d  | d  k rG |  j   } n |  j |  } t |  d k  r{ |  j j d  n  t	 t
 j d  ri  } x{ |  j   D]j } | j r t j j | j  } | j | |  } | j | j k r
d } t j | | | f  q
q q Wn  x | D] } | j |  j j j |  j j d |  j d |  j d |  j | j st|  j | j  qt |  j j d	 d   } | r| | _ qqWt |  _  |  j!   |  j j j d
  d  S(   Nt   prereposetupi   s#   No Repositories Available to Set Upt   pycurls/   sslclientcert basename shared between %s and %sR   R   R   t   downloaddirt   postreposetup("   R   R)   R   t   pluginst   runt	   findRepost   lenR   t   debugR&   R'   R(   t   sslclientcertt   ost   patht   basenamet
   setdefaultR,   t   ConfigErrort   setupt   confR   t   mediagrabberR   R   R   t   enabledR/   R0   t   getattrt   pkgdirR   R   R?   (	   R   t   thisrepoR   t   cert_basenamesR
   t   bnt   othert   msgRT   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   doSetupt   s:    	#
		
c         C   s   t  |  j j    S(   N(   t   strR   t   keys(   R   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   __str__   s    c         C   sW   y |  j    WnB t j k
 rR } |  j j d t |  t |  |  j f  n Xd  S(   Ns   Exception %s %s in %s ignored(   t   closeR,   R-   R   RH   t   reprR[   t   __del__(   R   R9   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR`      s    c         C   s(   x! |  j  j   D] } | j   q Wd  S(   N(   R   t   valuesR^   (   R   R
   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR^      s    c         C   s   | j  |  j k r( t j d | j   n  | |  j | j  <t | d  ri |  j j | j  |  j | _ n	 d  |  _ t |  j	 d  s t
 | _ n |  j	 j | _ d  S(   Ns;   Repository %s is listed more than once in the configurationR   t   _override_sigchecks(   R0   R   R,   t   DuplicateRepoErrorR&   R   t   updateR   R   R   R   Rb   (   R   t   repoobj(    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   add   s    	c         C   s7   | |  j  k r3 |  j  | } | j   |  j  | =n  d  S(   N(   R   R^   (   R   t   repoidRU   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   delete   s    
c         C   s   |  j  j   } | j   | S(   N(   R   Ra   t   sort(   R   t   repolist(    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyRi      s    
c         C   s9   y |  j  | SWn# t k
 r4 } t j d |  n Xd  S(   Ns:   Error getting repository data for %s, repository not found(   R   t   KeyErrorR,   R-   (   R   Rg   R9   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   getRepo   s
    c   	      C   s   | |  j  k r |  j  | g Sg  } x | j d  D] } | j   } t j | j   |  } xs |  j  j   D]b \ } } | | j k s t  | |  r | j |  qm | rm | | j	  rm | j |  qm qm Wq3 W| S(   s    Find all repositories matching fnmatch `pattern` on the repo.id,
            can also do case insensitive searches and/or search on the name.t   ,(
   R   t   splitt   stript   misct   compile_patternt   itemsR0   t   AssertionErrorR3   t   name(	   R   t   patternt
   name_matcht   ignore_caset   resultt   itemt   matchRt   R
   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyRF      s    c         C   s   g  } t  j |  s* | j d  d k ra x] |  j |  D]  } | j | j  | j   q: Wn) |  j |  } | j | j  | j   | S(   s   disable a repository from use
        
        fnmatch wildcards may be used to disable a group of repositories.
        returns repoid of disabled repos as list
        Rm   i(   Rp   t   re_globt   findRF   R3   R0   t   disableRl   (   R   Rg   R   R
   RU   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR/      s    $
c         C   s   g  } t  j |  s* | j d  d k ra x] |  j |  D]  } | j | j  | j   q: Wn) |  j |  } | j | j  | j   | S(   s   enable a repository for use
        
        fnmatch wildcards may be used to enable a group of repositories.
        returns repoid of enables repos as list
        Rm   i(   Rp   R{   R|   RF   R3   R0   t   enableRl   (   R   Rg   R   R
   RU   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt
   enableRepo   s    $
c         C   s   |  j  s( |  j j j d  t |  _  n  |  j d k	 rH |  j rH |  j Sg  } x3 |  j j	   D]" } | j
   r^ | j |  q^ q^ W| j   |  j d k	 r | |  _ |  j j   n  | S(   s#   return list of enabled repo objectst   prelistenabledreposN(   R    R   RD   RE   R   R   R   R   R   Ra   t	   isEnabledR3   Ri   t   clear(   R   t
   returnlistR
   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR)     s    	

	c         C   s:   g  } x- |  j    D] } | j r | j |  q q W| S(   s6   return a list of repo objects that have groups enabled(   R)   t   enablegroupsR3   (   R   R   R
   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   listGroupsEnabled  s
    	c         C   s0   | |  _  x  |  j j   D] } | | _  q Wd S(   s   sets cache value in all reposN(   R   R   Ra   (   R   t   cachevalR
   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   setCache(  s    	c         C   sN   | |  _  x> |  j j   D]- } | | j k r | j | _ | | _ q q Wd S(   s$   sets the cachedir value in all reposN(   t	   _cachedirR   Ra   t   basecachedirt   old_base_cache_dir(   R   t   cachedirR
   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   setCacheDir.  s
    	c         C   s.   x' |  j  j   D] } | j | |  q Wd S(   s6   sets the progress bar for downloading files from reposN(   R   Ra   t   setCallback(   R   R"   t	   multi_objR
   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   setProgressBar8  s    c         C   s+   x$ |  j  j   D] } | j |  q Wd S(   s'   sets the failure callback for all reposN(   R   Ra   t   setFailureObj(   R   R"   R
   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   setFailureCallback>  s    c         C   s+   x$ |  j  j   D] } | j |  q Wd S(   s)   sets the failure callback for all mirrorsN(   R   Ra   t   setMirrorFailureObj(   R   R"   R
   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   setMirrorFailureCallbackD  s    c         C   s+   x$ |  j  j   D] } | j |  q Wd  S(   N(   R   Ra   t   setInterruptCallback(   R   R   R
   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR   J  s    c         C   s   |  j  S(   N(   R   (   R   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   getPackageSackN  s    RR   t   metadatai    c         C   s  |  j  s |  j   n  | s( |  j } n  g  } | d k rI |  j   } n | d k rg |  j j   } n t |  t j k r x | D]A } t	 | t
  r | j |  q |  j |  } | j |  q Wn4 t |  t j k r |  j |  } | j |  n  | d k rd d d g } n	 | g } t t j d  rxE | D]= } | j rTq?n  | j r?| j   }	 |	 j | |  q?q?Wt j j   n  x | D] } | j   }	 y |	 j | | | |  Wn t k
 r2}
 |
 j d j d  s  n  | d
 k r| j r|  j | j  qt j |
 j d   qt j k
 rr}
 | d k rl| j rl|  j | j  q  qX|  j j  | j |	  qWd	 S(   s   
        This populates the package sack from the repositories, two optional 
        arguments:
            - which='repoid, enabled, all'
            - mdtype='metadata, filelists, otherdata, all'
        RR   t   allR   t	   filelistst	   otherdataR!   i    t   ParsingN(   s   allR   (   s   allR   (!   R   RZ   R   R)   R   Ra   t   typet   typest   ListTypet
   isinstancet
   RepositoryR3   Rl   t
   StringTypeR&   R'   R(   R   R*   R   t   _retrieve_asyncR!   t   populatet	   TypeErrort   argst
   startswithR.   R/   R0   R,   R-   R   t   addSack(   R   t   whicht   mdtypeR   t	   cacheonlyt   myreposR
   t   repobjt   datat   sackR9   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   populateSackR  sX    				N(   R   R   R   R   R?   R   RZ   R]   R`   R^   Rf   Rh   Ri   Rl   R   RF   R/   R   R)   R   R   R   R   R   R   R   R   R   (    (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR   ,   s0   		),														
				R   c           B   s   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z e	 e  Z
 d   Z d   Z d	   Z d
   Z 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 RS(   s#   this is an actual repository objectc         C   s)   | |  _  i  |  _ |  j   t |  _ d  S(   N(   R0   R   R}   R   t   _xml2sqlite_local(   R   Rg   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR     s    		
c         C   s4   |  j  | j  k r d S|  j  | j  k  r, d Sd Sd S(   sf    Sort base class repos. by alphanumeric on their id, also
            see __cmp__ in YumRepository(). i   ii    N(   R0   (   R   RX   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   __cmp__  s
    c         C   s   |  j  S(   N(   R0   (   R   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR]     s    c         C   s   t  |  j  S(   N(   t   hashR0   (   R   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   __hash__  s    c         C   sW   y |  j    WnB t j k
 rR } |  j j d t |  t |  |  j f  n Xd  S(   Ns   Exception %s %s in %s ignored(   R^   R,   R-   R   RH   R_   R[   R`   (   R   R9   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR`     s    c         C   s   |  j  S(   s1    Show self.id, so we can use it and override it. (   R0   (   R   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   _ui_id  s    c         C   s   d  S(   N(    (   R   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR^     s    c         C   s   t  |  | |  d S(   s+   sets a generic attribute of this repositoryN(   t   setattr(   R   t   keyt   value(    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   setAttribute  s    c         C   s   t  |  | d   S(   N(   RS   R   (   R   R   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   getAttribute  s    c         C   s   |  j  d  } | d  k	 o | S(   NRR   (   R   R   (   R   RR   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR     s    c         C   s$   |  j  d d  t |  j |  j <d  S(   NRR   i   (   R   R   R   R0   (   R   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR~     s    c         C   s$   |  j  d d  t |  j |  j <d  S(   NRR   i    (   R   R   R   R0   (   R   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR}     s    c         C   s   |  j  d  } | p g  S(   Nt   exclude(   R   (   R   t   excludeList(    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   getExcludePkgList  s    c         C   s   |  j  d  } | p g  S(   Nt   includepkgs(   R   (   R   t   includeList(    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   getIncludePkgList  s    c         C   s   t     d  S(   N(   t   NotImplementedError(   R   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   ready  s    c         C   s   t     d  S(   N(   R   (   R   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   getGroupLocation  s    c         C   s   t     d  S(   N(   R   (   R   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR     s    c         C   s   t     d  S(   N(   R   (   R   R   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyRO     s    c         C   s   t     d  S(   N(   R   (   R   R   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR     s    c         C   s   t     d  S(   N(   R   (   R   R"   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR     s    c         C   s   t     d  S(   N(   R   (   R   R"   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR     s    c         C   s   t     d  S(   N(   R   (   R   t   packaget	   checkfunct   textR   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt
   getPackage  s    t   simplec         C   s   t     d  S(   N(   R   (   R   R   R   t   regetR   (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt	   getHeader  s    N(   R   R   R   R   R   R]   R   R`   R   t   propertyt   ui_idR^   R   R   R   R~   R}   R   R   R   R   R   RO   R   R   R   R   R   R   R   (    (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyR     s2   		
																			(   t   reR   R   Rp   RJ   R,   t   packageSackR    t   urlgrabber.grabberR'   R   R   R   R   R   (    (    (    s-   /usr/lib/python2.7/site-packages/yum/repos.pyt   <module>   s    h