s_c@s&dZddlmZddlZddlZddlZddlZddlZy4ddlm Z ddl m Z ddl m Z Wn7ek rddlm Z ddlm Z m Z nXddlmZmZddlZddlZdd lmZd d d d dddfZejjdkr4eZndZdefdYZ de fdYZ!d e"fdYZ#d e$fdYZ%d e"fdYZ&defdYZ'de"fdYZ(defdYZ)d e"fdYZ*dZ+e,dkr"e+ndS( s"Functionality related to packages.i(tprint_functionN(t BadStatusLine(t HTTPError(turlopen(RR(tMappingtSequence(tgettexttBaseDependencyt DependencytOrigintPackagetRecordtVersiont VersionListicCs\tjj|rXtjj||krXt|}tj|j|kSWdQXntS(s(Return ``True`` if the file is the same.N( tostpathtexiststgetsizetopentapt_pkgtHashesthashestFalse(RtsizeRtfobj((s//usr/lib/python2.7/dist-packages/apt/package.pyt _file_is_same4s*t FetchErrorcBseZdZRS(s(Raised when a file could not be fetched.(t__name__t __module__t__doc__(((s//usr/lib/python2.7/dist-packages/apt/package.pyR<stUntrustedErrorcBseZdZRS(s/Raised when a file did not have a trusted hash.(RRR(((s//usr/lib/python2.7/dist-packages/apt/package.pyR@scBseZdZdefdYZdZdZdZedZ edZ edZ ed Z ed Z ed Zed Zed ZedZRS(sA single dependency.t__dstrcBs eZdZdZdZRS(sQCompare helper for compatibility with old third-party code. Old third-party code might still compare the relation with the previously used relations (<<,<=,==,!=,>=,>>,) instead of the curently used ones (<,<=,=,!=,>=,>,). This compare helper lets < match to <<, > match to >> and = match to ==. cCstj||rtStj|dr8tjd|Stj|drZtjd|Stj|dr|tjd|StSdS(Nts>>t=s==(tstrt__eq__tTrueR(tselftother((s//usr/lib/python2.7/dist-packages/apt/package.pyR$PscCs|j| S(N(R$(R&R'((s//usr/lib/python2.7/dist-packages/apt/package.pyt__ne__\s(RRRR$R((((s//usr/lib/python2.7/dist-packages/apt/package.pyRGs cCs||_||_dS(N(t_versiont_dep(R&tversiontdep((s//usr/lib/python2.7/dist-packages/apt/package.pyt__init___s cCsd|j|jfS(Ns%s: %s(trawtypetrawstr(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyt__str__cscCs d|j|j|j|jfS(Ns;(tnametrelationR+R.(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyt__repr__fscCs |jjjS(sThe name of the target package.(R*t target_pkgR1(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR1jscCs|j|jjS(sThe relation (<, <=, =, !=, >=, >, '') in mathematical notation. The empty string will be returned in case of an unversioned dependency. (t_BaseDependency__dstrR*t comp_type(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR2oscCs |jjS(svThe relation (<<, <=, =, !=, >=, >>, '') in Debian notation. The empty string will be returned in case of an unversioned dependency. For more details see the Debian Policy Manual on the syntax of relationship fields: https://www.debian.org/doc/debian-policy/ch-relationships.html#s-depsyntax # noqa .. versionadded:: 1.0.0 (R*t comp_type_deb(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyt relation_debws cCs |jjS(sThe target version or an empty string. Note that the version is only an empty string in case of an unversioned dependency. In this case the relation is also an empty string. (R*t target_ver(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR+scCsmg}|jj}xQ|D]I}|j}|jjj}|j|}t||}|j|qW|S(sfA list of all Version objects which satisfy this dependency. .. versionadded:: 1.0.0 ( R*t all_targetst parent_pkgR)tpackaget_pcachet_rawpkg_to_pkgR tappend(R&ttverst_tverst_tvert_pkgtcachetpkgttver((s//usr/lib/python2.7/dist-packages/apt/package.pyttarget_versionss  cCs#g|jD]}|jr |^q S(siA list of all installed Version objects which satisfy this dep. .. versionadded:: 1.0.0 (RGt is_installed(R&RF((s//usr/lib/python2.7/dist-packages/apt/package.pytinstalled_target_versionsscCs.|jr#d|j|j|jfS|jSdS(sString represenation of the dependency. Returns the string representation of the dependency as it would be written in the debian/control file. The string representation does not include the type of the dependency. Example for an unversioned dependency: python3 Example for a versioned dependency: python3 >= 3.2 .. versionadded:: 1.0.0 s%s %s %sN(R+R1R8(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR/s cCs |jjS(sType of the dependency. This should be one of 'Breaks', 'Conflicts', 'Depends', 'Enhances', 'PreDepends', 'Recommends', 'Replaces', 'Suggests'. Additional types might be added in the future. (R*tdep_type_untranslated(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR.s cCs|jjdkS(sWhether this is a PreDepends.t PreDepends(R*RJ(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyt pre_depends(RRRR#R5R-R0R3tpropertyR1R2R8R+RGRIR/R.RL(((s//usr/lib/python2.7/dist-packages/apt/package.pyRDs      cBsteZdZdZdZdZedZedZedZ edZ edZ RS( sMRepresent an Or-group of dependencies. Attributes defined here: or_dependencies - The possible choices rawstr - String represenation of the Or-group of dependencies rawtype - The type of the dependencies in the Or-group target_version - A list of Versions which satisfy this Or-group of deps cCs,tt|j|||_||_dS(N(tsuperRR-R)t_rawtype(R&R+t base_depsR.((s//usr/lib/python2.7/dist-packages/apt/package.pyR-s cCsd|j|jfS(Ns%s: %s(R.R/(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR0scCsddjd|DS(Nss, css|]}t|VqdS(N(trepr(t.0tbd((s//usr/lib/python2.7/dist-packages/apt/package.pys s(tjoin(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR3scCs|S(N((R&((s//usr/lib/python2.7/dist-packages/apt/package.pytor_dependenciesscCsdjd|DS(sxString represenation of the Or-group of dependencies. Returns the string representation of the Or-group of dependencies as it would be written in the debian/control file. The string representation does not include the type of the Or-group of dependencies. Example: python2 >= 2.7 | python3 .. versionadded:: 1.0.0 s | css|]}|jVqdS(N(R/(RRRS((s//usr/lib/python2.7/dist-packages/apt/package.pys s(RT(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR/s cCs|jS(sType of the Or-group of dependency. This should be one of 'Breaks', 'Conflicts', 'Depends', 'Enhances', 'PreDepends', 'Recommends', 'Replaces', 'Suggests'. Additional types might be added in the future. .. versionadded:: 1.0.0 (RO(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR.s cCsKg}x>|D]6}x-|jD]"}||kr|j|qqWq W|S(slA list of all Version objects which satisfy this Or-group of deps. .. versionadded:: 1.0.0 (RGR?(R&R@RSRF((s//usr/lib/python2.7/dist-packages/apt/package.pyRGs   cCs#g|jD]}|jr |^q S(siA list of all installed Version objects which satisfy this dep. .. versionadded:: 1.0.0 (RGRH(R&RF((s//usr/lib/python2.7/dist-packages/apt/package.pyRI s( RRRR-R0R3RMRUR/R.RGRI(((s//usr/lib/python2.7/dist-packages/apt/package.pyRs     cBs eZdZdZdZRS(sThe origin of a version. Attributes defined here: archive - The archive (eg. unstable) component - The component (eg. main) label - The Label, as set in the Release file origin - The Origin, as set in the Release file codename - The Codename, as set in the Release file site - The hostname of the site. trusted - Boolean value whether this is trustworthy. cCs|j|_|j|_|j|_|j|_|j|_|j|_|j|_|jjj |}|r|j rt |_ n t |_ dS(N(tarchivet componenttlabeltorigintcodenametsitet not_automaticR=t_listt find_indext is_trustedR%ttrustedR(R&REt packagefilet indexfile((s//usr/lib/python2.7/dist-packages/apt/package.pyR-#s        cCs,d|j|j|j|j|j|jfS(NsH(RWRVRYRXR[R`(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR32s  (RRRR-R3(((s//usr/lib/python2.7/dist-packages/apt/package.pyR s  cBskeZdZdZdZdZdZdZdZdZ d dZ d Z d Z RS( s"Record in a Packages file Represent a record as stored in a Packages file. You can use this like a dictionary mapping the field names of the record to their values:: >>> record = Record("Package: python-apt\nVersion: 0.8.0\n\n") >>> record["Package"] 'python-apt' >>> record["Version"] '0.8.0' For example, to get the tasks of a package from a cache, you could do:: package.candidate.record["Tasks"].split() Of course, you can also use the :attr:`Version.tasks` property. cCstj||_dS(N(Rt TagSectiont_rec(R&t record_str((s//usr/lib/python2.7/dist-packages/apt/package.pyR-MscCs t|jS(N(thashRd(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyt__hash__PscCs t|jS(N(R#Rd(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR0SscCs |j|S(N(Rd(R&tkey((s//usr/lib/python2.7/dist-packages/apt/package.pyt __getitem__VscCs ||jkS(N(Rd(R&Rh((s//usr/lib/python2.7/dist-packages/apt/package.pyt __contains__YscCst|jjS(N(titerRdtkeys(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyt__iter__\sccs0x)|jjD]}||j|fVqWdS(s6An iterator over the (key, value) items of the record.N(RdRl(R&Rh((s//usr/lib/python2.7/dist-packages/apt/package.pyt iteritems_scCs|jj||S(sReturn record[key] if key in record, else *default*. The parameter *default* must be either a string or None. (Rdtget(R&Rhtdefault((s//usr/lib/python2.7/dist-packages/apt/package.pyRodscCs ||jkS(s deprecated form of ``key in x``.(Rd(R&Rh((s//usr/lib/python2.7/dist-packages/apt/package.pythas_keykscCs t|jS(N(tlenRd(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyt__len__osN(RRRR-RgR0RiRjRmRntNoneRoRqRs(((s//usr/lib/python2.7/dist-packages/apt/package.pyR 9s         cBs{eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z ed Zed ZedZedZedZedZedZedZedZedZedZedZedZedZedZedZedZedZ dZ!edZ"ed Z#ed!Z$ed"Z%ed#Z&ed$Z'ed%Z(ed&Z)ed'Z*ed(Z+ed)Z,d*Z-ed+Z.ed,Z/d-d0d0d.Z1d-d0e2d0d/Z3RS(1sRepresentation of a package version. The Version class contains all information related to a specific package version. .. versionadded:: 0.7.9 cCs||_||_dS(N(R<t_cand(R&R<tcand((s//usr/lib/python2.7/dist-packages/apt/package.pyR-|s cCsyU|jj}|jj}||kr+dS||kr;dStj|jj|jSWn@tk rytj|jj|SWqtk rt SXnXdS(s:Compares against another apt.Version object or a version string. This method behaves like Python 2's cmp builtin and returns an integer according to the outcome. The return value is negative in case of self < other, zero if self == other and positive if self > other. The comparison includes the package name and architecture if other is an apt.Version object. If other isn't an apt.Version object it'll be assumed that other is a version string (without package name/arch). .. versionchanged:: 1.0.0 iiN( R<tfullnameRtversion_compareRutver_strR+tAttributeErrort TypeErrortNotImplemented(R&R't self_namet other_name((s//usr/lib/python2.7/dist-packages/apt/package.pyt_cmps      cCs|j|dkS(Ni(R(R&R'((s//usr/lib/python2.7/dist-packages/apt/package.pyR$scCs|j|dkS(Ni(R(R&R'((s//usr/lib/python2.7/dist-packages/apt/package.pyt__ge__scCs|j|dkS(Ni(R(R&R'((s//usr/lib/python2.7/dist-packages/apt/package.pyt__gt__scCs|j|dkS(Ni(R(R&R'((s//usr/lib/python2.7/dist-packages/apt/package.pyt__le__scCs|j|dkS(Ni(R(R&R'((s//usr/lib/python2.7/dist-packages/apt/package.pyt__lt__scCs0y|j|dkSWntk r+tSXdS(Ni(RR{R|(R&R'((s//usr/lib/python2.7/dist-packages/apt/package.pyR(s cCs |jjS(N(RuRf(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRgscCsd|jj|jfS(Ns%s=%s(R<R1R+(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR0scCsd|jj|jfS(Ns (R<R1R+(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR3s cCs3|jjjj|jjdr/|jjjSdS(s=Internal helper that moves the Records to the right position.iN(R<R=t_recordstlookupRut file_list(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRs"cCs;|jj}|jjjj|jjd|jjjS(s2Internal helper to get the translated description.i(Ruttranslated_descriptionR<R=RRRtpop(R&t desc_iter((s//usr/lib/python2.7/dist-packages/apt/package.pyt_translated_recordss "cCs |jjS(s.Return the size of the package when installed.(Rutinstalled_size(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRscCs |jjS(s$Return the homepage for the package.(Rthomepage(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRscCs |jjS(sReturn the size of the package.(RuR(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRscCs |jjS(s/Return the architecture of the package version.(Rutarch(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyt architecturescCst|jjS(s:Return whether the version of the package is downloadable.(tboolRut downloadable(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRscCs(|jj}|o'|jj|jjkS(skReturn wether this version of the package is currently installed. .. versionadded:: 1.0.0 (R<t installedRutid(R&tinst_ver((s//usr/lib/python2.7/dist-packages/apt/package.pyRHs cCs |jjS(sReturn the version as a string.(RuRy(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR+scCs |jjS(s0Return the short description (one line summary).(Rt short_desc(R&((s//usr/lib/python2.7/dist-packages/apt/package.pytsummaryscCs |jjS(s"return the long description (raw).(Rt long_desc(R&((s//usr/lib/python2.7/dist-packages/apt/package.pytraw_descriptionscCs |jjS(s"Return the section of the package.(Rutsection(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRscCs\d}|jj}y%t|ts6|jd}nWn*tk rc}td|jj|fSXt |j d}t |x|D]}|j dkr|j ds|d7}qqn|jdr|j dsd|d }qJd |d }nF|jd rD|j ds.|dkr;|d }qJ|}n|}||7}qW|S( sReturn the formatted long description. Return the formatted long description according to the Debian policy (Chapter 5.6.13). See http://www.debian.org/doc/debian-policy/ch-controlfields.html for more information. tsutf-8s<Invalid unicode in description for '%s' (%s). Please report.s t.s s s %s is%s t i(RRt isinstancetunicodetdecodetUnicodeDecodeErrort_R<R1Rktsplittnexttstriptendswitht startswith(R&tdesctdscterrtlinestraw_linetline((s//usr/lib/python2.7/dist-packages/apt/package.pyt descriptions4        cCs9y|jjp|jjSWntk r4|jjSXdS(s&Return the name of the source package.N(Rt source_pkgR<t shortnamet IndexError(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyt source_name/s cCs9y|jjp|jjSWntk r4|jjSXdS(s)Return the version of the source package.N(Rt source_verRuRyR(R&((s//usr/lib/python2.7/dist-packages/apt/package.pytsource_version7s cCs |jjS(s.Return the priority of the package, as string.(Rut priority_str(R&((s//usr/lib/python2.7/dist-packages/apt/package.pytpriority?scCsQd}|jjjj}x2|jjD]$\}}t||j|}q%W|S(sReturn the internal policy priority as a number. See apt_preferences(5) for more information about what it means. i(R<R=t _depcachetpolicyRuRtmaxt get_priority(R&RRRat_unused((s//usr/lib/python2.7/dist-packages/apt/package.pytpolicy_priorityDs cCst|jjS(sReturn a Record() object for this version. Return a Record() object for this version which provides access to the raw attributes of the candidate version (R Rtrecord(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyROscGsg}|jj}x|D]y}y_xX||D]L}g}x$|D]}|jt||q@W|jt|||q-WWqtk rqXqW|S(s(Return a list of Dependency objects for the given types. Multiple types can be specified. Possible types are: 'Breaks', 'Conflicts', 'Depends', 'Enhances', 'PreDepends', 'Recommends', 'Replaces', 'Suggests' Additional types might be added in the future. (Rut depends_listR?RRtKeyError(R&ttypesRtdependsttype_t dep_ver_listRPtdep_or((s//usr/lib/python2.7/dist-packages/apt/package.pytget_dependenciesXs    ! cCs!g|jjD]}|d^q S(s3 Return a list of names that this version provides.i(Rut provides_list(R&tp((s//usr/lib/python2.7/dist-packages/apt/package.pytprovidesnscCs |jdS(s4Return the list of enhances for the package version.tEnhances(R(R&((s//usr/lib/python2.7/dist-packages/apt/package.pytenhancessscCs|jddS(s/Return the dependencies of the package version.RKtDepends(R(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyt dependenciesxscCs |jdS(s-Return the recommends of the package version.t Recommends(R(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyt recommends}scCs |jdS(s+Return the suggests of the package version.tSuggests(R(R&((s//usr/lib/python2.7/dist-packages/apt/package.pytsuggestsscCs@g}x3|jjD]%\}}|jt|j|qW|S(s1Return a list of origins for the package version.(RuRR?R R<(R&toriginsRaR((s//usr/lib/python2.7/dist-packages/apt/package.pyRscCs |jjS(sZReturn the path to the file inside the archive. .. versionadded:: 0.7.10 (Rtfilename(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRscCs |jjS(sKReturn the md5sum of the binary. .. versionadded:: 0.7.10 (Rtmd5_hash(R&((s//usr/lib/python2.7/dist-packages/apt/package.pytmd5scCs |jjS(sLReturn the sha1sum of the binary. .. versionadded:: 0.7.10 (Rt sha1_hash(R&((s//usr/lib/python2.7/dist-packages/apt/package.pytsha1scCs |jjS(sNReturn the sha256sum of the binary. .. versionadded:: 0.7.10 (Rt sha256_hash(R&((s//usr/lib/python2.7/dist-packages/apt/package.pytsha256scCst|jdjS(sGet the tasks of the package. A set of the names of the tasks this package belongs to. .. versionadded:: 0.8.0 tTask(tsetRR(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyttaskssccsVxO|jjD]A\}}|jjjj|}|r |j|jjVq q WdS(sVReturn an iterator over all available urls. .. versionadded:: 0.7.10 N( RuRR<R=R]R^t archive_uriRR(R&RaRRb((s//usr/lib/python2.7/dist-packages/apt/package.pyt_urisscCst|jS(s^Return a list of all available uris for the binary. .. versionadded:: 0.7.10 (tlistR(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyturisscCs3ytt|jSWntk r.dSXdS(sNReturn a single URI for the binary. .. versionadded:: 0.7.10 N(RRkRt StopIterationRt(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyturis Rc Cs|d kr$tjjdt}ntjj|jj }tjj ||}t ||j |jj rtd|tjj|S|jjd\}}|jjjj|}|p|o|jstd|jj|jt|ddfn|jstdn|jj } |p.| jsDtd|ntj|p_tj j!j"} tj#| |j| |j |d |} | j$| j%| j&krt'd | j(| j)fntjj|S( sCFetch the binary version of the package. The parameter *destdir* specifies the directory where the package will be fetched to. The parameter *progress* may refer to an apt_pkg.AcquireProgress() object. If not specified or None, apt.progress.text.AcquireProgress() is used. The keyword-only parameter *allow_unauthenticated* specifies whether to allow unauthenticated downloads. If not specified, it defaults to the configuration option `APT::Get::AllowUnauthenticated`. .. versionadded:: 0.7.10 sAPT::Get::AllowUnauthenticateds"Ignoring already existing file: %sis>Could not fetch %s %s source package: Source %r is not trustedtdescribessNo URI for this binary.s8The item %r could not be fetched: No trusted hash found.tdestfiles$The item %r could not be fetched: %sN(*RtRtconfigtfind_bRRRtbasenameRRRTRRRtprinttabspathRuRR<R=R]R^R_RR1R+tgetattrRt ValueErrortusabletAcquiretapttprogressttexttAcquireProgresst AcquireFiletruntstatust STAT_DONERRt error_text( R&tdestdirRtallow_unauthenticatedtbaseRtpfiletoffsettindexRtacqtacqfile((s//usr/lib/python2.7/dist-packages/apt/package.pyt fetch_binarys8      ! c Cs|d kr$tjjdt}ntj}tj|pKtjj j }d }|j }|j pr|j j} |jp|jj} |j| } x(| r| |jkr|j| } qW| std|nt} |p|jjs#td|j j|j|jjfnx|jD]} tjj| j}tjj||}| j dkru|}nt!|| j"| j#rt$d|q-n|p| j#j%std|n| j&tj'||jj(| j| j#| j"|d|q-W|j)xB|j*D]7}|j+|j,krt-d|j.|j/fqqW|r|j d tj0|j}tjj||}t1j2d d ||gtjj3|Stjj3|Sd S( s9Get the source code of a package. The parameter *destdir* specifies the directory where the source will be fetched to. The parameter *progress* may refer to an apt_pkg.AcquireProgress() object. If not specified or None, apt.progress.text.AcquireProgress() is used. The parameter *unpack* describes whether the source should be unpacked (``True``) or not (``False``). By default, it is unpacked. If *unpack* is ``True``, the path to the extracted directory is returned. Otherwise, the path to the .dsc file is returned. The keyword-only parameter *allow_unauthenticated* specifies whether to allow unauthenticated downloads. If not specified, it defaults to the configuration option `APT::Get::AllowUnauthenticated`. sAPT::Get::AllowUnauthenticatedsNo source for %rs>Could not fetch %s %s source package: Source %r is not trustedRs"Ignoring already existing file: %ss8The item %r could not be fetched: No trusted hash found.Rs$The item %r could not be fetched: %st-s dpkg-sources-xN(4RtRRRRt SourceRecordsRRRRRRRR<RRRuRyRR+RRRR_RR1RtfilesRRRRTttypeRRRRRR?RRRtitemsRRRRRtupstream_versiont subprocesst check_callR(R&RRtunpackRtsrcRRRRRt source_lookupRtfilRRtitemtoutdir((s//usr/lib/python2.7/dist-packages/apt/package.pyt fetch_source sX    !      N(4RRRR-RR$RRRRR(RgR0R3RMRRRRRRRRHR+RRRRRRRRRRRRRRRRRRRRRRRRRtRR%R (((s//usr/lib/python2.7/dist-packages/apt/package.pyR ssb            /     4 cBsneZdZd dZdZdZdZdZdZ dZ dZ d Z d d Z RS( sProvide a mapping & sequence interface to all versions of a package. This class can be used like a dictionary, where version strings are the keys. It can also be used as a sequence, where integers are the keys. You can also convert this to a dictionary or a list, using the usual way of dict(version_list) or list(version_list). This is useful if you need to access the version objects multiple times, because they do not have to be recreated this way. Examples ('package.versions' being a version list): '0.7.92' in package.versions # Check whether 0.7.92 is a valid version. package.versions[0] # Return first version or raise IndexError package.versions[0:2] # Return a new VersionList for objects 0-2 package.versions['0.7.92'] # Return version 0.7.92 or raise KeyError package.versions.keys() # All keys, as strings. max(package.versions) cCs5||_|jj|_|r1|j||_ndS(N(t_packageRCt version_listt _versions(R&R<tslice_((s//usr/lib/python2.7/dist-packages/apt/package.pyR-ls cCst|tr"|j|j|Syt|j|j|SWnDtk rx4|jD]%}|j|krWt|j|SqWWnXtd|dS(NsVersion: %r not found.( Rtslicet __class__R R RR{RyR(R&R tver((s//usr/lib/python2.7/dist-packages/apt/package.pyRirs cCsddjd|DS(Ns[%s]s, css|]}t|VqdS(N(R#(RRR((s//usr/lib/python2.7/dist-packages/apt/package.pys s(RT(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR0scCsd|jS(Ns(Rl(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR3scsfdjDS(s*Return an iterator over all value objects.c3s!|]}tj|VqdS(N(R R (RRR(R&(s//usr/lib/python2.7/dist-packages/apt/package.pys s(R(R&((R&s//usr/lib/python2.7/dist-packages/apt/package.pyRmscCsFt|tr|j}nx$|jD]}|j|kr%tSq%WtS(N(RR R+RRyR%R(R&R R((s//usr/lib/python2.7/dist-packages/apt/package.pyRjs  cCst|t|kS(N(R(R&R'((s//usr/lib/python2.7/dist-packages/apt/package.pyR$scCs t|jS(N(RrR(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRsscCsg|jD]}|j^q S(s*Return a list of all versions, as strings.(RRy(R&R((s//usr/lib/python2.7/dist-packages/apt/package.pyRlscCs%y ||SWntk r |SXdS(sReturn the key or the default.N(t LookupError(R&RhRp((s//usr/lib/python2.7/dist-packages/apt/package.pyRos  N(RRRRtR-RiR0R3RmRjR$RsRlRo(((s//usr/lib/python2.7/dist-packages/apt/package.pyR Xs       cBs eZdZdZdZdZdZdZdZe eeZe dZ e dZ e d Z e d Z e d Zd Ze d ZdZe dZe dZe dZe dZe dZe dZe dZe dZe dZe dZe dZe dZd&d&dZe dZ e dZ!e dZ"e dZ#d Z$e%e&d!Z'e%e%e%d"Z(e%d#Z)e%d$Z*d%Z+RS('sRepresentation of a package in a cache. This class provides methods and properties for working with a package. It lets you mark the package for installation, check if it is installed, and much more. cCs||_||_d|_dS(s Init the Package object RN(RCR=t _changelog(R&tpcachetpkgiter((s//usr/lib/python2.7/dist-packages/apt/package.pyR-s  cCs|jS(N(R1(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR0scCs#d|jj|jj|jjfS(Ns((RCR1RR(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR3scCs|j|jkS(N(R1(R&R'((s//usr/lib/python2.7/dist-packages/apt/package.pyRscCs5|jjj|j}|dk r1t||SdS(sReturn the candidate version of the package. This property is writeable to allow you to set the candidate version of the package. Just assign a Version() object, and it will be set as the candidate version. N(R=Rtget_candidate_verRCRtR (R&Rv((s//usr/lib/python2.7/dist-packages/apt/package.pyt candidates cCs:|jj|jjj|j|j|jjdS(s)Set the candidate version of the package.N(R=tcache_pre_changeRtset_candidate_verRCRutcache_post_change(R&R+((s//usr/lib/python2.7/dist-packages/apt/package.pyt__set_candidates cCs)|jjdk r%t||jjSdS(s`Return the currently installed version of the package. .. versionadded:: 0.7.9 N(RCt current_verRtR (R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRscCs|jjtS(s}Return the name of the package, possibly including architecture. If the package is not part of the system's preferred architecture, return the same as :attr:`fullname`, otherwise return the same as :attr:`shortname` .. versionchanged:: 0.7.100.3 As part of multi-arch, this field now may include architecture information. (RCt get_fullnameR%(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR1s cCs|jjtS(s\Return the name of the package, including architecture. .. versionadded:: 0.7.100.3(RCRR(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRwscCs |jjS(sZReturn the name of the package, without architecture. .. versionadded:: 0.7.100.3(RCR1(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRscCs |jjS(snReturn a uniq ID for the package. This can be used eg. to store additional information about the pkg.(RCR(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRscCs |jjS(s[Return the hash of the object. This returns the same value as ID, which is unique.(RCR(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRgscCs |jjS(s>Return True if the package is an essential part of the system.(RCt essential(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRscCs |jjS(sReturn the Architecture of the package. .. versionchanged:: 0.7.100.3 This is now the package's architecture in the multi-arch sense, previously it was the architecture of the candidate version and deprecated. (RCR(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR scCs |jjS(s"Return the section of the package.(RCR(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRscCs|jjj|jS(s5Return ``True`` if the package is marked for install.(R=Rtmarked_installRC(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR scCs|jjj|jS(s5Return ``True`` if the package is marked for upgrade.(R=Rtmarked_upgradeRC(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR!scCs|jjj|jS(s4Return ``True`` if the package is marked for delete.(R=Rt marked_deleteRC(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR"$scCs|jjj|jS(s2Return ``True`` if the package is marked for keep.(R=Rt marked_keepRC(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR#)scCs|jjj|jS(s! Package is marked for downgrade (R=Rtmarked_downgradeRC(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR$.scCs|jjj|jS(s7Return ``True`` if the package is marked for reinstall.(R=Rtmarked_reinstallRC(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR%3scCs|jjdk S(s,Return ``True`` if the package is installed.N(RCRRt(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRH8scCs|jo|jjj|jS(s-Return ``True`` if the package is upgradable.(RHR=Rt is_upgradableRC(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR&=s cCs(|js|jo'|jjj|jS(sReturn ``True`` if the package is no longer required. If the package has been installed automatically as a dependency of another package, and if no packages depend on it anymore, the package is no longer required. (RHR R=Rt is_garbageRC(R&((s//usr/lib/python2.7/dist-packages/apt/package.pytis_auto_removableCscCs|jjj|jS(s@Return whether the package is marked as automatically installed.(R=Rtis_auto_installedRC(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyR)NscCszxs|j|jfD]_}d|}y8t|d#}|jjdjdSWdQXWqtk rqqqXqWgS(sReturn a list of files installed by the package. Return a list of unicode names of the files which have been installed by this package s/var/lib/dpkg/info/%s.listtrbsutf-8u N(R1RwRtreadRRtEnvironmentError(R&R1RR((s//usr/lib/python2.7/dist-packages/apt/package.pytinstalled_filesTs &  cCs|jdkr|jS|dkr|js.n|jjdjdkrPd}q|jjdjdkrrd}qtd}t|tr|S|jdSn|jj }d }|jj }|jj }yt j }Wntk rnXx}|j|rn|jsqn|jj |jkr;|j}|j }Pnt j|j|dkr|j}|j }qqW|jd d } t| d kr| d}n~ |d} |jd rd |d } n|jdd } t| d krdj| d }n~ |i|d6| d6|d6|d6}tj} zRytjd|re|jredSt|} d}dtj|}xtr|r|jrdS| j}|sPn|jd}tj||}|rt |j!dd}|r&d|kr&|jdd d }n|j"d }|r`d|kr`|jdd d }n|rt j||dkrPqn||7}qWt|dkrtd}t|ts|jd}qn||_Wnt#k rM|jjdjdkr!td||f}n td}t|tr@|S|jdSt$t%fk rtd}t|tr|S|jdSXWdtj| X|jS(s Download the changelog of the package and return it as unicode string. The parameter *uri* refers to the uri of the changelog file. It may contain multiple named variables which will be substitued. These variables are (src_section, prefix, src_pkg, src_ver). An example is the Ubuntu changelog:: "http://changelogs.ubuntu.com/changelogs/pool" \ "/%(src_section)s/%(prefix)s/%(src_pkg)s" \ "/%(src_pkg)s_%(src_ver)s/changelog" The parameter *cancel_lock* refers to an instance of threading.Lock, which if set, prevents the download. uitDebiansshttp://packages.debian.org/changelogs/pool/%(src_section)s/%(prefix)s/%(src_pkg)s/%(src_pkg)s_%(src_ver)s/changelogtUbuntusuhttp://changelogs.ubuntu.com/changelogs/pool/%(src_section)s/%(prefix)s/%(src_pkg)s/%(src_pkg)s_%(src_ver)s/changelogs$The list of changes is not availablesutf-8tmaint/itlibit:Rt src_sectiontprefixtsrc_pkgtsrc_veris^%s \((.*)\)(.*)$R+sThe list of changes is not available yet. Please use http://launchpad.net/ubuntu/+source/%s/%s/+changelog until the changes become available or try again later.sOFailed to download the list of changes. Please check your Internet connection.N(&RRtRRRYRRRRRRRRRt SystemErrorRR+RxRRrRRTtsockettgetdefaulttimeouttsetdefaulttimeouttisSetRtretescapeR%treadlinetmatchRRtgroupRtIOErrorR(R&Rt cancel_locktresR6R4RR7t src_recordst section_splitR5t src_ver_splitttimeouttchangelog_filet changelogtregexptline_rawRR@Rt changelog_ver((s//usr/lib/python2.7/dist-packages/apt/package.pyt get_changeloges     #                         %cCs t|S(scReturn a VersionList() object for all available versions. .. versionadded:: 0.7.9 (R (R&((s//usr/lib/python2.7/dist-packages/apt/package.pytversionsscCs|jjj|jS(s5Return True if the to-be-installed package is broken.(R=Rtis_inst_brokenRC(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRPscCs|jjj|jS(s/Return True if the installed package is broken.(R=Rt is_now_brokenRC(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRQscCs|jjtjkS(s8Checks whether the package is is the config-files state.(RCt current_stateRtCURSTATE_CONFIG_FILES(R&((s//usr/lib/python2.7/dist-packages/apt/package.pythas_config_filesscCs4|jj|jjj|j|jjdS(sMark a package for keep.N(R=RRt mark_keepRCR(R&((s//usr/lib/python2.7/dist-packages/apt/package.pyRU!s cCs|jj|jjj|j||r|jjjdkrtj|jj}|j|j|j |j|j |j|j |j n|jj dS(s+Mark a package for deletion. If *auto_fix* is ``True``, the resolver will be run, trying to fix broken packages. This is the default. If *purge* is ``True``, remove the configuration files of the package as well. The default is to keep the configuration. iN(R=RRt mark_deleteRCt broken_countRtProblemResolvertcleartprotecttremovetinstall_protecttresolveR(R&tauto_fixtpurgetfix((s//usr/lib/python2.7/dist-packages/apt/package.pyRV's   cCs|jj|jjj|j|||r|jjjdkrtj|jj}|j|j|j |j|j t n|jj dS(s0Mark a package for install. If *autoFix* is ``True``, the resolver will be run, trying to fix broken packages. This is the default. If *autoInst* is ``True``, the dependencies of the packages will be installed automatically. This is the default. If *fromUser* is ``True``, this package will not be marked as automatically installed. This is the default. Set it to False if you want to be able to automatically remove the package at a later stage when no other package depends on it. iN( R=RRt mark_installRCRWRRXRYRZR]R%R(R&R^t auto_instt from_usertfixer((s//usr/lib/python2.7/dist-packages/apt/package.pyRa<s cCsP|jr2|j}|jd||j|ntjjd|jjdS(sMark a package for upgrade.Rcs4MarkUpgrade() called on a non-upgradeable pkg: '%s' N( R&R)Rat mark_autotsyststderrtwriteRCR1(R&Rctauto((s//usr/lib/python2.7/dist-packages/apt/package.pyt mark_upgradeTs    cCs|jjj|j|dS(sMark a package as automatically installed. Call this function to mark a package as automatically installed. If the optional parameter *auto* is set to ``False``, the package will not be marked as automatically installed anymore. The default is ``True``. N(R=RReRC(R&Ri((s//usr/lib/python2.7/dist-packages/apt/package.pyRe_scCs|jjj||dS(sCommit the changes. The parameter *fprogress* refers to a apt_pkg.AcquireProgress() object, like apt.progress.text.AcquireProgress(). The parameter *iprogress* refers to an InstallProgress() object, as found in apt.progress.base. N(R=Rtcommit(R&t fprogresst iprogress((s//usr/lib/python2.7/dist-packages/apt/package.pyRkhs N(,RRRR-R0R3RRt_Package__set_candidateRMRR1RwRRRgRRRR R!R"R#R$R%RHR&R(R)R-RtRNRORPRQRTRUR%RRVRaRjReRk(((s//usr/lib/python2.7/dist-packages/apt/package.pyR sN           cCs}tdddl}tjtjjj}tj|}|d}td|j td|j td|j j td|j j td |j jtd |j jtd |j jtd |j jtd |j jtd|jtd|j jtd|j jtd|j jtd|j jtd|j jtd|j jtd|j jx4|j jD]&}tdjd|jDqWtd|j jtd|j jtd|j jt|djxt t!fD]}td|xB|D]:}|j"rC|j#dddkr}|j$|q}qCqCWtd|j%j&td |j%j'q)Wtxt t!fD]}td!|tj|}xf|j(D]X}|j#dddkry||j)|WqIt*k rEtd"|qIXqqWtd|j%j&td#|j%j+qWdS($s Self-test.sSelf-test for the Package moduliNs apt-utilss Name: %s sID: %s sPriority (Candidate): %s sPriority (Installed): %s sInstalled: %s sCandidate: %s sCandidateDownloadable: %ssCandidateOrigins: %ssSourcePkg: %s s Section: %s s Summary: %ssDescription (formatted) : %ssDescription (unformatted): %ssInstalledSize: %s sPackageSize: %s sDependencies: %ssRecommends: %st,css1|]'}d|j|j|j|jfVqdS(s%s (%s) (%s) (%s)N(R1R+R2RL(RRto((s//usr/lib/python2.7/dist-packages/apt/package.pys ssarch: %ss homepage: %ssrec: t2vcards8Running install on random upgradable pkgs with AutoFix: iis Broken: %s sInstCount: %s s.Randomly remove some packages with AutoFix: %ssError trying to remove: %s s DelCount: %s (,RtrandomRtinitRRRt OpProgresstCacheR1RRRRR+RRRRRRRRRRRRTRURRRRNR%RR&trandintRaRRWt inst_countRlRVR8t del_count(RrRRDRER,tiR1((s//usr/lib/python2.7/dist-packages/apt/package.pyt_testtsd        t__main__(-Rt __future__RRRfR=R9Rt http.clientRt urllib.errorRturllib.requestRt ImportErrorthttplibturllib2t collectionsRRRtapt.progress.textRRRt__all__t version_infotmajorR#RRt ExceptionRRtobjectRRRR R R R R RzR(((s//usr/lib/python2.7/dist-packages/apt/package.pytsH           K#:N 9