????

Your IP : 18.226.34.223


Current Path : /lib/python3.9/site-packages/dnf/__pycache__/
Upload File :
Current File : //lib/python3.9/site-packages/dnf/__pycache__/package.cpython-39.pyc

a

�!c�+�@s�dZddlmZddlmZddlmZddlZddlZddl	Zddl
ZddlZddlZ
ddlZ
ddlZddlZddlZe�d�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%dNdDdE�Z&dFdG�Z'edHdI��Z(dJdK�Z)dLdM�Z*�Z+S)O�Packagez Represents a package. #:api z
-debuginfoz-debugsourcecs,tt|��|�||_d|_d|_d|_dS�N)�superr�__init__�base�_priv_chksum�_repo�
_priv_size)�selfZ
initobjectr
��	__class__��//usr/lib/python3.9/site-packages/dnf/package.pyr	0s
zPackage.__init__c
s�|jr|jS|jr�tjj��}ztj�||j	�}Wn8tj
jyj}ztj�
t|���WYd}~n
d}~00t�|�t�|�fStt|�jSr)r�
_from_cmdlinerZyumZmiscZget_default_chksum_type�libdnf�utilsZchecksum_value�location�error�Error�
exceptions�	MiscError�str�hawkey�chksum_type�binasciiZ	unhexlifyrr�chksum)rrZ
chksum_val�errr�_chksum7s&�zPackage._chksumcCs
||_dSr)r�r�valrrrr!EscCs|jtjkSr)�reponamerZCMDLINE_REPO_NAME�rrrrrIszPackage._from_cmdlinecCs|jtjkSr)r$r�SYSTEM_REPO_NAMEr%rrr�_from_systemMszPackage._from_systemcCs*d}|jr|jj�|�}|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$)rZpkgreporrr�
_from_repoQszPackage._from_repocCs|jr|jj�|�SdS)N�)r'r
r)r*r%rrr�	from_repo`szPackage.from_repocCstj�|���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�localPkgr%rrrr/gszPackage._headercs|jr|jStt|�jSr)r
rr�sizer%rrr�_sizepsz
Package._sizecCs
||_dSr)r
r"rrrr2vscCs"|jdurdS|j\}}t�|�Sr)Z
hdr_chksumr�hexlify)rrrrrr�_pkgidzs

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

zPackage.source_namecCsF|j�|j�r|jS|j}|j�|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)rr;rrr�
debug_name�s
zPackage.debug_namecCs |jdur|jn|j}||jS)zv
        Returns name of the debugsource package for this package.
        e.g. krb5-libs -> krb5-debugsource
        N)r:r;r>�rZsrc_namerrr�debugsource_name�szPackage.debugsource_namecCsN|js
dSzt|jj�tj|j��WStyHt	j
�dt|���Yn0dS)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�
StopIterationrrZPackageNotFoundErrorrr%rrr�
get_header�szPackage.get_headercCs |jdur|jn|j}||jS)z�
        returns name of debuginfo package for source package of given package
        e.g. krb5-libs -> krb5-debuginfo
        N)r:r;r=rArrr�source_debug_name�szPackage.source_debug_namecCs
t|j�S)z: Always type it to int, rpm bindings expect it like that. )�intrDr%rrr�idx�szPackage.idxcCs|jSr�r$r%rrr�repoid�szPackage.repoidcCs|j|jt|j�|j|jfSr)r;�archrr �v�rr%rrr�pkgtup�szPackage.pkgtupcCs|jr|jS|jj|jSr)rr
Zreposr$r%rrrr*�szPackage.repocCs
||_dSr)rr"rrrr*�scCs |jtjkrdS|jjj�|�Sr)rKrr&r
r)r.Zget_reason_namer%rrr�reason�szPackage.reasoncCs|jSr)rr%rrr�relativepath�szPackage.relativepathcCs|jSr)rLr%rrr�a�sz	Package.acCs|jSr)Zepochr%rrrr �sz	Package.ecCs|jSr)�versionr%rrrrM�sz	Package.vcCs|jSr)�releaser%rrrrN�sz	Package.rcCs|jSrrJr%rrr�ui_from_reposzPackage.ui_from_repocCs|�|�dkS�Nr�Zevr_cmp�r�pkgrrr�evr_eqszPackage.evr_eqcCs|�|�dkSrVrWrXrrr�evr_gt	szPackage.evr_gtcCs|�|�dkSrVrWrXrrr�evr_lt
szPackage.evr_ltcCs|jSr)Zmedianrr%rrr�
getDiscNumszPackage.getDiscNumcCsr|jr|jS|j}|jj��rH|jrH|j�d�rHtj�	|�
�|�d��S|��s\tj�
|�}tj�	|j|�d��S)z� Package's location in the filesystem.

            For packages in remote repo returns where the package will be/has
            been downloaded.
        �file://�/)rrr*r�isLocal�baseurl�
startswith�os�path�joinZget_local_baseurl�lstrip�
_is_local_pkg�basename�pkgdir)r�locrrrr0szPackage.localPkg��http�ftp�file�httpscCs |js|jrdS|j�|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)rZschemesrrrrp$s	zPackage.remote_locationcCsJ|jr
dSd|jvr$|j�d�s$dS|jpH|jj��oH|jpH|j�d�S)NTz://r^F)r'rrbrr*rr`rar%rrrrg1s�zPackage._is_local_pkgcCs*|jj��r|��s|j��S|jjSdSr)r*rr`rgZcache_pkgdirrir%rrrri:s
zPackage.pkgdircCs0|jdurdS|j\}}t�|�t�|���fS)z] Return the chksum type and chksum string how the legacy yum expects
            it.
        N)NN)r!rZchksum_namerr3�decode)rrrrrr�returnIdSumBs

zPackage.returnIdSumc
Csx|jrtd��|jrdS|��\}}ztj�||��|�WStjj	yr}zt
j�t
|���WYd}~n
d}~00dS)Nz$Can not verify an installed package.T)r'�
ValueErrorrrrrrZchecksum_checkr0rrrrrr)rrrr rrr�verifyLocalPkgLszPackage.verifyLocalPkg)rk),�__name__�
__module__�__qualname__�__doc__r=r>r	�propertyr!�setterrr'r+r-r/r2r4r:r@rBrFrGrIrKrOr*rPrQrRr rMrNrUrZr[r\r]r0rprgrirrrt�
__classcell__rrrrr*s�




























	

r)rxZ
__future__rrZdnf.i18nrrZdnf.exceptionsrZdnf.rpmZdnf.yum.miscrZlibdnf.errorrZlibdnf.utilsZloggingrcr.Z	getLogger�loggerrrrrr�<module>s