3 šgt`*0 ã @ s¤ d dl mZ d dl mZ d dlmZmZ d dlmZ d dlZd dl Zd dl Zd dlZd dlZd dl Zd dlZd dlZd dlZd dlZejjG dd„ dejjƒƒZdS )é )Úabsolute_import)Úunicode_literals)Ú_Úlogger)ÚOptionParserNc sž e Zd ZdgZedƒZ‡ fdd„Zedd„ ƒZdd„ Z d d „ Z dd„ Zd d„ Zdd„ Z dd„ Zdd„ Zd dd„Zd!dd„Zedd„ ƒZdd„ Zdd„ Z‡ ZS )"ÚDownloadCommandZdownloadz%Download package to current directoryc s t t| ƒj|ƒ d | _d | _d S )N)Úsuperr Ú__init__ÚoptsÚparser)ÚselfÚcli)Ú __class__© ú/usr/lib/python3.6/download.pyr + s zDownloadCommand.__init__c C sÒ | j ddtdƒd� | j ddtdƒd� | j d dtd ƒd� | j ddtdƒd� | j d ddg tjdtdƒd� | j ddtdƒd� | j ddtdƒd� | j ddddtdƒd� | j ddddd d!gg td"ƒd#� d S )$NÚpackagesú+zpackages to download)ÚnargsÚhelpz--sourceÚ store_truezdownload the src.rpm instead)Úactionr z--debuginfoz'download the -debuginfo package insteadz --debugsourcez)download the -debugsource package insteadz--archz --archlistÚarchesz[arch]z5limit the query to packages of given architectures.)ÚdestÚdefaultr Úmetavarr z --resolvez(resolve and download needed dependenciesz --alldepsz^when running with --resolve, download all dependencies (do not exclude already installed ones)z--urlz--urlsÚurlzJprint list of urls where the rpms can be downloaded instead of downloading)r r r z--urlprotocolsÚappendÚhttpÚhttpsZrsyncÚftpz4when running with --url, limit to specific protocols)r Úchoicesr r )Úadd_argumentr r Z_SplitCallback)r r r r Ú set_argparser0 s* zDownloadCommand.set_argparserc C sŒ | j j}d|_d|_| jjr*| jjr*d|_| jjr>| j j jƒ | jjsN| jj rZ| j j jƒ | jjrr| jj| j j_ntjjtjƒ ƒ| j j_d S )NTF)r ÚdemandsZsack_activationZavailable_reposr ÚresolveZalldepsZload_system_repoÚsourceÚbaseZreposZenable_source_reposÚ debuginfoÚdebugsourceZenable_debug_reposÚdestdirÚconfÚdnfÚi18nÚucdÚosÚgetcwd)r r# r r r Ú configureK s zDownloadCommand.configurec C s | j j r.| j j r.| j j r.| j| j jƒ}nXg }| j jrN|j| j| j jƒƒ | j jrj|j| j| j jƒƒ | j jr†|j| j | j jƒƒ | j j røxd|D ]\}|jtj kr”|j| j jd�}|rÂt|ƒ q”tdƒ|j }| jjjrætjj|ƒ‚tj|ƒ q”W dS | j|ƒ dS )zExecute the util action here.)Úschemesz$Failed to get mirror for package: %sN)r r% r' r( Ú_get_pkg_objs_rpmsr ÚextendÚ_get_pkg_objs_sourceÚ_get_pkg_objs_debuginfoÚ_get_pkg_objs_debugsourcer ÚrepoidÚhawkeyÚCMDLINE_REPO_NAMEZremote_locationZurlprotocolsÚprintr Únamer&