³ò
à ŠHc           @   sy  d  d k  Z  d  d k l Z d  d k Z d  d k Z d  d k Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ	 d	 e
 f d
 „  ƒ  YZ d e
 f d „  ƒ  YZ d e f d „  ƒ  YZ d e
 f d „  ƒ  YZ d „  Z d „  Z e d j o|d GHe  i ƒ  e e i i ƒ  ƒ Z e i d e ƒ e i d e ƒ e i d ƒ GHe d Z e i GHe e ƒ GHx! e i ƒ  D] Z e e i Z quWe i ƒ  e i ƒ  Z  e e  ƒ GHx e  D] Z e i Z q´Wx8 d d g D]* Z! e i" i# e! ƒ p e i$ e! ƒ qÔqÔWe  i% i& d d ƒ e  i' e i( ƒ Z) e  i* e i i+ ƒ  ƒ Z, e i- e, e) ƒ d GHe e ƒ Z. e. i/ i d e ƒ e. i/ i d e ƒ e. i/ i ƒ  e. i0 e ƒ  ƒ e e. ƒ GHx! e. i ƒ  D] Z e. e i Z q»We e. ƒ GHd GHe d e ƒ  ƒ Z. e. i/ i d e ƒ e. i/ i d e ƒ e. i/ i ƒ  e. i0 e ƒ  ƒ e e. ƒ GHx! e. i ƒ  D] Z e. e i Z qOWe e. ƒ GHn d S(   iÿÿÿÿN(   t   Packaget   FetchCancelledExceptionc           B   s   e  Z d  Z RS(   sB    Exception that is thrown when the user cancels a fetch operation (   t   __name__t
   __module__t   __doc__(    (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyR      s   t   FetchFailedExceptionc           B   s   e  Z d  Z RS(   s.    Exception that is thrown when fetching fails (   R   R   R   (    (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyR      s   t   LockFailedExceptionc           B   s   e  Z d  Z RS(   s-    Exception that is thrown when locking fails (   R   R   R   (    (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyR   "   s   t   Cachec           B   sÔ   e  Z d  Z d d e d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d	 „  Z e d
 „ Z e d „  ƒ Z d „  Z d „  Z d d „ Z d „  Z d d d „ Z d „  Z d „  Z d „  Z RS(   sz    Dictionary-like package cache 
        This class has all the packages that are available in it's
        dictionary
    c         C   sm   h  |  _  | o t i i d d ƒ n | o. t i i d | ƒ t i i d | d ƒ n |  i | ƒ d  S(   Ns   Dir::Cache::pkgcachet    t   Dirs   Dir::State::statuss   /var/lib/dpkg/status(   t
   _callbackst   apt_pkgt   Configt   Sett   open(   t   selft   progresst   rootdirt   memonly(    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt   __init__,   s    	c         C   s:   |  i  i | ƒ o# x  |  i  | D] } | ƒ  q! Wn d S(   s#    internal helper to run a callback N(   R
   t   has_key(   R   t   namet   callback(    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt   _runCallbacks6   s     c         C   s  |  i  d ƒ t i | ƒ |  _ t i |  i ƒ |  _ t i |  i ƒ |  _ t i ƒ  |  _	 |  i	 i
 ƒ  h  |  _ | d j o d | _ n d } } t |  i i ƒ } x¬ |  i i D]ž } | d j o6 | d | j  o% | i | t | ƒ d ƒ | } n t | i ƒ d j o5 t |  i |  i |  i |  i	 |  | ƒ |  i | i <n | d 7} q± W| d j o | i ƒ  n |  i  d ƒ d S(   sY    Open the package cache, after that it can be used like
            a dictionary
        t   cache_pre_opens   Building data structuresi    id   i   t   cache_post_openN(   R   R   t   GetCachet   _cachet   GetDepCachet	   _depcachet   GetPkgRecordst   _recordst   GetPkgSourceListt   _listt   ReadMainListt   _dictt   Nonet   Opt   lent   Packagest   updatet   floatt   VersionListR    t   Namet   done(   R   R   t   it   lastt   sizet   pkg(    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyR   <   s0    	
 
c         C   s   |  i  | S(   s"    look like a dictionary (get key) (   R#   (   R   t   key(    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt   __getitem__\   s    c         c   s0   x# |  i  i ƒ  D] } |  i  | Vq Wt ‚ d  S(   N(   R#   t   keyst   StopIteration(   R   t   pkgname(    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt   __iter__`   s     c         C   s   |  i  i | ƒ S(   N(   R#   R   (   R   R1   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyR   e   s    c         C   s   t  |  i ƒ S(   N(   R&   R#   (   R   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt   __len__h   s    c         C   s   |  i  i ƒ  S(   N(   R#   R3   (   R   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyR3   k   s    c         C   st   g  } xg |  i  i ƒ  D]V } |  i  | } | i p( | i p | i p | i p
 | i o | i | ƒ q q W| S(   s    Get the marked changes (   R#   R3   t   markedUpgradet   markedInstallt   markedDeletet   markedDowngradet   markedReinstallt   append(   R   t   changesR   t   p(    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt
   getChangesn   s     c         C   s(   |  i  ƒ  |  i i | ƒ |  i ƒ  d S(   s]    Upgrade the all package, DistUpgrade will also install
            new dependencies
        N(   t   cachePreChangeR   t   Upgradet   cachePostChange(   R   t   distUpgrade(    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt   upgradex   s    
c         C   si   t  ƒ  } xY |  D]Q } | i o@ | i i t i j p | i i t i j o | i | i ƒ q q W| S(   sB    return the packages not downloadable packages in reqreinst state (	   t   sett   candidateDownloadablet   _pkgt	   InstStateR   t   InstStateReInstReqt   InstStateHoldReInstReqt   addR   (   R   t	   reqreinstR0   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt   reqReinstallPkgs€   s    	 c         C   s¸   | i  ƒ  } t } t } d } xb | i D]W } | i | i j o q( n | i o t } q( n | d | i | i f 7} t } q( W| | i	 j o t
 | ‚ n | o t | ‚ n | S(   NR   s   Failed to fetch %s %s
(   t   Runt   Falset   Itemst   Statust   StatDonet   StatIdlet   Truet   DescURIt	   ErrorTextt   ResultCancelledR   R   (   R   t   fetchert   rest   failedt	   transientt   errMsgt   item(    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt   _runFetcher‹   s$    
 

c         C   s   t  i i d ƒ d } t  i | ƒ } | d j  o t d | ‚ n z5 | i | |  i |  i ƒ p t Sn |  i	 | ƒ SWd t
 i | ƒ Xd S(   s    fetch the needed archives s   Dir::Cache::Archivest   locki    s   Failed to lock %sN(   R   R   t   FindDirt   GetLockR   t   GetArchivesR!   R   RP   R_   t   ost   close(   R   RY   t   pmt   lockfileR`   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt   _fetchArchives£   s    c         C   s’   t  i i d ƒ d } t  i | ƒ } | d j  o t d | ‚ n z: | d j o t i i ƒ  } n |  i	 i
 | |  i ƒ SWd t i | ƒ Xd S(   s&    run the equivalent of apt-get update s   Dir::State::ListsR`   i    s   Failed to lock %sN(   R   R   Ra   Rb   R   R$   t   aptR   t   FetchProgressR   t   UpdateR!   Rd   Re   (   R   t   fetchProgressRg   R`   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyR(   ¶   s    c         C   s'   | i  ƒ  | i | ƒ } | i ƒ  | S(   N(   t   startUpdatet   runt   finishUpdate(   R   Rf   t   installProgressRZ   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt   installArchivesÄ   s    

c         C   sÝ   | d j o t i i ƒ  } n | d j o t i i ƒ  } n t i |  i ƒ } t i | ƒ } xl t	 od |  i
 | | ƒ } |  i | | ƒ } | | i j o Pn | | i j o t d ‚ n | i ƒ  qd W| | i j S(   s'    Apply the marked changes to the cache s   installArchives() failedN(   R$   Ri   R   Rj   t   InstallProgressR   t   GetPackageManagerR   t
   GetAcquireRU   Rh   Rq   t   ResultCompletedt   ResultFailedt   SystemErrort   Shutdown(   R   Rl   Rp   Rf   RY   RZ   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt   commitÊ   s     	 c         C   s   |  i  d ƒ d S(   s@    called internally if the cache has changed, emit a signal then t   cache_post_changeN(   R   (   R   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyRC   é   s    c         C   s   |  i  d ƒ d S(   sS    called internally if the cache is about to change, emit
            a signal then t   cache_pre_changeN(   R   (   R   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyRA   í   s    c         C   s<   |  i  i | ƒ p g  |  i  | <n |  i  | i | ƒ d S(   sZ    connect to a signal, currently only used for
            cache_{post,pre}_{changed,open} N(   R
   R   R=   (   R   R   R   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt   connectò   s    N(   R   R   R   R$   RP   R   R   R   R2   R6   R   R7   R3   R@   RE   t   propertyRN   R_   Rh   R(   Rq   Ry   RC   RA   R|   (    (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyR   &   s(   
		 						
					t   Filterc           B   s   e  Z d  Z d „  Z RS(   s    Filter base class c         C   s   t  S(   sn    Filter function, return True if the package matchs a
            filter criteria and False otherwise
        (   RU   (   R   R0   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt   applyü   s    (   R   R   R   R   (    (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyR~   ú   s   t   MarkedChangesFilterc           B   s   e  Z d  Z d „  Z RS(   s(    Filter that returns all marked changes c         C   s.   | i  p | i p
 | i o t Sn t Sd  S(   N(   R9   R:   R8   RU   RP   (   R   R0   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyR     s    (   R   R   R   R   (    (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyR€     s   t   FilteredCachec           B   se   e  Z d  Z d
 d
 d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z RS(   sa    A package cache that is filtered.

        Can work on a existing cache or create a new one
    c         C   sk   | d  j o t | ƒ |  _ n
 | |  _ |  i i d |  i ƒ |  i i d |  i ƒ h  |  _ g  |  _ d  S(   NRz   R   (   R$   R   t   cacheR|   t   filterCachePostChanget	   _filteredt   _filters(   R   R‚   R   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyR     s    		c         C   s   t  |  i ƒ S(   N(   R&   R„   (   R   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyR7     s    c         C   s   |  i  i | S(   N(   R‚   R#   (   R   R1   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyR2     s    c         C   s   |  i  i ƒ  S(   N(   R„   R3   (   R   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyR3     s    c         C   s   |  i  i | ƒ S(   N(   R„   R   (   R   R1   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyR   !  s    c         C   sj   h  |  _  xZ |  i i i ƒ  D]F } x= |  i D]2 } | i |  i i | ƒ o d |  i  | <Pq, q, Wq Wd S(   s    internal helper to refilter i   N(   R„   R‚   R#   R3   R…   R   (   R   R0   t   f(    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt   _reapplyFilter$  s    	 
 c         C   s*   g  |  _  |  i  i | ƒ |  i i ƒ  d S(   s    set the current active filter N(   R…   R=   R‚   RC   (   R   t   filter(    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt	   setFilter-  s    	c         C   s   |  i  ƒ  d S(   s<    called internally if the cache changes, emit a signal then N(   R‡   (   R   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyRƒ   5  s    c         C   s6   |  i  i | ƒ o |  i  | Sn t |  i | ƒ Sd S(   s*    we try to look exactly like a real cache N(   t   __dict__R   t   getattrR‚   (   R   R1   (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt   __getattr__=  s    N(   R   R   R   R$   R   R7   R2   R3   R   R‡   R‰   Rƒ   RŒ   (    (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyR   
  s   									c           C   s	   d GHd  S(   Ns   cache pre changed(    (    (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt   cache_pre_changedF  s    c           C   s	   d GHd  S(   Ns   cache post changed(    (    (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pyt   cache_post_changedI  s    t   __main__s   Cache self testR{   Rz   t   aptitudes   /tmp/pytests   /tmp/pytest/partials   Dir::Cache::Archivess.   Testing filtered cache (argument is old cache)s$   Testing filtered cache (no argument)R   (1   R   Ri   R    t   apt.progressRd   t   syst   IOErrorR   R   R   t   objectR   R~   R€   R   R   RŽ   R   t   initR   t   OpTextProgresst   cR|   R   R?   R   R&   R3   R0   t   xRE   R@   R>   t   dt   patht   existst   mkdirR   R   Rs   R   Rf   Rt   t   TextFetchProgressRY   Rh   R†   R‚   R‰   (    (    (    s-   /usr/lib/python2.5/site-packages/apt/cache.pys   <module>   s|   Ô<		

 
    