
Nc        
   @   sS  d  d k  Z  d  d k Z d  d k Z d  d k l Z d  d k l Z d  d k l Z l	 Z	 l
 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 e f d     YZ d   Z d   Z d   Z e d j o e   n d S(   iN(   t   Package(   t   gettext(   t   AttributeDeprecatedByt   function_deprecated_byt   deprecated_argst   FetchCancelledExceptionc           B   s   e  Z d  Z RS(   sA   Exception that is thrown when the user cancels a fetch operation.(   t   __name__t
   __module__t   __doc__(    (    (    s-   /usr/lib/python2.6/dist-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.6/dist-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.6/dist-packages/apt/cache.pyR
   )   s   t   Cachec           B   s#  e  Z d  Z d$ d$ e 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 e d    Z e d    Z e d    Z d   Z d   Z d   Z d   Z e d$ d e d   Z e d    Z e d$ d$ d   Z d   Z d   Z d   Z  d   Z! d   Z" e d    Z# e d    Z$ e d    Z% e d     Z& e' i( o e) e  Z* e) e  Z+ e, d!  Z- e, d"  Z. e, d#  Z/ e) e  Z0 e) e  Z1 e) e  Z2 e) e  Z3 e) e  Z4 e) e  Z5 e) e   Z6 n RS(%   s  Dictionary-like package cache.

    This class has all the packages that are available in it's
    dictionary.

    Keyword arguments:
    progress -- a OpProgress object
    rootdir -- a alternative root directory. if that is given
               the system sources.list and system lists/ files are
               not read, only files relative to the given rootdir
    memonly -- build the cache in memory only
    c         C   s'  d  |  _ d  |  _ d  |  _ d  |  _ h  |  _ t i   |  _ t	   |  _
 | o t i i	 d d  n | o t i i | d  o t i t i | d  n t i i | d  o t i t i | d  n t i i	 d |  t i i	 d | d  |  i |  t i   n |  i |  d  S(   Ns   Dir::Cache::pkgcachet    s   /etc/apt/apt.confs   /etc/apt/apt.conf.dt   Dirs   Dir::State::statuss   /var/lib/dpkg/status(   t   Nonet   _cachet	   _depcachet   _recordst   _listt
   _callbackst   weakreft   WeakValueDictionaryt   _weakreft   sett   _sett   apt_pkgt   configt   ost   patht   existst   read_config_filet   isdirt   read_config_dirt   _check_and_create_required_dirst   init_systemt   open(   t   selft   progresst   rootdirt   memonly(    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   __init__;   s,    					c         C   s   d d g } d d d d g } xG | D]? } t  i i | |  p" d G| | GHt  i | |  q% q% Wx: | D]2 } t  i i | |  p t | | d  qo qo Wd	 S(
   sf   
        check if the required apt directories/files are there and if
        not create them
        s   /var/lib/dpkg/statuss   /etc/apt/sources.lists   /var/lib/dpkgs	   /etc/apt/s   /var/cache/apt/archives/partials   /var/lib/apt/lists/partials
   creating: t   wN(   R   R   R   t   makedirsR#   (   R$   R&   t   filest   dirst   dt   f(    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR!   X   s    		  c         C   s7   | |  i  j o# x  |  i  | D] } |   q Wn d S(   s#    internal helper to run a callback N(   R   (   R$   t   namet   callback(    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   _run_callbacksm   s     c         C   sy  | d j o t i i i   } n |  i d  t i |  |  _ t i	 |  i  |  _
 t i |  i  |  _ t i   |  _ |  i i   |  i i   |  i i   t d  | _ d } } t |  i i  } x |  i i D] } | d j	 o6 | d | j  o% | i | t |  d  | } n t | i  d j o |  i i | i  n | d 7} q W| i   |  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   t   aptR%   t   baset
   OpProgressR1   R   R   R   t   DepCacheR   t   PackageRecordsR   t
   SourceListR   t   read_main_listR   t   clearR   t   _t   opt   lent   packagest   updatet   floatt   version_listt   addR/   t   done(   R$   R%   t   it   lastt   sizet   pkg(    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR#   s   s.    
 

c         C   s{   y |  i  | SWne t j
 oY | |  i j o2 t |  } t |  |  i |  } |  i  | <| St d |   n Xd S(   s"    look like a dictionary (get key) s!   The cache has no package named %rN(   R   t   KeyErrorR   t   strR    R   (   R$   t   keyRH   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   __getitem__   s    !c         c   s'   x |  i  D] } |  | Vq
 Wt  d  S(   N(   R   t   StopIteration(   R$   t   pkgname(    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   __iter__   s    
 c         C   s   | |  i  j S(   N(   R   (   R$   RK   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   has_key   s    c         C   s   | |  i  j S(   N(   R   (   R$   RK   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   __contains__   s    c         C   s   t  |  i  S(   N(   R>   R   (   R$   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   __len__   s    c         C   s   t  |  i  S(   N(   t   listR   (   R$   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   keys   s    c         C   s^   g  } xQ |  D]I } | i  p( | i p | i p | i p
 | i o | i |  q q W| S(   s    Get the marked changes (   t   marked_upgradet   marked_installt   marked_deletet   marked_downgradet   marked_reinstallt   append(   R$   t   changesRH   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   get_changes   s     c         C   s(   |  i    |  i i |  |  i   d S(   s   Upgrade all packages.

        If the parameter *dist_upgrade* is True, new dependencies will be
        installed as well (and conflicting packages may be removed). The
        default value is False.
        N(   t   cache_pre_changeR   t   upgradet   cache_post_change(   R$   t   dist_upgrade(    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR^      s    
c         C   s>   t  i |  i  } t  i   } | i | |  i |  i  | i S(   s;   Get the size of the packages that are required to download.(   R   t   PackageManagerR   t   Acquiret   get_archivesR   R   t   fetch_needed(   R$   t   pmt   fetcher(    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   required_download   s    c         C   s
   |  i  i S(   s8   Get the size of the additional required space on the fs.(   R   t   usr_size(   R$   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   required_space   s    c         C   sl   t    } x\ |  D]T } | i i o@ | i i t i j p | i i t i j o | i | i	  q q W| S(   sA   Return the packages not downloadable packages in reqreinst state.(
   R   t	   candidatet   downloadablet   _pkgt
   inst_stateR   t   INSTSTATE_REINSTREQt   INSTSTATE_HOLD_REINSTREQRC   R/   (   R$   t	   reqreinstRH   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   req_reinstall_pkgs   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	   STAT_DONEt	   STAT_IDLEt   Truet   desc_urit
   error_textt   RESULT_CANCELLEDR   R	   (   R$   Rf   t   rest   failedt	   transientt   err_msgt   item(    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   _run_fetcher   s&    
 

c         C   s   t  i i d  d } t  i |  } | d j  o t d |   n z2 | i | |  i |  i  p t S|  i	 |  SWd t
 i |  Xd S(   s    fetch the needed archives s   Dir::Cache::Archivest   locki    s   Failed to lock %sN(   R   R   t   find_dirt   get_lockR
   Rc   R   R   Rs   R   R   t   close(   R$   Rf   Re   t   lockfileR   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   _fetch_archives   s    c         C   sD   y |  i  | } Wn t j
 o t SXt | i o | i  Sd S(   s0   Return whether the package is a virtual package.N(   R   RI   Rs   t   boolt   provides_listRB   (   R$   RN   RH   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   is_virtual_package	  s
    c         C   s   g  } y, |  i  | } t | i  d j o | SWn t j
 o | SXxm |  D]e } |  i i | i  } | d j o qP n x3 | i D]( } | | d j o | i	 |  q q WqP W| S(   sk   
        Return a list of packages which provide the virtual package of the
        specified name
        i    N(
   R   R>   RB   RI   R   t   get_candidate_verRl   R   R   RZ   (   R$   t   virtualt	   providerst   vpRH   t   vt   p(    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   get_providing_packages  s"    	 
 i    c      
   C   s   t  i i d  d } t  i |  } | d j  o t d |   n z | d j o t i i i	   } n y |  i
 i | |  i |  } Wn! t j
 o } t |   n X| o | o t    n | SWd t i |  Xd S(   s   Run the equivalent of apt-get update.

        The first parameter *fetch_progress* may be set to an instance of
        apt.progress.FetchProgress, the default is apt.progress.FetchProgress()
        .
        s   Dir::State::ListsR   i    s   Failed to lock %sN(   R   R   R   R   R
   R   R4   R%   R5   t   AcquireProgressR   R@   R   t   SystemErrorR	   R   R   (   R$   t   fetch_progresst   pulse_intervalt   raise_on_errorR   R   R|   t   e(    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR@   (  s     	c         C   so   y | i    Wn t j
 o | i   n X| i |  } y | i   Wn t j
 o | i   n X| S(   s   
        The first parameter *pm* refers to an object returned by
        apt_pkg.PackageManager().

        The second parameter *install_progress* refers to an InstallProgress()
        object of the module apt.progress.
        (   t   startUpdatet   AttributeErrort   start_updateRr   t   finishUpdatet   finish_update(   R$   Re   t   install_progressR|   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   install_archivesF  s    
c         C   s
  | d j o t i i i   } n | d j o t i i i   } n t i |  i  } t i	 |  } x t
 o |  i | |  } |  i | |  } | | i j o PnE | | i j o t d   n% | | i j o n t d |   | i   qj W| | i j S(   sC  Apply the marked changes to the cache.

        The first parameter, *fetch_progress*, refers to a FetchProgress()
        object as found in apt.progress, the default being
        apt.progress.FetchProgress().

        The second parameter, *install_progress*, is a
        apt.progress.InstallProgress() object.
        s   installArchives() faileds<   internal-error: unknown result code from InstallArchives: %sN(   R   R4   R%   R5   R   t   InstallProgressR   Ra   R   Rb   Rx   R   R   t   RESULT_COMPLETEDt   RESULT_FAILEDR   t   RESULT_INCOMPLETEt   shutdown(   R$   R   R   Re   Rf   R|   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   commit[  s(     
c         C   s   |  i  i   d S(   s    Unmark all changes N(   R   t   init(   R$   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR;     s    c         C   s   |  i  d  d S(   s@    called internally if the cache has changed, emit a signal then R_   N(   R1   (   R$   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR_     s    c         C   s   |  i  d  d S(   sS    called internally if the cache is about to change, emit
            a signal then R]   N(   R1   (   R$   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR]     s    c         C   s9   | |  i  j o g  |  i  | <n |  i  | i |  d S(   sZ    connect to a signal, currently only used for
            cache_{post,pre}_{changed,open} N(   R   RZ   (   R$   R/   R0   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   connect  s    c         C   s   t  i |  i  S(   s  Return an ActionGroup() object for the current cache.

        Action groups can be used to speedup actions. The action group is
        active as soon as it is created, and disabled when the object is
        deleted or when release() is called.

        You can use the action group as a context manager, this is the
        recommended way::

            with cache.actiongroup():
                for package in my_selected_packages:
                    package.mark_install()

        This way, the ActionGroup is automatically released as soon as the
        with statement block is left. It also has the benefit of making it
        clear which parts of the code run with a action group and which
        don't.
        (   R   t   ActionGroupR   (   R$   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   actiongroup  s    c         C   s
   |  i  i S(   s7   Return the number of packages with broken dependencies.(   R   t   broken_count(   R$   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR     s    c         C   s
   |  i  i S(   s2   Return the number of packages marked for deletion.(   R   t	   del_count(   R$   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   delete_count  s    c         C   s
   |  i  i S(   s6   Return the number of packages marked for installation.(   R   t
   inst_count(   R$   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   install_count  s    c         C   s
   |  i  i S(   s-   Return the number of packages marked as keep.(   R   t
   keep_count(   R$   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR     s    Rg   Ri   Rq   N(7   R   R   R   R   Rs   R(   R!   R1   R#   RL   RO   RP   RQ   RR   RT   R\   R   R^   t   propertyRg   Ri   Rq   R   R   R   R   Rx   R@   R   R   R;   R_   R]   R   R   R   R   R   R   R   t   _COMPAT_0_7R   t   _runCallbackst
   getChangesR   t   requiredDownloadt   additionalRequiredSpacet   reqReinstallPkgst   _runFetchert   _fetchArchivest   isVirtualPackaget   getProvidingPackagest   installArchivest   cachePostChanget   cachePreChange(    (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR   -   sb   		 													+					
t   ProblemResolverc           B   sM   e  Z d  Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 RS(   su   Resolve problems due to dependencies and conflicts.

    The first argument 'cache' is an instance of apt.Cache.
    c         C   s   t  i | i  |  _ d  S(   N(   R   R   R   t	   _resolver(   R$   t   cache(    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR(     s    c         C   s   |  i  i | i  d S(   s'   Reset the package to the default state.N(   R   R;   Rl   (   R$   t   package(    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR;     s    c         C   s   |  i  i   d S(   s/   mark protected packages for install or removal.N(   R   t   install_protect(   R$   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR     s    c         C   s   |  i  i | i  d S(   s)   Protect a package so it won't be removed.N(   R   t   protectRl   (   R$   R   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR     s    c         C   s   |  i  i | i  d S(   s   Mark a package for removal.N(   R   t   removeRl   (   R$   R   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR     s    c         C   s   |  i  i   d S(   s:   Resolve dependencies, try to remove packages where needed.N(   R   t   resolve(   R$   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR     s    c         C   s   |  i  i   d S(   s4   Resolve dependencies, do not try to remove packages.N(   R   t   resolve_by_keep(   R$   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR     s    (
   R   R   R   R(   R;   R   R   R   R   R   (    (    (    s-   /usr/lib/python2.6/dist-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
        (   Rx   (   R$   RH   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   apply  s    (   R   R   R   R   (    (    (    s-   /usr/lib/python2.6/dist-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 St Sd  S(   N(   RV   RW   RU   Rx   Rs   (   R$   RH   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR     s    (   R   R   R   R   (    (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR     s   t   FilteredCachec           B   s   e  Z d  Z d d d  Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z e i o( e e  Z e e  Z e e  Z n 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(   NR_   R3   (   R   R   R   R   t   filter_cache_post_changet	   _filteredt   _filters(   R$   R   R%   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR(     s    		c         C   s   t  |  i  S(   N(   R>   R   (   R$   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyRR     s    c         C   s   |  i  | S(   N(   R   (   R$   RK   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyRL   !  s    c         c   s$   x |  i  D] } |  i | Vq
 Wd  S(   N(   R   R   (   R$   RN   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyRO   $  s    
 c         C   s   |  i  i   S(   N(   R   RT   (   R$   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyRT   (  s    c         C   s   | |  i  j S(   N(   R   (   R$   RK   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyRP   +  s    c         C   s   | |  i  j S(   N(   R   (   R$   RK   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyRQ   .  s    c         C   sZ   h  |  _  xJ |  i D]? } x6 |  i D]+ } | i |  o d |  i  | i <Pq# q# Wq Wd S(   s    internal helper to refilter i   N(   R   R   R   R   R/   (   R$   RH   R.   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   _reapply_filter1  s    	
 
 c         C   s*   g  |  _  |  i  i |  |  i i   d S(   s   Set the current active filter.N(   R   RZ   R   R_   (   R$   t   filter(    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt
   set_filter:  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.6/dist-packages/apt/cache.pyR   B  s    c         C   s   t  |  i |  S(   s)   we try to look exactly like a real cache.(   t   getattrR   (   R$   RK   (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   __getattr__K  s    N(   R   R   R   R   R(   RR   RL   RO   RT   RP   RQ   R   R   R   R   R   R   R   t   _reapplyFiltert	   setFiltert   filterCachePostChange(    (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyR     s"   
												
c           C   s	   d GHd  S(   Ns   cache pre changed(    (    (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   cache_pre_changedW  s    c           C   s	   d GHd  S(   Ns   cache post changed(    (    (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   cache_post_changed[  s    c          C   s  d GHt  i   t t i i i    }  |  i d t  |  i d t	  d |  j GH|  d } | i
 GHt |   GHx/ |  i   D]! } |  | i
 | j p t  q| W|  i   |  i   } t |  GHx | D] } | i
 p t  q Wx8 d d g D]* } t i i |  p t i |  q q Wt  i i d d  t  i |  i  } t  i t i i i    } |  i | |  d GHt |   } | i i d t  | i i d t	  | i i   | i t    t |  GHx/ | i   D]! } | | | i
 j p t  qWt |  GHd	 GHt d
 t i i i    } | i i d t  | i i d t	  | i i   | i t    t |  GHx/ | i   D]! } | | | i
 j p t  qWt |  GHd S(   s   Internal test code.s   Cache self testR]   R_   t   aptitudes   /tmp/pytests   /tmp/pytest/partials   Dir::Cache::Archivess.   Testing filtered cache (argument is old cache)s$   Testing filtered cache (no argument)R%   N(    R   R   R   R4   R%   t   textR6   R   R   R   R/   R>   RT   t   AssertionErrorR^   R\   R   R   R   t   mkdirR   R   Ra   R   Rb   R   R   R   R   R   R   R5   (   R   RH   RN   R[   t   dirnameRe   Rf   t   filtered(    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   _test_  s`    

 
    t   __main__(   R   R   R   R4   R    R   R<   t   apt.deprecationR   R   R   t   apt.progress.textt   IOErrorR   R	   R
   t   objectR   R   R   R   R   R   R   R   R   (    (    (    s-   /usr/lib/python2.6/dist-packages/apt/cache.pyt   <module>   s(    %

I			8