usr/lib/python3.6/site-packages/dnf/__pycache__/package.cpython-36.pyc000064400000023452147205364300021425 0ustar003 ft`+@sdZddlmZddlmZddlmZddlZddlZddl Zddl Zddl Z ddl Z ddlZ ddlZddlZddlZejdZGddde jZdS) z! Contains the dnf.Package class. )absolute_import)unicode_literals)_NdnfcseZdZdZdZdZfddZefddZej ddZed d Z ed d Z ed dZ eddZ eddZefddZej ddZeddZeddZeddZeddZddZed d!Zed"d#Zed$d%Zed&d'Zed(d)Zej d*d)Zed+d,Zed-d.Zed/d0Zed1d2Zed3d4Zed5d6Zed7d8Z d9d:Z!d;d<Z"d=d>Z#d?d@Z$dAdBZ%dRdGdHZ&dIdJZ'edKdLZ(dMdNZ)dOdPZ*Z+S)SPackagez Represents a package. #:api z -debuginfoz -debugsourcecs,tt|j|||_d|_d|_d|_dS)N)superr__init__base _priv_chksum_repo _priv_size)selfZ initobjectr ) __class__/usr/lib/python3.6/package.pyr0s zPackage.__init__cs|jr |jS|jr~tjjj}ytjj||j }Wn6tj j k rh}ztj j t|WYdd}~XnXtj|tj|fStt|jS)N)r _from_cmdlinerZyumZmiscZget_default_chksum_typelibdnfutilsZchecksum_valuelocationerrorError exceptions MiscErrorstrhawkey chksum_typebinasciiZ unhexlifyrrchksum)r rZ chksum_vale)rrr_chksum7s " zPackage._chksumcCs ||_dS)N)r )r valrrrrEscCs |jtjkS)N)reponamerZCMDLINE_REPO_NAME)r rrrrIszPackage._from_cmdlinecCs |jtjkS)N)r!rSYSTEM_REPO_NAME)r rrr _from_systemMszPackage._from_systemcCs*d}|jr|jjj|}|r$d|S|jS)a9 For installed packages returns id of repository from which the package was installed prefixed with '@' (if such information is available in the history database). Otherwise returns id of repository the package belongs to (@System for installed packages of unknown origin) N@)r#r historyrepor!)r Zpkgreporrr _from_repoQs zPackage._from_repocCs|jr|jjj|SdS)N)r#r r%r&)r rrr from_repo`szPackage.from_repocCstjj|jS)z Returns the header of a locally present rpm package file. As opposed to self.get_header(), which retrieves the header of an installed package from rpmdb. )rrpm_headerlocalPkg)r rrrr+gszPackage._headercs|jr |jStt|jS)N)r rrsize)r )rrr_sizepsz Package._sizecCs ||_dS)N)r )r r rrrr.vscCs"|jdkrdS|j\}}tj|S)N)Z hdr_chksumrhexlify)r rrrrr_pkgidzs  zPackage._pkgidcCs4|jdk r,tjj|jd}|jddd}nd}|S)zO returns name of source package e.g. krb5-libs -> krb5 Nz.src.rpm-r)Z sourcerpmrutilZrtrimrsplit)r Zsrcnamerrr source_names  zPackage.source_namecCsF|jj|jr|jS|j}|jj|jr<|dt|j }||jS)a) Returns name of the debuginfo package for this package. If this package is a debuginfo package, returns its name. If this package is a debugsource package, returns the debuginfo package for the base package. e.g. kernel-PAE -> kernel-PAE-debuginfo N)nameendswithDEBUGINFO_SUFFIXDEBUGSOURCE_SUFFIXlen)r r6rrr debug_names zPackage.debug_namecCs |jdk r|jn|j}||jS)zv Returns name of the debugsource package for this package. e.g. krb5-libs -> krb5-debugsource N)r5r6r9)r src_namerrrdebugsource_nameszPackage.debugsource_namec CsN|js dSyt|jjjtj|jStk rHt j j dt |YnXdS)a` Returns the rpm header of the package if it is installed. If not installed, returns None. The header is not cached, it is retrieved from rpmdb on every call. In case of a failure (e.g. when the rpmdb changes between loading the data and calling this method), raises an instance of PackageNotFoundError. Nz4Package not found when attempting to retrieve header) r#nextr Z_tsZdbMatchr*ZRPMDBI_PACKAGESrpmdbid StopIterationrrZPackageNotFoundErrorr)r rrr get_headers zPackage.get_headercCs |jdk r|jn|j}||jS)z returns name of debuginfo package for source package of given package e.g. krb5-libs -> krb5-debuginfo N)r5r6r8)r r<rrrsource_debug_nameszPackage.source_debug_namecCs t|jS)z: Always type it to int, rpm bindings expect it like that. )intr?)r rrridxsz Package.idxcCs|jS)N)r!)r rrrrepoidszPackage.repoidcCs|j|jt|j|j|jfS)N)r6archrrvr)r rrrpkgtupszPackage.pkgtupcCs|jr |jS|jj|jS)N)r r Zreposr!)r rrrr&sz Package.repocCs ||_dS)N)r )r r rrrr&scCs |jtjkrdS|jjjj|S)N)rErr"r r%r*Zget_reason_name)r rrrreasons zPackage.reasoncCs|jS)N)r)r rrr relativepathszPackage.relativepathcCs|jS)N)rF)r rrrasz Package.acCs|jS)N)Zepoch)r rrrrsz Package.ecCs|jS)N)version)r rrrrGsz Package.vcCs|jS)N)release)r rrrrHsz Package.rcCs|jS)N)r!)r rrr ui_from_reposzPackage.ui_from_repocCs|j|dkS)Nr)evr_cmp)r pkgrrrevr_eqszPackage.evr_eqcCs|j|dkS)Nr)rP)r rQrrrevr_gt szPackage.evr_gtcCs|j|dkS)Nr)rP)r rQrrrevr_lt szPackage.evr_ltcCs|jS)N)Zmedianr)r rrr getDiscNumszPackage.getDiscNumcCsr|jr |jS|j}|jjjrH|jrH|jjdrHtjj |j |j dS|j s\tjj |}tjj |j|j dS)z Package's location in the filesystem. For packages in remote repo returns where the package will be/has been downloaded. zfile:///)rrr&r isLocalbaseurl startswithospathjoinZget_local_baseurllstrip _is_local_pkgbasenamepkgdir)r locrrrr,s zPackage.localPkghttpftpfilehttpscCs |js |jrdS|jj|j|S)a The location from where the package can be downloaded from. Returns None for installed and commandline packages. :param schemes: list of allowed protocols. Default is ('http', 'ftp', 'file', 'https') :return: location (string) or None N)r#rr&remote_locationr)r Zschemesrrrrf$s zPackage.remote_locationcCsL|jr dSd|jkr&|jjd r&dS|jpJ|jjjoJ|j pJ|jjdS)NTz://zfile://F)r#rrYrr&r rWrX)r rrrr^1s zPackage._is_local_pkgcCs,|jjjr |j r |jjS|jjSdS)N)r&r rWr^Z cache_pkgdirr`)r rrrr`:s zPackage.pkgdircCs0|jdkrdS|j\}}tj|tj|jfS)z] Return the chksum type and chksum string how the legacy yum expects it. N)NN)rrZ chksum_namerr/decode)r rrrrr returnIdSumBs  zPackage.returnIdSumcCst|jrtd|jrdS|j\}}ytjj||j|Stjj k rn}zt j j t |WYdd}~XnXdS)Nz$Can not verify an installed package.T)r# ValueErrorrrhrrZchecksum_checkr,rrrrrr)r rrrrrrverifyLocalPkgLs zPackage.verifyLocalPkgrbrcrdre)rk),__name__ __module__ __qualname____doc__r8r9rpropertyrsetterrr#r'r)r+r.r0r5r;r=rArBrDrErIr&rJrKrLrrGrHrOrRrSrTrUr,rfr^r`rhrj __classcell__rr)rrr*sR                        r)roZ __future__rrZdnf.i18nrrZdnf.exceptionsrZdnf.rpmZ dnf.yum.miscrZ libdnf.errorrZ libdnf.utilsZloggingrZr*Z getLoggerZloggerrrrrrs