AlkantarClanX12

Your IP : 18.222.166.127


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

3

��fLQ�@sFddlmZddlmZddlmZmZddlZddlZddl	Zddl
ZddlZddlZddl
ZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZddlZdZ dZ!ej"ej#dZ$dej%e$�ej&fZ'd	e'e!fd
e'e fdd�Z(ej)d
�Z*dd�Z+dd�Z,d-dd�Z-dd�Z.Gdd�de/�Z0Gdd�de1�Z2Gdd�dej3j4�Z5Gdd�de/�Z6Gdd �d ej7j8�Z9Gd!d"�d"ej3j:�Z;Gd#d$�d$e;�Z<Gd%d&�d&e;�Z=Gd'd(�d(ej3j:�Z>ej7j?j@ZAej7j?jBZCej7j?jDZEGd)d*�d*ej7jF�ZGGd+d,�d,ejHjI�Z?dS).�)�absolute_import)�unicode_literals)�ucd�_N�packagesZ
mirrorlistz-_.:z(?P<repoid>[%s]+)\-[%s]{16}z>^%s\/.*((xml|yaml)(\.gz|\.xz|\.bz2|.zck)?|asc|cachecookie|%s)$z^%s\/%s\/.+rpm$z^.+(solv|solvx)$)�metadatarZdbcache�dnfcCstjjj|�}|dkrdS|S)zAReturn index of an invalid character in the repo ID (if present).rN)�libdnf�repo�RepoZverifyId)Zrepo_idZ
first_invalid�r�/usr/lib/python3.6/repo.py�repo_id_invalidHsrcGs8x"|D]}|||�}|dk	r|SqWttd�|��dS)Nz"no matching payload factory for %s)�
ValueErrorr)�pkg�progressZ	factories�fn�ploadrrr
�_pkg2payloadOs


rTcCs�dd�}|jj�dd�t||d�D�}t�}ytjjjtjj|�|�Wn,t	k
rv}zt
|�|_WYdd}~XnX|j�|jj
�|_xj|D]b}|j�}|dks�|jd�r�q�|j�}	|	j}
|
j}|dkr�|jj|�q�|jjj�|g|j|<q�W|S)NcSst|d�S)NZdelta)�hasattr)�payloadrrr
�_download_sort_keyYsz._download_payloads.<locals>._download_sort_keycSsg|]}|j��qSr)�_librepo_target)�.0rrrr
�
<listcomp>]sz&_download_payloads.<locals>.<listcomp>)�keyzNot finishedzAlready downloaded)�err�clear�sorted�_DownloadErrorsr	r
�
PackageTargetZdownloadPackagesZVectorPPackageTarget�RuntimeError�str�_fatal�wait�copy�_recoverableZgetErr�
startswithZgetCallbacks�
package_ploadr�_skipped�add�_repoZexpire�_pkg_irrecoverable)�payloadsZdrpmZ	fail_fastrZtargets�errs�eZtgtr�	callbacksrrrrr
�_download_payloadsWs0

r1cCsL|\}}x:|D]2}|j}||kr,||j7}q||j7}||j7}qW||fS)N)r�
download_size�
_full_size)Zsavingr-r.�realZfullrrrrr
�_update_savingxs


r5c@s>eZdZdd�Zdd�Zedd��Zejdd��Zdd	�Zd
S)rcCsi|_i|_d|_t�|_dS)N)r,�_val_recoverabler#�setr))�selfrrr
�__init__�sz_DownloadErrors.__init__cCs"|jr|jS|jrd|jgiSiS)N�)r,r#)r8rrr
�_irrecoverable�s
z_DownloadErrors._irrecoverablecCs|jS)N)r6)r8rrr
r&�sz_DownloadErrors._recoverablecCs
||_dS)N)r6)r8Znew_dctrrr
r&�scCs|j|jkrdS|jS)Nr)rr)r2)r8rrrr
�_bandwidth_used�sz_DownloadErrors._bandwidth_usedN)	�__name__�
__module__�__qualname__r9r;�propertyr&�setterr<rrrr
r�s
rc@seZdZdd�ZdS)�_DetailedLibrepoErrorcCs,tj|�|jd|_|jd|_||_dS)Nr�)�	Exceptionr9�argsZlibrepo_codeZlibrepo_msg�
source_url)r8Zlibrepo_errrFrrr
r9�s
z_DetailedLibrepoError.__init__N)r=r>r?r9rrrr
rB�srBc@seZdZdd�ZdS)�_NullKeyImportcCsdS)NTr)r8�id�userid�fingerprint�url�	timestamprrr
�_confirm�sz_NullKeyImport._confirmN)r=r>r?rMrrrr
rG�srGc@s eZdZdd�Zedd��ZdS)�MetadatacCs
||_dS)N)r+)r8r
rrr
r9�szMetadata.__init__cCs
|jj�S)N)r+�fresh)r8rrr
rO�szMetadata.freshN)r=r>r?r9r@rOrrrr
rN�srNcs4eZdZ�fdd�Zdd�Zdd�Zdd�Z�ZS)	�PackageTargetCallbackscstt|�j�||_dS)N)�superrPr9r()r8r()�	__class__rr
r9�szPackageTargetCallbacks.__init__cCs|jjd||�dS)Nr)r(�_end_cb)r8�status�msgrrr
�end�szPackageTargetCallbacks.endcCs|jjd||�dS)Nr)r(�_progress_cb)r8�totalToDownload�
downloadedrrr
r�szPackageTargetCallbacks.progresscCs|jjd||�dS)Nr)r(�_mirrorfail_cb)r8rUrKrrr
�
mirrorFailure�sz$PackageTargetCallbacks.mirrorFailure)r=r>r?r9rVrr[�
__classcell__rr)rRr
rP�srPcsHeZdZ�fdd�Zdd�Zdd�Zdd�Zed	d
��Zdd�Z	�Z
S)
�PackagePayloadcs$tt|�j|�t|�|_||_dS)N)rQr]r9rPr0r)r8rr)rRrr
r9�s
zPackagePayload.__init__cCsRtjj}|dkrtjj}n$|jd�r(dS|tjjjkr>tjj	}|j
j|||�dS)z"End callback to librepo operation.NzNot finished)r�callbackZ
STATUS_FAILEDZ	STATUS_OKr'r	r
�PackageTargetCBZTransferStatus_ALREADYEXISTSZSTATUS_ALREADY_EXISTSrrV)r8�cbdataZ	lr_statusrUrTrrr
rS�s

zPackagePayload._end_cbcCs|jj|tjj|�dS)N)rrVrr^Z
STATUS_MIRROR)r8r`rrKrrr
rZ�szPackagePayload._mirrorfail_cbcCsXy|jj||�Wn@tk
rRtj�\}}}tj|||�}tjdj|��YnXdS)Nr:)	rrD�sys�exc_info�	traceback�format_exception�logger�critical�join)r8r`�total�done�exc_type�	exc_value�
exc_traceback�except_listrrr
rW�szPackagePayload._progress_cbcCs|jS)N)r2)r8rrr
r3�szPackagePayload._full_sizecCs�|j}|j}tjj|�|d||j|j|jd�}|j|j	��t
jj|jj
|d|d|d|d|d|d|d	d
d
|j�S)NT)�dest�resumer`Z
progresscbZendcbZmirrorfailurecb�relative_urlrn�
checksum_type�checksum�expectedsize�base_urlror)r�pkgdirr�util�
ensure_dirrWrSrZ�update�_target_paramsr	r
r r+r0)r8rruZ
target_dctrrr
r�s 
zPackagePayload._librepo_target)r=r>r?r9rSrZrWr@r3rr\rr)rRr
r]�sr]c@s(eZdZdd�Zdd�Zedd��ZdS)�
RPMPayloadcCstjj|jj�S)N)�os�path�basenamer�location)r8rrr
�__str__szRPMPayload.__str__cCsT|j}|j�\}}tjjj|�}|tjjjkr>tjt	d�|�|j
|||j|jd�S)Nzunsupported checksum type: %s)rprqrrrsrt)
rZreturnIdSumr	r
r ZchecksumTypeZChecksumType_UNKNOWNre�warningrr~�downloadsize�baseurl)r8rZctypeZcsumZ
ctype_coderrr
ryszRPMPayload._target_paramscCs|jjS)zTotal size of the download.)rr�)r8rrr
r2szRPMPayload.download_sizeN)r=r>r?rryr@r2rrrr
rzsrzcs@eZdZ�fdd�Zdd�Zdd�Zdd�Zed	d
��Z�Z	S)�RemoteRPMPayloadcs�tt|�jd|�||_d|_||_|jjp.d|jjjd�}t	j
|jd��j�dd�}d|}t
jj|jj|d�|_tjj|j�t
jj|j|j�jd	��|_dS)
NZ
unused_objectrr:Zbasearch�utf8�zcommandline-r�/)rQr�r9�remote_location�remote_size�confZ
releasever�
substitutions�get�hashlibZsha256�encodeZ	hexdigestr{r|rgZcachedirrurrvrwr�lstripZ
local_path)r8r�r�r�sZdigestZrepodir)rRrr
r9szRemoteRPMPayload.__init__cCstjj|j�S)N)r{r|r}r�)r8rrr
r)szRemoteRPMPayload.__str__cCs^||_y|jj||�Wn@tk
rXtj�\}}}tj|||�}tjdj	|��YnXdS)Nr:)
r�rrDrarbrcrdrerfrg)r8r`rhrirjrkrlrmrrr
rW,szRemoteRPMPayload._progress_cbcCs<tjj|jjtjj|j�|j	dddtjj
|j�ddd|j�S)NrT)r	r
r r��_configr{r|r}r�ru�dirnamer0)r8rrr
r5sz RemoteRPMPayload._librepo_targetcCs|jS)zTotal size of the download.)r�)r8rrr
r2;szRemoteRPMPayload.download_size)
r=r>r?r9rrWrr@r2r\rr)rRr
r�s
	r�cszeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Ze	d
d��Z
e	dd��Zejdd��Zdd�Z
dd�Z�ZS)�	MDPayloadcs.tt|�j|�d|_d|_d|_t�|_dS)Nr:rF)rQr�r9�_text�_download_size�fastest_mirror_runningr7�mirror_failures)r8r)rRrr
r9Cs
zMDPayload.__init__cCstjjr|jS|jjd�SdS)Nzutf-8)r�pycompZPY3r�r�)r8rrr
rJszMDPayload.__str__cCs|jS)N)r�)r8rrr
�__unicode__PszMDPayload.__unicode__cCs||_|jj||�dS)N)r�r)r8r`rhrirrr
rWSszMDPayload._progress_cbcCs\|tjjjkr"td�|}d|_n*|tjjjkrH|jrH|rBd|nd}ndS|jj|�dS)Nz,determining the fastest mirror (%s hosts).. Tz
error: %s
zdone.
)	r	r
�RepoCBZFastestMirrorStage_DETECTIONrr�ZFastestMirrorStage_STATUSr�message)r8r`�stage�datarUrrr
�_fastestmirror_cbWszMDPayload._fastestmirror_cbcCs&|jj|�d||f}tj|�dS)Nzerror: %s (%s).)r�r*re�debug)r8r`rUrKrrrr
�_mirror_failure_cbcszMDPayload._mirror_failure_cbcCs|jS)N)r�)r8rrr
r2hszMDPayload.download_sizecCs|jS)N)�	_progress)r8rrr
rlszMDPayload.progresscCs|dkrtjj�}||_dS)N)rr^�NullDownloadProgressr�)r8rrrr
rps
cCs||_|jjdd�dS)NrCr)r�r�start)r8�textrrr
r�vszMDPayload.startcCsd|_|jj|dd�dS)Nr)r�rrV)r8rrr
rVzsz
MDPayload.end)r=r>r?r9rr�rWr�r�r@r2rrAr�rVr\rr)rRr
r�Asr�csLeZdZ�fdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	�Z
S)�
RepoCallbackscs tt|�j�||_|j|_dS)N)rQr�r9r+�	_md_pload)r8r
)rRrr
r9�szRepoCallbacks.__init__cCs|jj|�dS)N)r�r�)r8Zwhatrrr
r��szRepoCallbacks.startcCs|jj�dS)N)r�rV)r8rrr
rV�szRepoCallbacks.endcCs|jjd||�dS)Nr)r�rW)r8rXrYrrr
r�szRepoCallbacks.progresscCs|jjd||�dS)N)r�r�)r8r�Zptrrrr
�
fastestMirror�szRepoCallbacks.fastestMirrorcCs|jjd|||�dS)Nr)r�r�)r8rUrKrrrr
�handleMirrorFailure�sz!RepoCallbacks.handleMirrorFailurecCs|jjj|||||�S)N)r+�_key_importrM)r8rHrIrJrKrLrrr
�
repokeyImport�szRepoCallbacks.repokeyImport)r=r>r?r9r�rVrr�r�r�r\rr)rRr
r��sr�cseZdZeZd7�fdd�	Zedd��Zedd��Zej	dd��Zed	d
��Z
dd�Ze
j	d
d
��Z
edd��Zedd��Z
e
j	dd��Z
dd�Zdd�Z�fdd�Zdd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�Zd9d5d6�Z�ZS):rNcs�tt|�j||d�|jjj�tjj|r.|nd|j�|_t	t
jj��|_
t|�|_|jjj�|jj|j�d|_t�|_d|_|jj|r�|jr�tn|j�|r�|jj|j�t
jjj�|_|dk	r�|jnd|_dS)N)Zsection�parentr:T) rQrr9r��thisZdisownr	r
r+r�rr^r�r�r�Z
_callbacksZsetCallbacks�_pkgdirrGr�rZsetSyncStrategyZ	cacheonly�SYNC_ONLY_CACHE�DEFAULT_SYNCZsetSubstitutionsr�r�Z
SubstitutionsZ_substitutionsZcheck_config_file_ageZ_check_config_file_age)r8�nameZparent_conf)rRrr
r9�s
z
Repo.__init__cCs
|jj�S)N)r+ZgetId)r8rrr
rH�szRepo.idcCs
|jj�S)N)r+ZgetRepoFilePath)r8rrr
�repofile�sz
Repo.repofilecCs|jj|�dS)N)r+ZsetRepoFilePath)r8�valuerrr
r��scCs|jj�r|jj�S|j�S)N)r+ZisLocalZgetLocalBaseurl�cache_pkgdir)r8rrr
ru�s

zRepo.pkgdircCs$|jdk	r|jStjj|jj�t�S)N)r�r{r|rgr+�getCachedir�_PACKAGES_RELATIVE_DIR)r8rrr
r��s
zRepo.cache_pkgdircCs
||_dS)N)r�)r8�valrrr
ru�scCstjj|jj�d�S)NZpubring)r{r|rgr+r�)r8rrr
�_pubring_dir�szRepo._pubring_dircCs
|jj�S)N)r+ZgetLoadMetadataOther)r8rrr
�load_metadata_other�szRepo.load_metadata_othercCs|jj|�dS)N)r+ZsetLoadMetadataOther)r8r�rrr
r��scCs|j|jkS)N)rH)r8�otherrrr
�__lt__�szRepo.__lt__cCsd|jj|jfS)Nz<%s %s>)rRr=rH)r8rrr
�__repr__�sz
Repo.__repr__cstt|�j||�dS)N)rQr�__setattr__)r8r�r�)rRrr
r��szRepo.__setattr__cCs|jj�dS)N)r+�disable)r8rrr
r��szRepo.disablecCs|jj�dS)N)r+�enable)r8rrr
r��szRepo.enablecCs|jj|�dS)a/Ask for additional repository metadata type to download.

        Given metadata_type is appended to the default metadata set when
        repository is downloaded.

        Parameters
        ----------
        metadata_type: string

        Example: add_metadata_type_to_download("productid")
        N)r+ZaddMetadataTypeToDownload)r8�
metadata_typerrr
�add_metadata_type_to_download�s
z"Repo.add_metadata_type_to_downloadcCs|jj|�dS)aIStop asking for this additional repository metadata type
        in download.

        Given metadata_type is no longer downloaded by default
        when this repository is downloaded.

        Parameters
        ----------
        metadata_type: string

        Example: remove_metadata_type_from_download("productid")
        N)r+ZremoveMetadataTypeFromDownload)r8r�rrr
�"remove_metadata_type_from_downloadsz'Repo.remove_metadata_type_from_downloadcCs|jj|�S)z�Return path to the file with downloaded repository metadata of given type.

        Parameters
        ----------
        metadata_type: string
        )r+ZgetMetadataPath)r8r�rrr
�get_metadata_pathszRepo.get_metadata_pathcCs|jj|�S)z�Return content of the file with downloaded repository metadata of given type.

        Content of compressed metadata file is returned uncompressed.

        Parameters
        ----------
        metadata_type: string
        )r+ZgetMetadataContent)r8r�rrr
�get_metadata_content!s
zRepo.get_metadata_contentcCs�d}z�y|jj�}Wnttjjtfk
r�}zP|jjrhd|j}x|jjD]}|d|7}qJWt	j
|�tjj
t|���WYdd}~XnXWdt�|j_Xt|j�|_|S)a�Load the metadata for this repo.

        Depending on the configuration and the age and consistence of data
        available on the disk cache, either loads the metadata from the cache or
        downloads them from the mirror, baseurl or metalink.

        This method will by default not try to refresh already loaded data if
        called repeatedly.

        Returns True if this call to load() caused a fresh metadata download.

        Fz7Errors during downloading metadata for repository '%s':z
  - %sN)r+�loadr	�error�Errorr!r�r�rHrer�r�
exceptionsZ	RepoErrorr"r7rNr)r8�retr/rUZfailurerrr
r�-s

&z	Repo.loadcCsP|js|jjd�|jrL|jdkr&dS|jj�}|jj�rDtd|�}d|fSdS)	a)Get the number of seconds after which the cached metadata will expire.

        Returns a tuple, boolean whether there even is cached metadata and the
        number of seconds it will expire in. Negative number means the metadata
        has expired already, None that it never expires.

        FrCTNr���)TN)Fr)rr+Z	loadCacheZmetadata_expireZgetExpiresInZ	isExpired�min)r8Z
expirationrrr
�_metadata_expire_inJs



zRepo._metadata_expire_incCs
||_dS)N)r�)r8Z
key_importrrr
�_set_key_import]szRepo._set_key_importcCs||j_dS)N)r�r)r8rrrr
�set_progress_bar`szRepo.set_progress_barcCs
|jj�S)zoReturns user defined http headers.

        Returns
        -------
        headers : tuple of strings
        )r+ZgetHttpHeaders)r8rrr
�get_http_headersdszRepo.get_http_headerscCs|jj|�dS)aSets http headers.

        Sets new http headers and rewrites existing ones.

        Parameters
        ----------
        headers : tuple or list of strings
            Example: set_http_headers(["User-Agent: Agent007", "MyFieldName: MyFieldValue"])
        N)r+ZsetHttpHeaders)r8Zheadersrrr
�set_http_headersnszRepo.set_http_headers�http�ftp�file�httpscs@��fdd�}�sdS|jj�}|r,||�S|jr<||j�SdS)z�
        :param location: relative location inside the repo
        :param schemes: list of allowed protocols. Default is ('http', 'ftp', 'file', 'https')
        :return: absolute url (string) or None
        csZxT|D]L}�r>tjjj|�d}|�krRtjj|�jd��Sqtjj|�jd��SqWdS)Nrr�)rr�Zurlparser{r|rgr�)Zurl_listrKr�)r~�schemesrr
�schemes_filter�s
z,Repo.remote_location.<locals>.schemes_filterN)r+Z
getMirrorsr�)r8r~r�r�Zmirrorsr)r~r�r
r�{s

zRepo.remote_location)NN�r�r�r�r�)r�)r=r>r?�SYNC_TRY_CACHEr�r9r@rHr�rArur�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r\rr)rRr
r�s6


r)T)JZ
__future__rrZdnf.i18nrrZdnf.callbackrZdnf.confZdnf.conf.substitutionsZ	dnf.constZ
dnf.cryptoZdnf.exceptionsZdnf.loggingZ
dnf.pycompZdnf.utilZdnf.yum.miscZlibdnf.errorr	Zlibdnf.repo�	functoolsr�ZhawkeyZlogging�operatorr{�reZshutil�stringraZtimercr�Z_MIRRORLIST_FILENAMEZ
ascii_lettersZdigitsZ
_REPOID_CHARS�escapeZ	hexdigitsZ_CACHEDIR_REZCACHE_FILESZ	getLoggerrerrr1r5�objectrrDrBr^Z	KeyImportrGrNr
r_rPZPayloadr]rzr�r�rZSyncStrategy_LAZYZ	SYNC_LAZYZSyncStrategy_ONLY_CACHEr�ZSyncStrategy_TRY_CACHEr�r�r�r�ZRepoConfrrrr
�<module>sl




!
8&?