����JFIF��`�`�����Viewing File: /lib/python3.9/site-packages/dnf-plugins/__pycache__/config_manager.cpython-39.opt-1.pyc
a

�&c�*�@s�ddlmZddlmZddlmZmZmZddlZddlZddl	Zddl
ZddlZddlZddl
Z
ddlZddlZejjGdd�dejj��Zdd�Ze�d	�Ze�d
�Ze�d�Ze�d�Zd
d�ZdS)�)�absolute_import)�unicode_literals)�_�logger�P_Nc@sReZdZdgZed�jejjd�Z	e
dd��Zdd�Zdd	�Z
d
d�Zdd
�ZdS)�ConfigManagerCommandzconfig-managerz4manage {prog} configuration options and repositories)�progcCs�|jdddtd�d�|jdddtd	�d
�|jdgdd
td�d�|jdddtd�d
�|jdddtd�d
�|��}|jddddtd�d�|jddddtd�d�dS)N�crepo�*�repozrepo to modify)�nargs�metavar�help�--saveF�
store_truez/save the current options (useful with --setopt))�default�actionr�
--add-repo�appendZURLz8add (and enable) the repo from the specified file or url)rrr
r�--dumpz,print current configuration values to stdout�--dump-variableszprint variable values to stdout�
--set-enabled�set_enabledz"enable repos (automatically saves))r�destrr�--set-disabled�set_disabledz#disable repos (automatically saves))�add_argumentr�add_mutually_exclusive_group)�parserZenable_group�r�>/usr/lib/python3.9/site-packages/dnf-plugins/config_manager.py�
set_argparser)s:�������z"ConfigManagerCommand.set_argparsercCs�|jj}d|_|jjgksd|jjsd|jjsd|jjsd|jjsd|jj	sd|jj
�td��
d�gd����|jjgkr~t�td��|jjs�|jj	s�|jjs�|jjr�d|_dd�|jjD�}dd�|D�|j_dS)	NTz.one of the following arguments is required: {}� )rrrrrz--enablerz	--disablez{Warning: --enablerepo/--disablerepo arguments have no meaningwith config manager. Use --set-enabled/--set-disabled instead.cSsg|]}|dkr|�d��qS)�,)�split)�.0�xrrr �
<listcomp>_�z2ConfigManagerCommand.configure.<locals>.<listcomp>cSs"g|]}|D]}|dkr|�qqS)�r)r%Zsublist�itemrrr r'as�)�cli�demandsZavailable_repos�opts�add_repo�save�dump�dump_variablesrrZ	optparser�errorr�format�joinZrepos_edrZwarningZ	root_userr	)�selfr,Z	temp_listrrr �	configureBs4��������zConfigManagerCommand.configurecCs|jjr|��n|��dS)zExecute the util action here.N)r-r.�modify_repo)r5rrr �runds
zConfigManagerCommand.runc	srg�t������fdd�}�jjrf�jjD]�|�d�q,t�jd�r��jj��D]�|�d�qTn(t�jd�r��jj��D]�|�d�q~�r�tj�t	d�d�
�����jj}i}t�jd�rԈjj
rԈjj
}�jj�r�jjj��D]\�}td	�|f�q�jj�rd
�jjv�rv�jj�rJ|�rJ�jj��jjjd
|j|��jj�rvt�jj�d
��t�jj�����s�dS�jj�s��jj�r�d�j_t��D]�}i}�jj�r�d|d
<n�jj�r�d|d
<t�jd��r�jj��D]$\}}t�|j|��r�|�|��q�jj�r<|�r<�jj�|j|j|j|��jj�r�t�jj�d|j��t|����q�dS)z< process --set-enabled, --set-disabled and --setopt options cs0�jj�|�}|s����n|r,��|�dS)N)�baseZreposZget_matching�add�extend)�keyZadd_matching_reposZmatching�Zmatching_repos�nameZnot_matching_repos_idr5rr �match_reposqs
z5ConfigManagerCommand.modify_repo.<locals>.match_reposT�repo_setoptsFzNo matching repo to modify: %s.z, �main_setoptsz%s = %s�mainN�1Zenabled�0zrepo: )�setr-r	�hasattrr@�keys�dnf�
exceptions�Errorrr4r9�confrAr1Z
substitutions�items�printr/Zwrite_raw_configfileZconfig_file_pathr0�outputZ
fmtSectionrr�sorted�fnmatch�id�updateZrepofile)	r5r?ZsbcZmodify�valrZrepo_modify�repoidZsetoptsrr=r r7ksd�
�




z ConfigManagerCommand.modify_repoc
CsT|jjj}d}|jjD�]}tjj�|�jdkr@dt	j
�|�}t�
td�|�|�d�r�t	j
�|�}t	j
�||�}z6|jj|dd�}t�|j|�t	�|d�|��WnBty�}z*|d	7}t�|�WYd
}~qWYd
}~n
d
}~00qt|�}d�tjj|�}t	j
�|d|�}d
|||f}	t||	�sqq|�rPtj� t!dd|���d
S)z process --add-repo option rr)zfile://zAdding repo from: %sz.repo�w+)�mode��Nz$created by {} config-manager from {}z%s.repoz"[%s]
name=%s
baseurl=%s
enabled=1
zConfiguration of repo failedzConfiguration of repos failed)"r9rKZget_reposdirr-r.rH�pycomp�urlparse�scheme�os�path�abspathr�infor�endswith�basenamer4Zurlopen�shutil�copy2r>�chmod�close�IOErrorr2�sanitize_url_to_fsr3�util�	MAIN_PROG�save_to_filerIrJr)
r5Z	myrepodirZerrors_count�urlZdestname�f�erTZreponame�contentrrr r.�s<


$�

�zConfigManagerCommand.add_repoN)�__name__�
__module__�__qualname__�aliasesrr3rHrhriZsummary�staticmethodr!r6r8r7r.rrrr r"s�
"Brc
Cs�zHt|d��*}tj�||�t�|d�Wd�n1s<0YWn<ttfy�}z t�	t
d�||�WYd}~dSd}~00dS)NrUrWz&Could not save repo to repofile %s: %sFT)�openrHrYZ
write_to_filer\rdrf�OSErrorrr2r)�filenamern�fdrmrrr rj�s.
�rjz^\w+:/*(\w+:|www\.)?z[?/:&#|~\*\[\]\(\)\'\\]+z^[,.]*z[,.]*$cCs(zbt�|�r`tjjr&|�d��d�}n:t|t�rB|�d��d�}n
|�d�}t|t	�r`|�d�}Wnt
ttt
fy|Yn0t�d|�}t�d|�}t�d|�}t�d|�}t|�dk�r|dd��d�}dt|d�}t��}|�||d��d��|d|�d|��}d	}t�|d|�S)
z�Return a filename suitable for the filesystem and for repo id

    Strips dangerous and common characters to create a filename we
    can use to store the cache in.
    Zidnazutf-8r)r�N����zE[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.:-])�	RE_SCHEME�matchrHrYZPY3�encode�decode�
isinstance�strZunicode�UnicodeDecodeError�UnicodeEncodeError�UnicodeError�	TypeError�sub�RE_SLASH�RE_BEGIN�RE_FINAL�lenr$�hashlibZsha256rRZ	hexdigest�re)rk�parts�	lastindexZcsumZ
allowed_regexrrr rg�s.



rg)Z
__future__rrZdnfpluginscorerrrrHZdnf.cliZ
dnf.pycompZdnf.utilrPr�r\r�rbZpluginZregister_commandr+ZCommandrrj�compiler{r�r�r�rgrrrr �<module>s(1




Back to Directory �������}�!1AQa"q2���#B��R��$3br� %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz�������������������������������������������������������������������������������� ������w�!1AQaq"2�B���� #3R�br� $4�%�&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz������������������������������������������������������������������������ ��?��_��+��?��(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(���(�����