Your IP : 3.14.255.58


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

3

�ft`�A�@s�ddlmZddlmZmZddlmZddlmZddl	m
Z
ddl	ZddlZddl
Z
ddlZddlZddlZddlZGdd�dej�ZdS)	�)�print_function)�commands�CliError)�_)�NoModuleException)�loggerNcs*eZdZGdd�dej�ZGdd�de�ZGdd�de�ZGdd�de�ZGd	d
�d
e�Z	Gdd�de�Z
Gd
d�de�ZGdd�de�ZGdd�de�Z
Gdd�de�ZGdd�de�ZGdd�de�Zeeee	e
eee
eeehZehZd%Zed�Z�fdd�Zdd�Zdd �Zd!d"�Zd#d$�Z�ZS)&�
ModuleCommandcs,eZdZ�fdd�Zdd�Zdd�Z�ZS)zModuleCommand.SubCommandcs(ttj|�j|�tjjj|j�|_dS)N)	�superr�
SubCommand�__init__�dnf�module�module_baseZ
ModuleBase�base)�self�cli)�	__class__��/usr/lib/python3.6/module.pyr(sz!ModuleCommand.SubCommand.__init__c	Cs�t�}x�|jjD]�}|jj|�\}}|dkr.q|jr:|jnd}|jrJ|jnd}|jr^|jdksd|jrxt	j
td�j|��|j
r�|j
nd}|jjj||dd|�}|j|�qW|S)N��zjOnly module name, stream, architecture or profile is used. Ignoring unneeded information in argument: '{}'���)�set�opts�module_specr�_get_modules�name�stream�version�contextr�infor�format�archr�_moduleContainer�query�update)	r�modules_from_specsr�__Znsvcaprrr"�modulesrrr�#_get_modules_from_name_stream_specs,sz<ModuleCommand.SubCommand._get_modules_from_name_stream_specsc	Cs�t�}t�}x0|D](}||kr|jjj|�r|j|j��qWxB|D]:}tj|�}x*|jtj	gd�D]}|j
rd|j|j
�qdWqDW||fS)N)Zforms)rrr#ZisModuleActiver%ZgetArtifacts�hawkeyZSubjectZget_nevra_possibilitiesZ
FORM_NEVRAr�add)	rZuse_modulesZskip_modulesZ	artifactsZ	pkg_namesr
ZartifactZsubjZ	nevra_objrrr�_get_module_artifact_names>s


z3ModuleCommand.SubCommand._get_module_artifact_names)�__name__�
__module__�__qualname__rr)r,�
__classcell__rr)rrr
&sr
c@s(eZdZdZed�Zdd�Zdd�ZdS)	zModuleCommand.ListSubCommand�listz,list all module streams, profiles and statescCs|jj}d|_d|_dS)NT)r�demands�available_repos�sack_activation)rr2rrr�	configureRsz&ModuleCommand.ListSubCommand.configurecCs�|j}|jjr&|j|jjtjjj�}nV|jj	rF|j|jjtjjj
�}n6|jjrf|j|jjtjjj�}n|j|jjtjjj
�}|r�t|�dS|jjr�td�}tjj|��dS)NzNo matching Modules to list)rr�enabledZ_get_brief_descriptionr�libdnfr
�ModulePackageContainerZModuleState_ENABLED�disabledZModuleState_DISABLED�	installedZModuleState_INSTALLEDZModuleState_UNKNOWN�printrr�
exceptions�Error)rZmods�output�msgrrr�
run_on_moduleWs(z*ModuleCommand.ListSubCommand.run_on_moduleN)r1)r-r.r/�aliasesr�summaryr5r@rrrr�ListSubCommandMsrCc@s(eZdZdZed�Zdd�Zdd�ZdS)	zModuleCommand.InfoSubCommandr z)print detailed information about a modulecCs|jj}d|_d|_dS)NT)rr2r3r4)rr2rrrr5tsz&ModuleCommand.InfoSubCommand.configurecCsf|jjr|jj|jj�}n*|jjr4|jj|jj�}n|jj|jj�}|rRt|�nt	j
jtd���dS)NzNo matching Modules to list)
r�verboserZ_get_full_infor�profileZ_get_info_profilesZ	_get_infor;rr<r=r)rr>rrrr@ys
z*ModuleCommand.InfoSubCommand.run_on_moduleN)r )r-r.r/rArrBr5r@rrrr�InfoSubCommandosrFc@s(eZdZdZed�Zdd�Zdd�ZdS)	zModuleCommand.EnableSubCommand�enablezenable a module streamcCs$|jj}d|_d|_d|_d|_dS)NT)rr2r3r4�	resolving�	root_user)rr2rrrr5�s
z(ModuleCommand.EnableSubCommand.configurecCs�y|jj|jj�Wnltjjk
r�}zL|jjj	rb|j
s@|jrD|�|jrb|jdt
jjjkrb|�tjt|��WYdd}~XnXdS)Nr)rrGrrrr<�
MarkingErrorsr�conf�strict�no_match_group_specs�error_group_specs�module_depsolv_errorsr7r
r8�!ModuleErrorType_ERROR_IN_DEFAULTSr�error�str)r�errrr@�s
z,ModuleCommand.EnableSubCommand.run_on_moduleN)rG)r-r.r/rArrBr5r@rrrr�EnableSubCommand�srTc@s(eZdZdZed�Zdd�Zdd�ZdS)	zModuleCommand.DisableSubCommand�disablez%disable a module with all its streamscCs$|jj}d|_d|_d|_d|_dS)NT)rr2r3r4rHrI)rr2rrrr5�s
z)ModuleCommand.DisableSubCommand.configurecCs�y|jj|jj�Wnltjjk
r�}zL|jjj	rb|j
s@|jrD|�|jrb|jdt
jjjkrb|�tjt|��WYdd}~XnXdS)Nr)rrUrrrr<rJrrKrLrMrNrOr7r
r8rPrrQrR)rrSrrrr@�s
z-ModuleCommand.DisableSubCommand.run_on_moduleN)rU)r-r.r/rArrBr5r@rrrr�DisableSubCommand�srVc@s(eZdZdZed�Zdd�Zdd�ZdS)	zModuleCommand.ResetSubCommand�resetzreset a modulecCs$|jj}d|_d|_d|_d|_dS)NT)rr2r3r4rHrI)rr2rrrr5�s
z'ModuleCommand.ResetSubCommand.configurecCsby|jj|jj�WnHtjjk
r\}z(|jjj	r>|j
r>|�tjt
|��WYdd}~XnXdS)N)rrWrrrr<rJrrKrLrMrrQrR)rrSrrrr@�s
z+ModuleCommand.ResetSubCommand.run_on_moduleN)rW)r-r.r/rArrBr5r@rrrr�ResetSubCommand�srXc@s(eZdZdZed�Zdd�Zdd�ZdS)	zModuleCommand.InstallSubCommand�installz/install a module profile including its packagescCs$|jj}d|_d|_d|_d|_dS)NT)rr2r3r4rHrI)rr2rrrr5�s
z)ModuleCommand.InstallSubCommand.configurecCspy|jj|jj|jjj�WnNtjj	k
rj}z.|jjjrL|j
sH|jrL|�tj
t|��WYdd}~XnXdS)N)rrYrrrrKrLrr<rJrMrNrrQrR)rrSrrrr@�s
z-ModuleCommand.InstallSubCommand.run_on_moduleN)rY)r-r.r/rArrBr5r@rrrr�InstallSubCommand�srZc@s(eZdZdZed�Zdd�Zdd�ZdS)	zModuleCommand.UpdateSubCommandr%z0update packages associated with an active streamcCs$|jj}d|_d|_d|_d|_dS)NT)rr2r3r4rHrI)rr2rrrr5�s
z(ModuleCommand.UpdateSubCommand.configurecCs&|jj|jj�}|r"tdj|���dS)Nz, )rZupgraderrr�join)rZmodule_specsrrrr@�sz,ModuleCommand.UpdateSubCommand.run_on_moduleN)r%)r-r.r/rArrBr5r@rrrr�UpdateSubCommand�sr\c@s(eZdZd	Zed�Zdd�Zdd�ZdS)
zModuleCommand.RemoveSubCommand�remove�erasez3remove installed module profiles and their packagescCs0|jj}d|_d|_d|_d|_d|_d|_dS)NTF)rr2Z
allow_erasingr3Zfresh_metadatarHrIr4)rr2rrrr5�sz(ModuleCommand.RemoveSubCommand.configurec
Cs�|jj|jj�}|jjr�|j�}|j|t��\}}|j|jj	j
�|�\}}|jjj�j
�j|d�}|jjj�j
�j|d�}xF|D]>}||kr�td�j|�}	tj|	�q�|jjj||jjjd�q�W|s�dStjtjj|d��dS)N)rz0Package {} belongs to multiple modules, skipping)Z
clean_deps)rM)rr]rr�allr)r,rrr#ZgetModulePackages�sackr$r:�filtermrr!rr Zgoalr^rKZclean_requirements_on_removerQrr<rJ)
rZskipped_groupsr&Zremove_names_from_specr'Z
keep_namesZremove_queryZ
keep_query�pkgr?rrrr@�s&
z,ModuleCommand.RemoveSubCommand.run_on_moduleN)r]r^)r-r.r/rArrBr5r@rrrr�RemoveSubCommand�s	rcc@s(eZdZdZed�Zdd�Zdd�ZdS)	z ModuleCommand.SwitchToSubCommand�	switch-toz7switch a module to a stream and distrosync rpm packagescCs.|jj}d|_d|_d|_d|_d|jj_dS)NT)	rr2r3r4rHrIrrKZmodule_stream_switch)rr2rrrr5sz*ModuleCommand.SwitchToSubCommand.configurecCsry|jj|jj|jjjd�WnNtjj	k
rl}z.|jjjrN|j
sJ|jrN|�tj
t|��WYdd}~XnXdS)N)rL)rZ	switch_torrrrKrLrr<rJrMrNrrQrR)rrSrrrr@"s
z.ModuleCommand.SwitchToSubCommand.run_on_moduleN)rd)r-r.r/rArrBr5r@rrrr�SwitchToSubCommandsrec@s(eZdZdZed�Zdd�Zdd�ZdS)	z ModuleCommand.ProvidesSubCommand�provideszlist modular packagescCs|jj}d|_d|_dS)NT)rr2r3r4)rr2rrrr50sz*ModuleCommand.ProvidesSubCommand.configurecCs |jj|jj�}|rt|�dS)N)rZ_what_providesrrr;)rr>rrrr@5sz.ModuleCommand.ProvidesSubCommand.run_on_moduleN)rf)r-r.r/rArrBr5r@rrrr�ProvidesSubCommand+srgc@s(eZdZdZed�Zdd�Zdd�ZdS)	z!ModuleCommand.RepoquerySubCommand�	repoqueryz#list packages belonging to a modulecCs|jj}d|_d|_dS)NT)rr2r3r4)rr2rrrr5?sz+ModuleCommand.RepoquerySubCommand.configurecCs�t�}x*|jjD]}|jj|�\}}|j|�qW|j|t��\}}t�}|jjs\|jjr�|j	j
j�j�j|d�}x|D]}	|j
t|	��qzW|jjr�|j	j
j�j�j|d�}x|D]}	|j
t|	��q�Wdjt|��}
t|
�dS)N)Znevra_strict)r�
)rrrrrr%r,�	availabler:rr`r$rar+rRr[�sortedr;)rr&rr(r'Znames_from_specZspec_artifactsZpackage_stringsr$rbr>rrrr@Ds"

z/ModuleCommand.RepoquerySubCommand.run_on_moduleN)rh)r-r.r/rArrBr5r@rrrr�RepoquerySubCommand:srlr
zInteract with Modules.cs>tt|�j���fdd�|jD�}d|_dd�|D�|_dS)Nc3s|]}|��VqdS)Nr)�.0�subcmd)rrr�	<genexpr>dsz)ModuleCommand.__init__.<locals>.<genexpr>cSsi|]}|jD]
}||�qqSr)rA)rmrn�aliasrrr�
<dictcomp>fsz*ModuleCommand.__init__.<locals>.<dictcomp>)r	rr�SUBCMDSrn�_subcmd_name2obj)rrZsubcmd_objs)r)rrrbs
zModuleCommand.__init__cCs|j�}|jdddtd�d�|jdddtd�d�|jd	d
dtd�d�|jdd
dtd�d�|jdddtd�d�|jdddtd�d�g}g}xHt|jdd�d�D]2}|j|jd�|jdj|jd|jp�d��q�W|jdd|ddj	|�d�|jd d!d"td#�d$�dS)%Nz	--enabledr6�
store_truezshow only enabled modules)�dest�action�helpz
--disabledr9zshow only disabled modulesz--installedr:z'show only installed modules or packagesz	--profilerEzshow profile contentz--availablerjzshow only available packagesz--allr_zremove all modular packagescSs
|jdS)Nr)rA)�xrrr�<lambda>~sz-ModuleCommand.set_argparser.<locals>.<lambda>)�keyrz{}: {}rrnrz<modular command>ri)�nargs�choices�metavarrwrzmodule-spec�*zModule specification)r}r{rw)
Zadd_mutually_exclusive_group�add_argumentrrkrr�appendrAr!rBr[)r�parserZnarrowsZsubcommand_choicesZsubcommand_helprnrrr�
set_argparseris8
"

zModuleCommand.set_argparsercCsZy|j|jjd|_Wn(ttfk
r@|jjj�t�YnX|j|j_|jj�dS)Nr)	rsrrnr�KeyErrorrZ	optparserZprint_usager5)rrrrr5�s

zModuleCommand.configurecCs|j�|jj�dS)N)�check_required_argumentrnr@)rrrr�run�szModuleCommand.runcCsRdd�|jD�}|jjd|krN|jjsNttd�jtjj	|jj
|jjd���dS)NcSsg|]}|jD]}|�qqSr)rA)rmrnrprrr�
<listcomp>�sz9ModuleCommand.check_required_argument.<locals>.<listcomp>rz{} {} {}: too few arguments)�SUBCMDS_NOT_REQUIRED_ARGrrnrrrr!r�utilZ	MAIN_PROGZcommand)rZnot_required_argumentrrrr��s
z%ModuleCommand.check_required_argument)r
)r-r.r/r�Commandr
rCrFrTrVrXrZr\rcrergrlrrr�rArrBrr�r5r�r�r0rr)rrr%s.'"%	r)Z
__future__rZdnf.clirrZdnf.i18nrZdnf.module.exceptionsrZdnf.utilrr�sys�osr*r7Zdnf.module.module_baseZdnf.exceptionsr�rrrrr�<module>s

?>