
 Hc           @   s  d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k Z d   Z d e f d     YZ d e f d     YZ d e f d     YZ	 d	 e f d
     YZ
 e d j o%d GHe  i   e  i   Z e  i e  Z e  i e  Z e  i   Z e d Z e
 e e e e e e  Z d e i GHd e i GHd e i GHd e i GHd e i GHd e i GHd e i GHd e i GHd e i  GHd e i! GHd e i" GHd e i# GHd e i$ GHd e i% GHd e i& GHd e i' GHxY e i( D]N Z) d i* g  Z+ e) i, D]) Z- e+ d e- i e- i. e- i/ e- i0 f q[+  GHqWd  e i1 GHd! e i2 GHd" Ge i3 GHd  d k4 Z4 e4 i5 i6   Z5 e4 i7 e5  Z x e8 e9 g D] Z: d# e: GHxV e i;   D]H Z e e Z e i< o. e i= d$ d%  d% j o e i> e:  n n qWd& e i? i@ GHd' e i? iA GHqWHx e8 e9 g D] Z: d( e: GHe4 i7 e5  Z xe e i;   D]W Z e i= d$ d%  d% j o8 y e e iB e:  Wn eC j
 o d) e GHn Xn qNWd& e i? i@ GHd* e i? iD GHq#Wn d S(+   iNc         C   s   t  i d |   S(   Ns
   python-apt(   t   gettextt   dgettext(   t   s(    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   _   s    t   BaseDependencyc           B   s   e  Z d  Z d   Z RS(   s    a single dependency c         C   s(   | |  _  | |  _ | |  _ | |  _ d  S(   N(   t   namet   relationt   versiont	   preDepend(   t   selfR   t   relt   vert   pre(    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   __init__!   s    			(   t   __name__t
   __module__t   __doc__R   (    (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyR      s   t
   Dependencyc           B   s   e  Z d    Z RS(   c         C   s   | |  _  d  S(   N(   t   or_dependencies(   R	   t   alternatives(    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyR   (   s    (   R   R   R   (    (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyR   '   s   t   Recordc           B   s2   e  Z d  Z d   Z d   Z d   Z d   Z RS(   s    represents a pkgRecord, can be accessed like a
        dictionary and gives the original package record
        if accessed as a string c         C   s   | |  _  t i |  |  _ d  S(   N(   t   _strt   apt_pkgt   ParseSectiont   _rec(   R	   R   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyR   /   s    	c         C   s   |  i  S(   N(   R   (   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   __str__2   s    c         C   s-   |  i  i |  } | d  j o
 t  n | S(   N(   R   t   gett   Nonet   KeyError(   R	   t   keyt   k(    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   __getitem__4   s    
c         C   s   |  i  i |  S(   N(   R   t   has_key(   R	   R   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyR    9   s    (   R   R   R   R   R   R   R    (    (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyR   +   s
   			t   Packagec           B   sB  e  Z d  Z d   Z e d  Z d   Z e e  Z d   Z e e  Z d   Z	 e e	  Z	 d   Z
 e e
  Z
 d   Z d   Z e e  Z d	   Z e e  Z d
   Z e e  Z e d  Z d   Z e e  Z d   Z e e  Z d   Z e e  Z d   Z e e  Z d   Z e e  Z d   Z e e  Z d   Z e e  Z d   Z e e  Z e d  Z e e  Z d   Z e e  Z d   Z e e  Z d   Z e e  Z d   Z e e  Z d   Z e e  Z d   Z e e  Z d   Z e e  Z d   Z  e e   Z  d   Z! e e!  Z! d   Z" e e"  Z" d   Z# e e#  Z# d    Z$ e e$  Z$ d!   Z% e e%  Z% d"   Z& e e&  Z& e d#  Z' e e'  Z' d$   Z( e e(  Z( d% d- d&     YZ) d'   Z* e e*  Z* d(   Z+ e e, d)  Z- e e e d*  Z. d+   Z/ d,   Z0 RS(.   s2    This class represents a package in the cache
    c         C   s:   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ d S(   s    Init the Package object N(   t   _cachet	   _depcachet   _recordst   _pkgt   _listt   _pcache(   R	   t   cachet   depcachet   recordst
   sourcelistt   pcachet   pkgiter(    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyR   ?   s    						c         C   s   | o |  i  i |  i  } n |  i i } | d j o t Sn | i d j o d |  i i   GHt Sn | i i d  \ } } |  i	 i
 | | f  t S(   sv    internal helper that moves the Records to the right
            position, must be called before _records is accessed s   No FileList for: %s i    N(   R#   t   GetCandidateVerR%   t
   CurrentVerR   t   Falset   FileListt   Namet   popR$   t   Lookupt   True(   R	   t   UseCandidateR   t   ft   index(    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   _lookupRecordJ   s    c         C   s
   |  i  i S(   s     Return the name of the package (   R%   R2   (   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyR   d   s    c         C   s
   |  i  i S(   se    Return a uniq ID for the pkg, can be used to store
            additional information about the pkg (   R%   t   ID(   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   idi   s    c         C   s,   |  i  i } | d j o | i Sn d Sd S(   s(    Return the installed version as string N(   R%   R/   R   t   VerStr(   R	   R   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   installedVersiono   s    c         C   s5   |  i  i |  i  } | d j o | i Sn d Sd S(   s(    Return the candidate version as string N(   R#   R.   R%   R   R<   (   R	   R   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   candidateVersionx   s    c      
   C   s   g  } | i  } x d d g D] } | i |  p q n xj | | D]^ } g  } x< | D]4 } | i t | i i | i | i | d j   qW W| i t |   qD Wq W| S(   Nt
   PreDependst   Depends(	   t   DependsListR    t   appendR   t	   TargetPkgR2   t   CompTypet	   TargetVerR   (   R	   R   t   depends_listt   dependst   tt
   depVerListt	   base_depst   depOr(    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   _getDependencies   s    	   2c         C   s7   |  i  i |  i  } | d j o g  Sn |  i |  S(   s)    return a list of candidate dependencies N(   R#   R.   R%   R   RL   (   R	   t   candver(    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   candidateDependencies   s    c         C   s.   |  i  i } | d j o g  Sn |  i |  S(   s)    return a list of installed dependencies N(   R%   R/   R   RL   (   R	   R   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   installedDependencies   s    c         C   sJ   |  i    p d  Sn t i |  i i  } | i d  o | d Sn d  S(   Nt   Architecture(   R9   R   R   R   R$   R   R    (   R	   t   sec(    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   architecture   s    c         C   sH   | o |  i  i |  i  } n |  i i } | d j o t Sn | i S(   s/    helper, return if the version is downloadable N(   R#   R.   R%   R/   R   R0   t   Downloadable(   R	   t   useCandidateR   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   _downloadable   s    c         C   s   |  i  d t  S(   s)    returns if the canidate is downloadable RT   (   RU   R5   (   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   candidateDownloadable   s    c         C   s   |  i  d t  S(   s2    returns if the installed version is downloadable RT   (   RU   R0   (   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   installedDownloadable   s    c         C   sD   |  i    p d Sn |  i i } | d j o | Sn |  i i Sd S(   s*    Return the source package name as string t    N(   R9   R   R$   t	   SourcePkgR%   R2   (   R	   t   src(    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   sourcePackageName   s    c         C   s   |  i    p d Sn |  i i S(   s%    Return the homepage field as string N(   R9   R   R$   t   Homepage(   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   homepage   s    c         C   s
   |  i  i S(   s"    Return the section of the package(   R%   t   Section(   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   section   s    c         C   s/   |  i  i |  i  } | o | i Sn d Sd S(   s/    Return the priority (of the candidate version)N(   R#   R.   R%   t   PriorityStrR   (   R	   R   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   priority   s    c         C   s/   |  i  i |  i  } | o | i Sn d Sd S(   s/    Return the priority (of the installed version)N(   R#   R.   R%   R`   R   (   R	   R   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   installedPriority   s    c         C   sY   |  i    p d Sn |  i i |  i  } | i } |  i i | i i d   |  i i	 S(   s1    Return the short description (one line summary) RX   i    (
   R9   R#   R.   R%   t   TranslatedDescriptionR$   R4   R1   R3   t	   ShortDesc(   R	   R   t	   desc_iter(    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   summary   s    	c   	      C   s   |  i    p d Sn |  i i |  i  } | i } |  i i | i i d   d } y t	 |  i i
 d  } Wn. t j
 o" } t d  |  i | f } n XxR t i | d  D]> } t i |  } | d j o | d 7} q | | d 7} q W| S(   s&    Return the formated long description RX   i    s   utf-8s<   Invalid unicode in description for '%s' (%s). Please report.s   
t   .(   R9   R#   R.   R%   Rc   R$   R4   R1   R3   t   unicodet   LongDesct   UnicodeDecodeErrorR   R   t   stringt   splitt   strip(	   R	   t   formatR   Re   t   descR   t   et   linet   tmp(    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   description   s$    		 c         C   s   |  i    p d Sn |  i i S(   s"    return the long description (raw)RX   (   R9   R$   Ri   (   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   rawDescription  s    c         C   s(   |  i  t  p d Sn t |  i i  S(   s>    return the full pkgrecord as string of the candidate version N(   R9   R5   R   R   R$   (   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   candidateRecord  s    c         C   s(   |  i  t  p d Sn t |  i i  S(   s>    return the full pkgrecord as string of the installed version N(   R9   R0   R   R   R$   (   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   installedRecord  s    c         C   s   |  i  i |  i  S(   s    Package is marked for install (   R#   t   MarkedInstallR%   (   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   markedInstall  s    c         C   s   |  i  i |  i  S(   s    Package is marked for upgrade (   R#   t   MarkedUpgradeR%   (   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   markedUpgrade  s    c         C   s   |  i  i |  i  S(   s    Package is marked for delete (   R#   t   MarkedDeleteR%   (   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   markedDelete$  s    c         C   s   |  i  i |  i  S(   s    Package is marked for keep (   R#   t
   MarkedKeepR%   (   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt
   markedKeep)  s    c         C   s   |  i  i |  i  S(   s!    Package is marked for downgrade (   R#   t   MarkedDowngradeR%   (   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   markedDowngrade.  s    c         C   s   |  i  i |  i  S(   s!    Package is marked for reinstall (   R#   t   MarkedReinstallR%   (   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   markedReinstall3  s    c         C   s   |  i  i d j S(   s    Package is installed N(   R%   R/   R   (   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   isInstalled8  s    c         C   s   |  i  o |  i i |  i  S(   s    Package is upgradable (   R   R#   t   IsUpgradableR%   (   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   isUpgradable=  s    c         C   s   |  i  o |  i i |  i  S(   sc    
        Package is installed as a automatic dependency and is
        no longer required
        (   R   R#   t	   IsGarbageR%   (   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   isAutoRemovableB  s    c         C   s   |  i  i |  i  } | i S(   s'    The size of the candidate deb package (   R#   R.   R%   t   Size(   R	   R   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   packageSizeK  s    c         C   s   |  i  i } | i S(   s'    The size of the installed deb package (   R%   R/   R   (   R	   R   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   installedPackageSizeQ  s    c         C   s   |  i  i |  i  } d S(   s-    The size of the candidate installed package N(   R#   R.   R%   (   R	   R6   R   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   candidateInstalledSizeW  s    c         C   s(   |  i  i } | d j o d Sn | i S(   s-    The size of the currently installed package i    N(   R%   R/   R   t   InstalledSize(   R	   R   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   installedSize\  s    t   Originc           B   s   e  Z d    Z d   Z RS(   c         C   sy   | i  |  _ | i |  _ | i |  _ | i |  _ | i |  _	 | i
 i |  } | o | i o t |  _ n
 t |  _ d  S(   N(   t	   Componentt	   componentt   Archivet   archiveR   t   origint   Labelt   labelt   Sitet   siteR&   t	   FindIndext	   IsTrustedR5   t   trustedR0   (   R	   t   pkgt   VerFileItert	   indexfile(    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyR   f  s    c         C   s,   d |  i  |  i |  i |  i |  i |  i f S(   NsP   component: '%s' archive: '%s' origin: '%s' label: '%s' site '%s' isTrusted: '%s'(   R   R   R   R   R   R   (   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   __repr__r  s    (   R   R   R   R   (    (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyR   e  s   	c         C   sa   |  i  i |  i  } | p d  Sn g  } x0 | i D]% \ } } | i |  i |  |   q4 W| S(   N(   R#   R.   R%   R   R1   RB   R   (   R	   R   t   originst   verFileIterR8   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   candidateOriginx  s    
 c         C   s1   |  i  i   |  i i |  i  |  i  i   d S(   s    mark a package for keep N(   R'   t   cachePreChangeR#   t   MarkKeepR%   t   cachePostChange(   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   markKeep  s    c         C   s   |  i  i   |  i i |  i |  | om |  i i d j oZ t i |  i  } | i |  i  | i	 |  i  | i
 |  i  | i   | i   n |  i  i   d S(   s    mark a package for delete. Run the resolver if autoFix is set.
            Mark the package as purge (remove with configuration) if 'purge'
            is set.
            i    N(   R'   R   R#   t
   MarkDeleteR%   t   BrokenCountR   t   GetPkgProblemResolvert   Cleart   Protectt   Removet   InstallProtectt   ResolveR   (   R	   t   autoFixt   purget   Fix(    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt
   markDelete  s    
c         C   s   |  i  i   |  i i |  i | |  | oV |  i i d j oC t i |  i  } | i |  i  | i	 |  i  | i
 t  n |  i  i   d S(   s    mark a package for install. Run the resolver if autoFix is set,
            automatically install required dependencies if autoInst is set
            record it as automatically installed when fromuser is set to false
        i    N(   R'   R   R#   t   MarkInstallR%   R   R   R   R   R   R   R5   R   (   R	   R   t   autoInstt   fromUsert   fixer(    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   markInstall  s    c         C   s6   |  i  o |  i   n t i i d |  i i  d S(   s    mark a package for upgrade s1   MarkUpgrade() called on a non-upgrable pkg: '%s'
N(   R   R   t   syst   stderrt   writeR%   R2   (   R	   (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   markUpgrade  s    
c         C   s   |  i  i | |  d S(   se    commit the changes, need a FetchProgress and InstallProgress
            object as argument
        N(   R#   t   Commit(   R	   t	   fprogresst	   iprogress(    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyt   commit  s    (    (1   R   R   R   R   R5   R9   R   t   propertyR;   R=   R>   RL   RN   RO   RR   RU   RV   RW   R[   R]   R_   Ra   Rb   Rf   Rs   Rt   Ru   Rv   Rx   Rz   R|   R~   R   R   R   R   R   R   R   R   R   R   R   R   R0   R   R   R   R   (    (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pyR!   <   s   																																					t   __main__s   Self-test for the Package moduls	   apt-utilss	   Name: %s s   ID: %s s   Priority (Candidate): %s s   Priority (Installed): %s s   Installed: %s s   Candidate: %s s   CandidateDownloadable: %ss   CandidateOrigins: %ss   SourcePkg: %s s   Section: %s s   Summary: %ss   Description (formated) :
%ss   Description (unformated):
%ss   InstalledSize: %s s   PackageSize: %s s   Dependencies: %st   ,s   %s (%s) (%s) (%s)s   arch: %ss   homepage: %ss   rec: s;   Running install on random upgradable pkgs with AutoFix: %s i    i   s   Broken: %s s   InstCount: %s s.   Randomly remove some packages with AutoFix: %ss   Error trying to remove: %s s   DelCount: %s (E   R   R   t   randomRk   R    R   t   objectR   R   R   R!   R   t   initt   GetCacheR(   t   GetDepCacheR)   t   GetPkgRecordsR*   t   GetPkgSourceListR+   R-   R   R   R   R;   Ra   Rb   R=   R>   RV   R   R[   R_   Rf   Rs   Rt   R   R   RO   RN   t   dept   joint   _[1]R   t   oR   R   R   RR   R]   Ru   t   aptt   progresst   OpTextProgresst   CacheR5   R0   t   it   keysR   t   randintR   R#   R   t	   InstCountR   t   SystemErrort   DelCount(    (    (    s/   /usr/lib/python2.5/site-packages/apt/package.pys   <module>   s   	 {


 L 	 

 	 