AlkantarClanX12

Your IP : 3.21.246.53


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

3

�ft`��@s�ddlmZddlmZddlmZddlZddlZddlm	Z	ddl
ZddlZddl
Z
ddlZddlZe
jd�ZdZejjed�Zejjed	�ZGd
d�de�ZGdd
�d
e�ZdS)�)�absolute_import)�unicode_literals)�_N)�PRIO_DEFAULT�dnfz/etc/dnf/aliases.d/zALIASES.confz	USER.confc@s,eZdZdd�Zedd��Zedd��ZdS)�
AliasesConfigcCs$||_tjj�|_|jj|j�dS)N)�_path�libdnf�confZConfigParser�_parser�read)�self�path�r�/usr/lib/python3.6/aliases.py�__init__*szAliasesConfig.__init__cCsHtjjd�}y|jt|jj�dd�Wntk
r>YnX|j�S)NT�main�enabled)	r	r
�
OptionBool�setrrZgetData�
IndexError�getValue)r
�optionrrrr/szAliasesConfig.enabledcCsVtj�}d}|jj|�s|Sx4|jj|�D]$}|jj||�}|sBq*|j�||<q*W|S)N�aliases)�collections�OrderedDictrZ
hasSectionZoptionsr�split)r
�resultZsection�key�valuerrrr8szAliasesConfig.aliasesN)�__name__�
__module__�__qualname__r�propertyrrrrrrr)s	rc@sNeZdZdd�Zdd�Zdd�Zdd�Zdd
d�Zdd
�Zdd�Z	dd�Z
d	S)�AliasescCsFtj�|_d|_d|_|j�r(d|_dS|j�|js:dS|j�dS)NTF)rrrr
r�_disabled_by_environ�
_load_main�
_load_aliases)r
rrrrGs
zAliases.__init__cCshtjjd�}y|jttjd�|j�Stk
r:dSt	k
rbt
jtd�tjd�dSXdS)NTZDNF_DISABLE_ALIASESFz@Unexpected value of environment variable: DNF_DISABLE_ALIASES=%s)
r	r
rrr�os�environr�KeyError�RuntimeError�logger�warningr)r
rrrrr%WszAliases._disabled_by_environcCs�yt|�Stk
rB}ztjjtd�||f��WYdd}~Xn:tk
rz}ztjjtd�||f��WYdd}~XnXdS)NzParsing file "%s" failed: %szCannot read file "%s": %s)rr+r�
exceptions�ConfigErrorr�IOError)r
r�errr�
_load_confds"zAliases._load_confcCsVy|jt�|_|jj|_Wn6tjjk
rP}ztjt	d�|�WYdd}~XnXdS)NzConfig error: %s)
r2�ALIASES_CONF_PATHr
rrr.r/r,�debugr)r
r1rrrr&ns
zAliases._load_mainNcCs�|dkr.y|j�}Wntjjk
r,dSXxf|D]^}y"|j|�}|jrX|jj|j�Wq4tjjk
r�}ztj	t
d�|�WYdd}~Xq4Xq4WdS)NzConfig error: %s)�_dropin_dir_filenamesrr.r/r2rr�updater,r-r)r
�	filenames�filenamer
r1rrrr'us

zAliases._load_aliasescs�tjjt�tjjt�g��fdd�}g}yPtjjt�s@tjt�x4ttj	t��D]"}||�r^qP|j
tjjt|��qPWWn2tt
fk
r�}ztjj|��WYdd}~XnXtjjt�r�|j
t�|S)Ncs|�kp|jd�p|jd�S)N�.�.conf�.CONF)r:r;)�
startswith�endswith)r8)�ignored_filenamesrr�_ignore_filename�s
z7Aliases._dropin_dir_filenames.<locals>._ignore_filename)r(r�basenamer3�ALIASES_USER_PATH�exists�ALIASES_DROPIN_DIR�mkdir�sorted�listdir�append�joinr0�OSErrorrr.r/)r
r?r7�fnr1r)r>rr5�s 


zAliases._dropin_dir_filenamescs:g�g�_�fdd������fdd���|�}�j|S)NcsNd}x&|D]}|r |ddkr P|d7}q
W�j|d|�7_||d�S)Nr�-�)�prefix_options)�argsZnum�arg)r
rr�store_prefix�s
z&Aliases._resolve.<locals>.store_prefixcs��|�}|s*|d�jks*|djd�rry.�j�|djd�rV|ddd�|d<Wntk
rlYnX|S|d�kr�tjjtd����j|d���j|d�}|r�||dd�S�|dd��SdS)Nr�\rLz"Aliases contain infinite recursion)	rr<�poprrr.�ErrorrrG)rN�suffixZcurrent_alias_result)r
�stackrP�
subresolverrrV�s&
z$Aliases._resolve.<locals>.subresolve)rM)r
rNrTr)r
rUrPrVr�_resolve�szAliases._resolvecCsP|jrLy|j|�}Wn6tjjk
rJ}ztjtd�|�WYdd}~XnX|S)Nz%s, using original arguments.)rrWrr.rSr,�errorr)r
rNr1rrr�resolve�s"zAliases.resolve)N)r r!r"rr%r2r&r'r5rWrYrrrrr$Fs


/r$)Z
__future__rrZdnf.i18nrrZdnf.clirZdnf.conf.configrZdnf.exceptionsZlibdnf.confr	Zloggingr(Zos.pathZ	getLoggerr,rCrrHr3rA�objectrr$rrrr�<module>s