ok

Mini Shell

Direktori : /lib/python3.6/site-packages/dnf/cli/commands/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/dnf/cli/commands/__pycache__/alias.cpython-36.pyc

3

�ft`��@s�ddlmZddlmZddlmZddlZddlZddlZddl	Zddlm
Z
ddlZddlZddl
mZejd�ZGdd	�d	e
j�ZdS)
�)�absolute_import)�print_function)�unicode_literalsN)�commands)�_�dnfc@sleZdZdZed�Zedd��Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�Zdd�Zdd�ZdS)�AliasCommand�aliaszList or create command aliasescCsl|j�}|jdddtd�d�|jdddtd�d�|jdd	d
dd
dgtd
�d�|jdddtd�d�dS)Nz--enable-resolvingF�
store_truezenable aliases resolving)�default�action�helpz--disable-resolvingzdisable aliases resolving�
subcommand�?�list�add�deletezaction to do with aliases)�nargsr�choicesr
r	�*zcommand[=result]zalias definition)r�metavarr
)Zadd_mutually_exclusive_group�add_argumentr)�parserZenable_group�r�/usr/lib/python3.6/alias.py�
set_argparser*s

zAliasCommand.set_argparsercCsH|jj}|jjdkrd|_tjjj�|_|jj	�|jj
|_|j�dS)NrrT)rr)
�cli�demands�optsrZ	root_userr�aliasesZAliases�aliases_baseZ
_load_aliases�enabledZresolving_enabled�_update_config_from_options)�selfrrrr�	configure9s

zAliasCommand.configurecCs�d}|jjrd}tjtd��|jjr8d}tjtd��|dk	r�tjjt	j
jj�sft
t	j
jjd�j�t	jjjt	j
jjddd|i�|jj�s�||j_dS)NTzAliases are now enabledFzAliases are now disabled�w�mainr!)rZenable_resolving�logger�inforZdisable_resolving�os�path�existsrrrZALIASES_CONF_PATH�open�close�confZ
BaseConfigZwrite_raw_configfiler Z_disabled_by_environr!)r#r!rrrr"Bs
z(AliasCommand._update_config_from_optionscCs�i}x�|jjD]�}|jdd�}|dj�}t|j��dkrLtjtd�|�q|jd�rhtjtd�|�qt|�dkr�tjtd�|�q|dj�||<qW|S)N�=�rzInvalid alias key: %s�-zAlias argument has no value: %s)	rr	�split�strip�lenr'�warningr�
startswith)r#Znew_aliasesr	�cmdrrr�_parse_option_aliasTs
z AliasCommand._parse_option_aliascCsxtjjtjjj�s&ttjjjd�j�ytjjj	tjjj�}Wn4tj
jk
rr}ztj
td�|�dSd}~XnX|S)Nr%zConfig error: %s)r)r*r+rrr�ALIASES_USER_PATHr,r-Z
AliasesConfig�
exceptionsZConfigErrorr'r5r)r#r.�errr�_load_user_aliaseseszAliasCommand._load_user_aliasescCsdttjjjd�}d}|dj|�7}|d7}x*|j�D]\}}|dj|dj|��7}q4W|j|�dS)Nr%z[main]
zenabled = {}

z
[aliases]
z{} = {}
� )	r,rrrr9�format�items�join�write)r#�user_aliasesr!Zfileobj�output�key�valuerrr�_store_user_aliasespsz AliasCommand._store_user_aliasescCsP|j�}|j}|dkrdS|j|�|j||j�tjtd�dj|j	���dS)NzAliases added: %sz, )
r<r�updaterFr!r'r(rr@�keys)r#rr.rBrrr�add_aliasesys
zAliasCommand.add_aliasescCs�|j�}|j}|dkrdSg}xF|D]>}y||=|j|�Wq$tk
r`tjtd�|�Yq$Xq$W|j||j�tjtd�dj	|��dS)NzAlias not found: %szAliases deleted: %sz, )
r<r�append�KeyErrorr'r(rrFr!r@)r#�cmdsr.rBZ
valid_cmdsr7rrr�remove_aliases�s
zAliasCommand.remove_aliasescCs~|g}y|jj|�}WnHtjjk
r^}z(tjtd�||dj|jj	|��WYdd}~XnXt
td�|dj|�f�dS)Nz%s, alias %s="%s"r=z
Alias %s='%s')r Z_resolverr:�Errorr'�errorrr@r�print)r#r7�argsr;rrr�
list_alias�s0zAliasCommand.list_aliascCs|jjstjtd��|jjdkrL|j�}|s>tj	j
td���|j|�dS|jjdkr�|jj}|gkrxtj	j
td���|j
|�dS|jjs�|jjs�tjtd��dSxX|jjD]}|j|�q�Wn<x:|jjD].}||jjkr�tjtd�|�q�|j|�q�WdS)NzAliases resolving is disabled.rzNo aliases specified.rzNo alias specified.zNo aliases defined.zNo match for alias: %s)r r!r'r5rrrr8rr:rNrIr	rMrr(rR)r#rrLr7rrr�run�s2

zAliasCommand.runN)r	)�__name__�
__module__�__qualname__rrZsummary�staticmethodrr$r"r8r<rFrIrMrRrSrrrrr&s		
r)Z
__future__rrrZloggingZos.pathr)Zdnf.clirZdnf.cli.aliasesrZdnf.confZdnf.exceptionsZdnf.i18nrZ	getLoggerr'ZCommandrrrrr�<module>s


Zerion Mini Shell 1.0