a
    ˆ�ÁjÏ�  ã                   @   s8  d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	 ddl
ZddlZddlZddlZddlZddlZddlZe d¡Ze	d	ƒd
 Ze	dƒd Ze	dƒZe	dƒZdd„ Zd$dd„Zdd„ ZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZ G d d!„ d!eƒZ!G d"d#„ d#eƒZ"dS )%z<
Classes for subcommands of the yum command line interface.
é    )Úprint_function)Úunicode_literals)ÚCleanCommandLock)ÚOptionParser)Ú_NÚdnfz+To diagnose the problem, try running: '%s'.zrpm -Va --nofiles --nodigestzDYou probably have corrupted RPMDB, running '%s' might fix the issue.zrpm --rebuilddba  You have enabled checking of packages via GPG keys. This is a good thing.
However, you do not have any GPG public keys installed. You need to download
the keys for packages you wish to install and install them.
You can do that by running the command:
    rpm --import public.gpg.key


Alternatively you can specify the url to the key you would like to use
for a repository in the 'gpgkey' option in a repository section and {prog}
will install it for you.

For more information contact your distribution or package provider.zgCannot check for release updates.
The ReleaseNotification dnf plugin has not been properly initialized.c                 C   sj   | j jsdS |  ¡ sf| j ¡ D ]F}|js.|jr|jst dt	j
tjjd�¡ t tdƒ|¡ tjj‚qdS )zªVerify that there are gpg keys for the enabled repositories in the
    rpm database.

    :param base: a :class:`dnf.Base` object.
    :raises: :class:`cli.CliError`
    Nz
%s
©ÚprogzProblem repository: %s)ÚconfZgpgcheckZ_gpg_key_checkÚreposZiter_enabledZrepo_gpgcheckZgpgkeyÚloggerZcriticalÚgpg_msgÚformatr   ÚutilÚMAIN_PROG_UPPERr   ÚcliÚCliError)Úbaser   Úrepo© r   ú=/usr/lib/python3.9/site-packages/dnf/cli/commands/__init__.pyÚ_checkGPGKey?   s    r   r   c                 C   s|   | j  ¡ rdS |D ]@}| d¡r2tj |¡r2 dS tjj |¡d }|dv r dS qt	dƒ 
d | jj¡¡}tj |¡‚dS )zÖVerify that there is at least one enabled repo.

    :param base: a :class:`dnf.Base` object.
    :param possible_local_files: the list of strings that could be a local rpms
    :raises: :class:`cli.CliError`:
    Nz.rpmr   )ÚhttpÚftpÚfileÚhttpsz*There are no enabled repositories in "{}".z", ")r   Z_any_enabledÚendswithÚosÚpathÚexistsr   ZpycompÚurlparser   r   Újoinr
   Zreposdirr   r   )r   Zpossible_local_filesZlfileÚschemeÚmsgr   r   r   Ú_checkEnabledRepoP   s    
r$   c                  C   sR   t j ¡ dd… } | D ]6}|jt jjkr|jdu r>t t	¡ q|jj
dd� qdS )z,Invoke check-release-update on check-update.NT)Zoutput_separators)r   ÚpluginZ_plugin_classesÚnameÚcallbackZUPDATE_QUERY_HOOKZ	singletonr   ÚinfoÚupdate_query_err_msgZrun_release_check)Zplugin_classesr%   r   r   r   Úrun_update_query_hookd   s    
r*   c                   @   s€   e Zd ZdZg ZdZdZdd„ Zedd„ ƒZ	edd	„ ƒZ
ed
d„ ƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚCommandz%Abstract base class for CLI commands.Ú Nc                 C   s
   || _ d S ©N©r   ©Úselfr   r   r   r   Ú__init__v   s    zCommand.__init__c                 C   s   | j jS r-   )r   r   ©r0   r   r   r   r   z   s    zCommand.basec                 C   s
   | j d S )Nr   ©Úaliasesr2   r   r   r   Ú_basecmd   s    zCommand._basecmdc                 C   s
   | j jjS r-   )r   r   Úoutputr2   r   r   r   r6   ƒ   s    zCommand.outputc                 C   s   dS )z4Define command specific options and arguments. #:apiNr   )r0   Úparserr   r   r   Úset_argparser‡   s    zCommand.set_argparserc                 C   s   dS )z*Do any command-specific pre-configuration.Nr   r2   r   r   r   Úpre_configure‹   s    zCommand.pre_configurec                 C   s   dS )z&Do any command-specific configuration.Nr   r2   r   r   r   Ú	configure�   s    zCommand.configurec                 C   s&   t |tjjƒrttfS td| ƒ‚dS )z.Get suggestions for resolving the given error.zerror not supported yet: %sN)Ú
isinstancer   Ú
exceptionsZTransactionCheckErrorÚ_RPM_VERIFYÚ_RPM_REBUILDDBÚNotImplementedError)r0   Úerrorr   r   r   Úget_error_output•   s    zCommand.get_error_outputc                 C   s   dS )zExecute the command.Nr   r2   r   r   r   Úrun›   s    zCommand.runc                 C   s   dS )z$Finalize operation after resolvementNr   r2   r   r   r   Úrun_resolved    s    zCommand.run_resolvedc                 C   s   dS )z%Finalize operations post-transaction.Nr   r2   r   r   r   Úrun_transaction¤   s    zCommand.run_transaction)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r4   ÚsummaryÚoptsr1   Úpropertyr   r5   r6   r8   r9   r:   rA   rB   rC   rD   r   r   r   r   r+   o   s$   


r+   c                	   @   sR   e Zd ZdZdZedƒZdZddddd	d
ddeh	Ze	dd„ ƒZ
dd„ Zdd„ ZdS )ÚInfoCommandzRA class containing methods needed by the cli to execute the
    info command.
    )r(   Úifz4display details about a package or group of packagesÚallÚ	availableÚ	installedÚextrasÚupdatesÚupgradesÚ
autoremoveÚrecentÚ	obsoletesc              	   C   sô   |  ¡ }|jddddd tdƒd� |jddddtd	ƒd
� |jddddtdƒd
� |jddddtdƒd
� |jddddtdƒd
� |jddddtdƒd
� |jddddtdƒd
� |jddddtdƒd
� |jddtdƒ| j| jtjtdƒd� d S ) Nú--allÚ_packages_actionÚstore_constrN   úshow all packages (default)©ÚdestÚactionÚconstÚdefaultÚhelpú--availablerO   úshow only available packages©r\   r]   r^   r`   ú--installedrP   úshow only installed packagesú--extrasrQ   úshow only extras packagesú	--updatesrS   úshow only upgrades packagesú
--upgradesú--autoremoverT   úshow only autoremove packagesú--recentrU   ú#show only recently changed packagesÚpackagesÚ*ÚPACKAGEzPackage name specification©ÚnargsÚmetavarÚchoicesr_   r]   r`   )Úadd_mutually_exclusive_groupÚadd_argumentr   Ú
pkgnarrowsÚDEFAULT_PKGNARROWr   ÚPkgNarrowCallback)Úclsr7   Únarrowsr   r   r   r8   ³   sL    þþþþþþþþýzInfoCommand.set_argparserc                 C   s|   | j j}d|_| jjr"| jj| j_| jjdkr4d|_| jjrd| jjr\| j  dd| jj ¡ nd| j_| jjdkrxd| j_d S )NTrP   ú--obsoletesú--rV   rR   rS   )	r   ÚdemandsÚsack_activationrJ   rX   Úpackages_actionÚavailable_reposrV   Ú_option_conflict©r0   r   r   r   r   r:   Ó   s    zInfoCommand.configurec                 C   s&   | j  | j¡ | j d| jj| jj¡S )Nr(   ©r   Ú _populate_update_security_filterrJ   r   Úoutput_packagesr�   ro   r2   r   r   r   rB   â   s    ÿzInfoCommand.runN)rE   rF   rG   rH   r4   r   rI   ry   rx   Úclassmethodr8   r:   rB   r   r   r   r   rL   ¨   s   
ÿ
rL   c                   @   s$   e Zd ZdZdZedƒZdd„ ZdS )ÚListCommandzRA class containing methods needed by the cli to execute the
    list command.
    )ÚlistZlsz$list a package or groups of packagesc                 C   s&   | j  | j¡ | j d| jj| jj¡S )NrŠ   r…   r2   r   r   r   rB   ï   s    ÿzListCommand.runN)rE   rF   rG   rH   r4   r   rI   rB   r   r   r   r   r‰   ç   s   r‰   c                   @   s8   e Zd ZdZdZedƒZedd„ ƒZdd„ Z	dd	„ Z
d
S )ÚProvidesCommandzVA class containing methods needed by the cli to execute the
    provides command.
    )ÚprovidesZwhatprovidesZprovZwpz*find what package provides the given valuec                 C   s   | j ddtdƒtdƒd� d S )NÚ
dependencyú+ZPROVIDEz#Provide specification to search for©rs   rt   r`   ©rw   r   ©r7   r   r   r   r8   ý   s    ÿzProvidesCommand.set_argparserc                 C   s   | j j}d|_d|_d|_d S ©NTF)r   r   r‚   Zfresh_metadatar€   r„   r   r   r   r:     s    zProvidesCommand.configurec                 C   s   t  tdƒ¡ | j | jj¡S )NzSearching Packages: )r   Údebugr   r   rŒ   rJ   r�   r2   r   r   r   rB     s    zProvidesCommand.runN©rE   rF   rG   rH   r4   r   rI   Ústaticmethodr8   r:   rB   r   r   r   r   r‹   õ   s   
r‹   c                   @   s8   e Zd ZdZdZedƒZedd„ ƒZdd„ Z	dd	„ Z
d
S )ÚCheckUpdateCommandzZA class containing methods needed by the cli to execute the
    check-update command.
    )úcheck-updatezcheck-upgradez$check for available package upgradesc                 C   s0   | j ddddtdƒd� | j ddtd	ƒd
� d S )Nz--changelogsÚ
changelogsFÚ
store_truezshow changelogs before update)r\   r_   r]   r`   ro   rp   rq   )rs   rt   r�   r‘   r   r   r   r8     s
    þz CheckUpdateCommand.set_argparserc                 C   s6   | j j}d|_d|_d|_| jjr(d|_t| jƒ d S ©NT)	r   r   r€   r‚   Zplugin_filtering_enabledrJ   r˜   r$   r   r„   r   r   r   r:     s    zCheckUpdateCommand.configurec                 C   sX   t ƒ  | jj| jdd� | jj| jjd| jjd�}|r@d| jj_	| jj
jrT| j ¡  d S )NZgte)Zcmp_typeT)Úprint_r˜   éd   )r*   r   r†   rJ   r   Úcheck_updatesro   r˜   r   Úsuccess_exit_statusr
   Zautocheck_running_kernelZ_check_running_kernel©r0   Úfoundr   r   r   rB   $  s    ÿ

zCheckUpdateCommand.runNr”   r   r   r   r   r–     s   
	r–   c                       s  e Zd ZdZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd	„ d	eƒZG d
d„ deƒZ	G dd„ deƒZ
G dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZeeeee	e
eeeeehZdZedƒZ‡ fdd„Zdd„ Zdd„ Zd d!„ Z‡  ZS )"ÚRepoPkgsCommandz2Implementation of the repository-packages command.c                   @   s$   e Zd ZdZdZdd„ Zdd„ ZdS )z%RepoPkgsCommand.CheckUpdateSubCommandú'Implementation of the info sub-command.)r—   c                 C   s   | j j}d|_d|_d S rš   )r   r   r‚   r€   r„   r   r   r   r:   <  s    z/RepoPkgsCommand.CheckUpdateSubCommand.configurec                 C   s*   | j j| jj| jdd�}|r&d| jj_dS )ú?Execute the command with respect to given arguments *cli_args*.T)r›   rœ   N)r   r�   rJ   Ú	pkg_specsÚreponamer   r   rž   rŸ   r   r   r   Úrun_on_repoA  s
    ÿz1RepoPkgsCommand.CheckUpdateSubCommand.run_on_repoN©rE   rF   rG   rH   r4   r:   r¦   r   r   r   r   ÚCheckUpdateSubCommand7  s   r¨   c                   @   s$   e Zd ZdZdZdd„ Zdd„ ZdS )zRepoPkgsCommand.InfoSubCommandr¢   )r(   c                 C   sh   | j j}d|_| jjr"| jj| j_| jjdkr4d|_| jjrd| jjr\| j  dd| jj ¡ nd| j_d S )NTrP   r}   r~   rV   )	r   r   r€   rJ   Ú_pkg_specs_actionÚpkg_specs_actionr‚   rV   rƒ   r„   r   r   r   r:   M  s    z(RepoPkgsCommand.InfoSubCommand.configurec                 C   s.   | j  | j¡ | j d| jj| jj| j¡ dS )r£   r(   N©r   r†   rJ   r   r‡   rª   r¤   r¥   r2   r   r   r   r¦   Z  s    
ÿz*RepoPkgsCommand.InfoSubCommand.run_on_repoNr§   r   r   r   r   ÚInfoSubCommandH  s   r¬   c                   @   s$   e Zd ZdZdZdd„ Zdd„ ZdS )z!RepoPkgsCommand.InstallSubCommandz*Implementation of the install sub-command.)Úinstallc                 C   s,   | j j}d|_d|_d|_d|_tj|_d S rš   ©	r   r   r‚   r€   Ú	resolvingÚ	root_userr   ÚREADÚclean_command_lockr„   r   r   r   r:   e  s    z+RepoPkgsCommand.InstallSubCommand.configurec                 C   sô   | j  | j¡ t| j| j ƒ d}| jjshz| j d| j¡ W n$ tj	j
y`   t tdƒ¡ Y qÜ0 d}nt| jjD ]j}z| j || j¡ W nL tj	j
yÔ } z0d |j| jjj |¡¡}t |¡ W Y d }~qpd }~0 0 d}qp|sðtj	 tdƒ¡‚d S )NFrp   úNo package available.Tz{}: {}zNo packages marked for install.)r   r†   rJ   r   r   r¤   r­   r¥   r   r<   ÚMarkingErrorr   r(   r   r   Úvaluer6   ÚtermÚboldÚError)r0   ÚdoneÚpkg_specÚer#   r   r   r   r¦   m  s$     z-RepoPkgsCommand.InstallSubCommand.run_on_repoNr§   r   r   r   r   ÚInstallSubCommand`  s   r¼   c                   @   s   e Zd ZdZdZdd„ ZdS )zRepoPkgsCommand.ListSubCommandz'Implementation of the list sub-command.)rŠ   c                 C   s.   | j  | j¡ | j d| jj| jj| j¡ dS )r£   rŠ   Nr«   r2   r   r   r   r¦   �  s    
ÿz*RepoPkgsCommand.ListSubCommand.run_on_repoN)rE   rF   rG   rH   r4   r¦   r   r   r   r   ÚListSubCommandŠ  s   r½   c                   @   s$   e Zd ZdZdZdd„ Zdd„ ZdS )z RepoPkgsCommand.MoveToSubCommandz*Implementation of the move-to sub-command.)zmove-toc                 C   s,   | j j}d|_d|_d|_d|_tj|_d S rš   ©	r   r   r€   r‚   r¯   r°   r   r±   r²   r„   r   r   r   r:   š  s    z*RepoPkgsCommand.MoveToSubCommand.configurec                 C   sŽ  t | j| jƒ d}| jjs’z| jjd| jd� W nZ tjj	yT   t
 tdƒ¡ Y n< tjjyv   t
 tdƒ¡ Y n tjjyŠ   Y n0 d}nâ| jjD ]Ø}z| jj|| jd� W n¸ tjj	yÞ   tdƒ}t
 ||¡ Y qš tjj�yV } z\|jD ]H}d}| jj |¡}|�r td	ƒ| }td
ƒ}t
 || jj |¡|¡ qøW Y d}~qšd}~0  tjj�yl   Y qš0 d}qš|�sŠtj tdƒ¡‚dS )r£   Frp   )Znew_reponamezNo package installed.r³   TúNo match for argument: %sr,   ú
 (from %s)ú%Installed package %s%s not available.NúNothing to do.)r   r   r   rJ   r¤   Ú	reinstallr¥   r   r<   ÚPackagesNotInstalledErrorr   r(   r   ÚPackagesNotAvailableErrorr´   ro   Úhistoryr   r6   r¶   r·   r¸   )r0   r¹   rº   r#   ÚerrÚpkgÚxmsgÚpkgrepor   r   r   r¦   ¢  s>    
.z,RepoPkgsCommand.MoveToSubCommand.run_on_repoNr§   r   r   r   r   ÚMoveToSubCommand•  s   rË   c                   @   s$   e Zd ZdZdZdd„ Zdd„ ZdS )z&RepoPkgsCommand.ReinstallOldSubCommandz0Implementation of the reinstall-old sub-command.)zreinstall-oldc                 C   s,   | j j}d|_d|_d|_d|_tj|_d S rš   r¾   r„   r   r   r   r:   Ò  s    z0RepoPkgsCommand.ReinstallOldSubCommand.configurec                 C   s˜  t | j| jƒ d}| jjs˜z| j d| j| j¡ W n^ tjj	yZ   t
dƒ}t |¡ Y n< tjjy|   t t
dƒ¡ Y n tjjy�   Y n0 d}næ| jjD ]Ü}z| j || j| j¡ W nº tjj	yæ   t
dƒ}t ||¡ Y q  tjj�y` } z^|jD ]J}d}| jj |¡}|�r(t
dƒ| }t
d	ƒ}t || jj |¡|¡ �q W Y d
}~q d
}~0  tjj�yv   Y q 0 d}q |�s”tj t
dƒ¡‚d
S )r£   Frp   ú)No package installed from the repository.r³   Tr¿   r,   rÀ   rÁ   NrÂ   )r   r   r   rJ   r¤   rÃ   r¥   r   r<   rÄ   r   r   r(   rÅ   r´   ro   rÆ   r   r6   r¶   r·   r¸   )r0   r¹   r#   rº   rÇ   rÈ   rÉ   rÊ   r   r   r   r¦   Ú  sD    ÿ
0z2RepoPkgsCommand.ReinstallOldSubCommand.run_on_repoNr§   r   r   r   r   ÚReinstallOldSubCommandÍ  s   rÍ   c                       s4   e Zd ZdZdZ‡ fdd„Zdd„ Zdd„ Z‡  ZS )	z#RepoPkgsCommand.ReinstallSubCommandz,Implementation of the reinstall sub-command.)rÃ   c                    s,   t tj| ƒ |¡ t |¡t |¡f| _dS )úInitialize the command.N)Úsuperr¡   ÚReinstallSubCommandr1   rÍ   rË   Úwrapped_commandsr/   ©Ú	__class__r   r   r1     s    ÿz,RepoPkgsCommand.ReinstallSubCommand.__init__c                 C   s2   d| j j_| jD ]}| j|_| j|_| ¡  qd S rš   )r   r   r‚   rÑ   rJ   r¥   r:   ©r0   Zcommandr   r   r   r:     s
    

z-RepoPkgsCommand.ReinstallSubCommand.configurec              	   C   sZ   t | j| jƒ | jD ]0}z| ¡  W n tjjy>   Y qY q0  qVqtj tdƒ¡‚dS )r£   z!No packages marked for reinstall.N)	r   r   r   rÑ   r¦   r   r<   r¸   r   rÔ   r   r   r   r¦     s    

z/RepoPkgsCommand.ReinstallSubCommand.run_on_repo)	rE   rF   rG   rH   r4   r1   r:   r¦   Ú__classcell__r   r   rÒ   r   rÐ     s
   rÐ   c                   @   s,   e Zd ZdZdZdd„ Zdd„ Zdd„ Zd	S )
z,RepoPkgsCommand.RemoveOrDistroSyncSubCommandz8Implementation of the remove-or-distro-sync sub-command.)zremove-or-distro-syncc                 C   s,   | j j}d|_d|_d|_d|_tj|_d S rš   r®   r„   r   r   r   r:   +  s    z6RepoPkgsCommand.RemoveOrDistroSyncSubCommand.configurec           	         sº   | j jj ˆ¡ tj |¡}| | j jj¡}| j jj‰ ‡ ‡fdd„| 	¡ D ƒ}|s`tj
 d|¡‚| ¡ }| j jjj}|D ]<}|j|j|jd�r | j jj |¡ qx| j jjj||d� qxdS )z;Synchronize a package with another repository or remove it.c                    s   g | ]}ˆ   |¡ˆkr|‘qS r   )r   )Ú.0rÈ   ©rÆ   r¥   r   r   Ú
<listcomp>:  s   ÿzIRepoPkgsCommand.RemoveOrDistroSyncSubCommand._replace.<locals>.<listcomp>zno package matched)r&   Úarch)Ú
clean_depsN)r   r   ZsackZdisable_repor   ÚsubjectZSubjectZget_best_queryrÆ   rP   r<   rÄ   rO   r
   Zclean_requirements_on_removeÚfilterr&   rÙ   Z_goalZdistupgradeZerase)	r0   rº   r¥   rÛ   ZmatchesrP   rO   rÚ   Úpackager   r×   r   Ú_replace3  s"    
ÿÿz5RepoPkgsCommand.RemoveOrDistroSyncSubCommand._replacec              	   C   sÄ   t | j| jƒ d}| jjs\z|  d| j¡ W n( tjj	yT   t
dƒ}t |¡ Y q¬0 d}nP| jjD ]F}z|  || j¡ W n* tjj	y¤   t
dƒ}t ||¡ Y qd0 d}qd|sÀtj t
dƒ¡‚dS )r£   Frp   rÌ   Tr¿   rÂ   N)r   r   r   rJ   r¤   rÞ   r¥   r   r<   rÄ   r   r   r(   r¸   ©r0   r¹   r#   rº   r   r   r   r¦   H  s$    z8RepoPkgsCommand.RemoveOrDistroSyncSubCommand.run_on_repoN)rE   rF   rG   rH   r4   r:   rÞ   r¦   r   r   r   r   ÚRemoveOrDistroSyncSubCommand&  s
   rà   c                   @   s$   e Zd ZdZdZdd„ Zdd„ ZdS )z+RepoPkgsCommand.RemoveOrReinstallSubCommandz6Implementation of the remove-or-reinstall sub-command.)zremove-or-reinstallc                 C   s,   | j j}d|_d|_d|_d|_tj|_d S rš   r¾   r„   r   r   r   r:   j  s    z5RepoPkgsCommand.RemoveOrReinstallSubCommand.configurec              	   C   s   t | j| jƒ d}| jjszz| jjd| j| jdd� W n< tjj	y^   t
dƒ}t |¡ Y qè tjjyr   Y qè0 d}nn| jjD ]d}z| jj|| j| jdd� W n> tjj	yÌ   t
dƒ}t ||¡ Y q‚ tjjyà   Y q‚0 d}q‚|sütj t
dƒ¡‚dS )	r£   Frp   T)Zold_reponameZnew_reponame_neqZ	remove_narÌ   r¿   rÂ   N)r   r   r   rJ   r¤   rÃ   r¥   r   r<   rÄ   r   r   r(   r´   r¸   rß   r   r   r   r¦   r  s8    þ
þ
z7RepoPkgsCommand.RemoveOrReinstallSubCommand.run_on_repoNr§   r   r   r   r   ÚRemoveOrReinstallSubCommande  s   rá   c                   @   s$   e Zd ZdZdZdd„ Zdd„ ZdS )z RepoPkgsCommand.RemoveSubCommandz)Implementation of the remove sub-command.)Úremovec                 C   s*   | j j}d|_d|_d|_d|_d|_d S r’   )r   r   r€   Zallow_erasingr‚   r¯   r°   r„   r   r   r   r:   œ  s    z*RepoPkgsCommand.RemoveSubCommand.configurec                 C   sÄ   d}| j jsPz| j d| j¡ W n( tjjyH   tdƒ}t	 
|¡ Y q®0 d}n^| j jD ]T}z| j || j¡ W n6 tjjy¦ } zt	 
t|ƒ¡ W Y d}~qXd}~0 0 d}qX|sÀt	 tdƒ¡ dS )r£   Frp   rÌ   TNzNo packages marked for removal.)rJ   r¤   r   râ   r¥   r   r<   r´   r   r   r(   ÚstrZwarning)r0   r¹   r#   rº   r»   r   r   r   r¦   ¤  s     $z,RepoPkgsCommand.RemoveSubCommand.run_on_repoNr§   r   r   r   r   ÚRemoveSubCommand—  s   rä   c                   @   s$   e Zd ZdZdZdd„ Zdd„ ZdS )z!RepoPkgsCommand.UpgradeSubCommandz*Implementation of the upgrade sub-command.)Úupgradez
upgrade-toc                 C   s,   | j j}d|_d|_d|_d|_tj|_d S rš   r¾   r„   r   r   r   r:   Ä  s    z+RepoPkgsCommand.UpgradeSubCommand.configurec              	   C   s”   t | j| jƒ d}| jjs.| j | j¡ d}nN| jjD ]D}z| j || j¡ W n& tj	j
yt   t tdƒ|¡ Y q60 d}q6|s�tj	 tdƒ¡‚dS )r£   FTr¿   zNo packages marked for upgrade.N)r   r   r   rJ   r¤   Zupgrade_allr¥   rå   r   r<   r´   r   r(   r   r¸   )r0   r¹   rº   r   r   r   r¦   Ì  s    z-RepoPkgsCommand.UpgradeSubCommand.run_on_repoNr§   r   r   r   r   ÚUpgradeSubCommand¿  s   ræ   )zrepository-packagesz	repo-pkgszrepo-packageszrepository-pkgsz7run commands on top of all packages in given repositoryc                    s>   t t| ƒ ˆ ¡ ‡ fdd„| jD ƒ}d| _dd„ |D ƒ| _dS )rÎ   c                 3   s   | ]}|ˆ ƒV  qd S r-   r   ©rÖ   Úsubcmdr.   r   r   Ú	<genexpr>ð  ó    z+RepoPkgsCommand.__init__.<locals>.<genexpr>Nc                 S   s   i | ]}|j D ]
}||“qqS r   r3   ©rÖ   rè   Úaliasr   r   r   Ú
<dictcomp>ò  s   z,RepoPkgsCommand.__init__.<locals>.<dictcomp>)rÏ   r¡   r1   ÚSUBCMDSrè   Ú_subcmd_name2obj)r0   r   Zsubcmd_objsrÒ   r.   r   r1   í  s    ÿzRepoPkgsCommand.__init__c              	   C   s`  |  ¡ }|jddddd tdƒd� |jddddtd	ƒd
� |jddddtdƒd
� |jddddtdƒd
� |jddddtdƒd
� |jddddtdƒd
� |jddddtdƒd
� |jddddtdƒd
� |jddtjtdƒtdƒd� d d!„ | jD ƒ}d"d!„ | jD ƒ}|jd#dd$|d% |¡d&� d}|ddddd'ddh}|jd(d)td*ƒ||tjtd+ƒd,� d S )-NrW   r©   rY   rN   rZ   r[   ra   rO   rb   rc   rd   rP   re   rf   rQ   rg   rh   rS   ri   rj   rk   rT   rl   rm   rU   rn   r¥   é   ZREPOIDzRepository ID)rs   r]   rt   r`   c                 S   s   g | ]}|j d  ‘qS )r   r3   rç   r   r   r   rØ     rê   z1RepoPkgsCommand.set_argparser.<locals>.<listcomp>c                 S   s   g | ]}|j D ]}|‘qqS r   r3   rë   r   r   r   rØ     rê   rè   Z
SUBCOMMANDz, )rs   rt   ru   r`   rV   r¤   rp   rq   zPackage specificationrr   )rv   rw   r   r   Z_RepoCallbackEnablerî   r!   rz   )r0   r7   r|   Zsubcommand_choicesZsubcommand_choices_allry   rx   r   r   r   r8   õ  sh    þþþþþþþþþ

ÿþýzRepoPkgsCommand.set_argparserc              
   C   s‚   z| j | jjd  | _W n@ tjjtfyX } z | jj ¡  tjj‚W Y d}~n
d}~0 0 | j| j_| jj	d | j_	| j 
¡  dS )z8Verify whether the command can run with given arguments.r   N)rï   rJ   rè   r   r   r   ÚKeyErrorÚ	optparserZprint_usager¥   r:   )r0   r»   r   r   r   r:      s    
zRepoPkgsCommand.configurec                 C   s   | j  ¡  dS )z>Execute the command with respect to given arguments *extcmds*.N)rè   r¦   r2   r   r   r   rB   ,  s    zRepoPkgsCommand.run)rE   rF   rG   rH   r+   r¨   r¬   r¼   r½   rË   rÍ   rÐ   rà   rá   rä   ræ   rî   r4   r   rI   r1   r8   r:   rB   rÕ   r   r   rÒ   r   r¡   4  s0   *8:?2($ü+r¡   c                   @   s0   e Zd ZdZdZedƒZedd„ ƒZdd„ Z	dS )	ÚHelpCommandzRA class containing methods needed by the cli to execute the
    help command.
    )r`   zdisplay a helpful usage messagec                 C   s*   | j ddtdƒtdƒjtjjd�d� d S )NÚcmdú?ZCOMMANDz{prog} command to get help forr   r�   )rw   r   r   r   r   r   r‘   r   r   r   r8   8  s
    ÿÿzHelpCommand.set_argparserc                 C   sL   | j jr| j j| jjvr&| jj ¡  n"| jj| j j }| jj || ƒ¡ d S r-   )rJ   rô   r   Zcli_commandsrò   Z
print_helprÔ   r   r   r   rB   >  s    ÿzHelpCommand.runN)
rE   rF   rG   rH   r4   r   rI   r•   r8   rB   r   r   r   r   ró   0  s   
ró   )r   )#rH   Z
__future__r   r   Zdnf.cli.demandr   Zdnf.cli.option_parserr   Zdnf.i18nr   Zdnf.clir   Zdnf.exceptionsZ
dnf.pycompZdnf.utilZ
dnf.pluginZloggingr   Z	getLoggerr   r=   r>   r   r)   r   r$   r*   Úobjectr+   rL   r‰   r‹   r–   r¡   ró   r   r   r   r   Ú<module>   sJ   
ÿÿÿÿ
9?(     