AlkantarClanX12

Your IP : 18.119.120.59


Current Path : /usr/lib/python3.6/site-packages/dnf/__pycache__/
Upload File :
Current File : //usr/lib/python3.6/site-packages/dnf/__pycache__/package.cpython-36.pyc

3

�ft`�+�@s�dZddlmZddlmZddlmZddlZddlZddl	Zddl
ZddlZddlZ
ddlZ
ddlZddlZddlZejd�ZGdd�dej�ZdS)	z! Contains the dnf.Package class. �)�absolute_import)�unicode_literals)�_N�dnfcs�eZdZdZdZdZ�fdd�Ze�fdd��Zej	dd��Zed	d
��Z
edd��Zed
d��Zedd��Z
edd��Ze�fdd��Zej	dd��Zedd��Zedd��Zedd��Zedd��Zdd�Zed d!��Zed"d#��Zed$d%��Zed&d'��Zed(d)��Zej	d*d)��Zed+d,��Zed-d.��Zed/d0��Zed1d2��Zed3d4��Zed5d6��Zed7d8��Z d9d:�Z!d;d<�Z"d=d>�Z#d?d@�Z$dAdB�Z%dRdGdH�Z&dIdJ�Z'edKdL��Z(dMdN�Z)dOdP�Z*�Z+S)S�Packagez 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
jk
rh}ztjj
t|���WYdd}~XnXtj|�tj|�fStt|�jS)N)r
�
_from_cmdlinerZyumZmiscZget_default_chksum_type�libdnf�utilsZchecksum_value�location�error�Error�
exceptions�	MiscError�str�hawkey�chksum_type�binasciiZ	unhexlifyrr�chksum)r
rZ
chksum_val�e)rrr�_chksum7s"zPackage._chksumcCs
||_dS)N)r
)r
�valrrrrEscCs|jtjkS)N)�reponamerZCMDLINE_REPO_NAME)r
rrrrIszPackage._from_cmdlinecCs|jtjkS)N)r!r�SYSTEM_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	�history�repor!)r
Zpkgreporrr�
_from_repoQszPackage._from_repocCs|jr|jjj|�SdS)N�)r#r	r%r&)r
rrr�	from_repo`szPackage.from_repocCstjj|j��S)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.
        )r�rpm�_header�localPkg)r
rrrr+gszPackage._headercs|jr|jStt|�jS)N)rrr�size)r
)rrr�_sizepsz
Package._sizecCs
||_dS)N)r)r
r rrrr.vscCs"|jdkrdS|j\}}tj|�S)N)Z
hdr_chksumr�hexlify)r
rrrrr�_pkgidzs

zPackage._pkgidcCs4|jdk	r,tjj|jd�}|jdd�d}nd}|S)zO
        returns name of source package
        e.g. krb5-libs -> krb5
        Nz.src.rpm�-�r)Z	sourcerpmr�utilZrtrim�rsplit)r
Zsrcnamerrr�source_name�s

zPackage.source_namecCsF|jj|j�r|jS|j}|jj|j�r<|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)�name�endswith�DEBUGINFO_SUFFIX�DEBUGSOURCE_SUFFIX�len)r
r6rrr�
debug_name�s
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_namerrr�debugsource_name�szPackage.debugsource_namecCsN|js
dSyt|jjjtj|j��Stk
rHt	j
jdt|���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_PACKAGES�rpmdbid�
StopIterationrrZPackageNotFoundErrorr)r
rrr�
get_header�s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<rrr�source_debug_name�szPackage.source_debug_namecCs
t|j�S)z: Always type it to int, rpm bindings expect it like that. )�intr?)r
rrr�idx�szPackage.idxcCs|jS)N)r!)r
rrr�repoid�szPackage.repoidcCs|j|jt|j�|j|jfS)N)r6�archrr�v�r)r
rrr�pkgtup�szPackage.pkgtupcCs|jr|jS|jj|jS)N)rr	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
rrr�reason�szPackage.reasoncCs|jS)N)r)r
rrr�relativepath�szPackage.relativepathcCs|jS)N)rF)r
rrr�a�sz	Package.acCs|jS)N)Zepoch)r
rrrr�sz	Package.ecCs|jS)N)�version)r
rrrrG�sz	Package.vcCs|jS)N)�release)r
rrrrH�sz	Package.rcCs|jS)N)r!)r
rrr�ui_from_reposzPackage.ui_from_repocCs|j|�dkS)Nr)�evr_cmp)r
�pkgrrr�evr_eqszPackage.evr_eqcCs|j|�dkS)Nr)rP)r
rQrrr�evr_gt	szPackage.evr_gtcCs|j|�dkS)Nr)rP)r
rQrrr�evr_lt
szPackage.evr_ltcCs|jS)N)Zmedianr)r
rrr�
getDiscNumszPackage.getDiscNumcCsr|jr|jS|j}|jjj�rH|jrH|jjd�rHtjj	|j
�|jd��S|j�s\tjj
|�}tjj	|j|jd��S)z� Package's location in the filesystem.

            For packages in remote repo returns where the package will be/has
            been downloaded.
        zfile://�/)rrr&r�isLocal�baseurl�
startswith�os�path�joinZget_local_baseurl�lstrip�
_is_local_pkg�basename�pkgdir)r
�locrrrr,szPackage.localPkg�http�ftp�file�httpscCs |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|jjj�oJ|jpJ|jjd�S)NTz://zfile://F)r#rrYrr&rrWrX)r
rrrr^1szPackage._is_local_pkgcCs,|jjj�r |j�r |jj�S|jjSdS)N)r&rrWr^Zcache_pkgdirr`)r
rrrr`:s
zPackage.pkgdircCs0|jdkrdS|j\}}tj|�tj|�j�fS)z] Return the chksum type and chksum string how the legacy yum expects
            it.
        N)NN)rrZchksum_namerr/�decode)r
rrrrr�returnIdSumBs

zPackage.returnIdSumcCst|jrtd��|jrdS|j�\}}ytjj||j�|�Stjj	k
rn}zt
jjt
|���WYdd}~XnXdS)Nz$Can not verify an installed package.T)r#�
ValueErrorrrhrrZchecksum_checkr,rrrrrr)r
rrrrrr�verifyLocalPkgLszPackage.verifyLocalPkg�rbrcrdre)rk),�__name__�
__module__�__qualname__�__doc__r8r9r�propertyr�setterrr#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	getLoggerZloggerrrrrr�<module>s