OwlCyberSecurity - MANAGER
Edit File: config_manager.cpython-36.opt-1.pyc
3 �gt`�*������������������@���s����d�dl�mZ�d�dl�mZ�d�dlmZmZmZ�d�dlZd�dlZd�dl Zd�dl Zd�dlZd�dlZd�dl Z d�dlZd�dlZejjG�dd��dejj��Zdd��Zejd �Zejd �Zejd�Zejd�Zd d��ZdS�)�����)�absolute_import)�unicode_literals)�_�logger�P_Nc���������������@���sR���e�Zd�ZdgZed�jejjd�Z e dd���Zdd��Zdd ��Z d d��Zdd ��ZdS�)�ConfigManagerCommandzconfig-managerz4manage {prog} configuration options and repositories)�progc�������������C���s����|�j�dddtd�d��|�j�dddtd �d ��|�j�dg�dd td�d��|�j�dddtd�d ��|�j�dddtd�d ��|�j��}|j�ddddtd�d��|j�ddddtd�d��d�S�)N�crepo�*�repozrepo to modify)�nargs�metavar�helpz--saveF� store_truez/save the current options (useful with --setopt))�default�actionr���z --add-repo�appendZURLz8add (and enable) the repo from the specified file or url)r���r���r ���r���z--dumpz,print current configuration values to stdoutz--dump-variableszprint variable values to stdoutz --set-enabled�set_enabledz"enable repos (automatically saves))r����destr���r���z--set-disabled�set_disabledz#disable repos (automatically saves))�add_argumentr���Zadd_mutually_exclusive_group)�parserZenable_group��r����$/usr/lib/python3.6/config_manager.py� set_argparser)���s,����z"ConfigManagerCommand.set_argparserc�������������C���s����|�j�j}d|_|�jjg�kp@|�jjp@|�jjp@|�jjp@|�jjp@|�jj sp|�j�j jtd�j djdddddd d dg����|�jjg�kr�tjtd���|�jjs�|�jj s�|�jjs�|�jjr�d|_d d��|�jjD��}dd��|D��|�j_d�S�)NTz.one of the following arguments is required: {}� z--savez --add-repoz--dumpz--dump-variablesz --set-enabledz--enablez--set-disabledz --disablez{Warning: --enablerepo/--disablerepo arguments have no meaningwith config manager. Use --set-enabled/--set-disabled instead.c�������������S���s���g�|�]}|d�kr|j�d���qS�)�,)�split)�.0�xr���r���r���� <listcomp>_���s����z2ConfigManagerCommand.configure.<locals>.<listcomp>c�������������S���s"���g�|�]}|D�]}|d�kr|�qqS�)��r���)r���Zsublist�itemr���r���r���r ���a���s����)�cli�demandsZavailable_repos�opts�add_repo�save�dump�dump_variablesr���r���Z optparser�errorr����format�joinZrepos_edr���ZwarningZ root_userr ���)�selfr$���Z temp_listr���r���r���� configureB���s*����zConfigManagerCommand.configurec�������������C���s���|�j�jr|�j���n|�j���dS�)zExecute the util action here.N)r%���r&����modify_repo)r-���r���r���r����rund���s���� zConfigManagerCommand.runc������� ���������s���g���t���������fdd�}�jjrnx�jjD�]�|�d��q.W�t�jd�r�xL�jjj��D�]�|�d��qZW�n,t�jd�r�x�jjj��D�]�|�d��q�W��r�tjjt d�dj ������jj}i�}t�jd�r�jj r�jj }�jj�rx*�jjjj��D�]\�}td �|f���q�W��jj��s0d �jjk�r��jj�r\|�r\�jjj�jjjd |j|���jj�r�t�jjjd ���t�jjj�������s�dS��jj�s��jj�r�d�j_x�t���D�]�}i�}�jj�r�d|d <�n�jj�r�d|d <�t�jd��r*x4�jjj��D�]$\}}tj|j|��r|j|���qW��jj�rT|�rT�jjj|j|j|j|���jj�r�t�jjjd|j����t|j�����q�W�dS�)z< process --set-enabled, --set-disabled and --setopt options c����������������s0����j�jj|��}|s�j���n|r,��j|��d�S�)N)�baseZreposZget_matching�add�extend)�keyZadd_matching_reposZmatching)�matching_repos�name�not_matching_repos_idr-���r���r����match_reposq���s ����z5ConfigManagerCommand.modify_repo.<locals>.match_reposT�repo_setoptsFzNo matching repo to modify: %s.z, �main_setoptsz%s = %s�mainN�1Zenabled�0zrepo: )�setr%���r ����hasattrr9����keys�dnf� exceptions�Errorr���r,���r1����confr:���r)���Z substitutions�items�printr'���Zwrite_raw_configfileZconfig_file_pathr(����outputZ fmtSectionr���r����sorted�fnmatch�id�updateZrepofile) r-���r8���ZsbcZmodify�valr���Zrepo_modify�repoidZsetoptsr���)r5���r6���r7���r-���r���r/���k���s`���� z ConfigManagerCommand.modify_repoc������� ������C���sN��|�j�jj}d}�x|�jjD��]}tjjj|�jdkrDdt j j|��}tj td�|��|jd�r�t j j|�}t j j||�}y6|�j�j|dd�}tj|j|��t j|d��|j���W�n6�tk r��}�z|d 7�}tj|��wW�Y�d d }~X�nX�qt|�}djtjj|�}t j j|d|��}d |||f�} t|| �sqqW�|�rJtjj t!dd|���d S�)z process --add-repo option r���r!���zfile://zAdding repo from: %sz.repozw+)�modei�������Nz$created by {} config-manager from {}z%s.repoz"[%s] name=%s baseurl=%s enabled=1 zConfiguration of repo failedzConfiguration of repos failed)"r1���rD���Zget_reposdirr%���r&���rA����pycompZurlparse�scheme�os�path�abspathr����infor����endswith�basenamer,���Zurlopen�shutilZcopy2r6����chmod�close�IOErrorr*����sanitize_url_to_fsr+����util� MAIN_PROG�save_to_filerB���rC���r���) r-���Z myrepodirZerrors_count�urlZdestname�f�erM���Zreponame�contentr���r���r���r&�������s8���� zConfigManagerCommand.add_repoN)�__name__� __module__�__qualname__�aliasesr���r+���rA���r]���r^���Zsummary�staticmethodr���r.���r0���r/���r&���r���r���r���r���r���"���s���"Br���c�������������C���sp���y4t�|�d�� }tjj||��tj|�d��W�d�Q�R�X�W�n6�ttfk rj�}�ztj t d�|�|��dS�d�}~X�nX�dS�)Nzw+i���z&Could not save repo to repofile %s: %sFT)�openrA���rP���Z write_to_filerR���rY���r[����OSErrorr���r*���r���)�filenamerc����fdrb���r���r���r���r_�������s���� r_���z^\w+:/*(\w+:|www\.)?z[?/:&#|~\*\[\]\(\)\'\\]+z^[,.]*z[,.]*$c�������������C���s*��ybt�j|��r`tjjr&|�jd�jd�}�n:t|�t�rB|�jd�jd�}�n |�jd�}�t|�t �r`|�jd�}�W�n�t ttt fk r~���Y�nX�t�jd|��}�tjd|��}�tjd|��}�tjd|��}�t|��dk�r|�dd��jd�}dt|d ���}tj��}|j|�|d��jd���|�d|��d�|j���}�d }tj|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����rO���zE[^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_.:-]���)� RE_SCHEME�matchrA���rP���ZPY3�encode�decode� isinstance�strZunicode�UnicodeDecodeError�UnicodeEncodeError�UnicodeError� TypeError�sub�RE_SLASH�RE_BEGIN�RE_FINAL�lenr����hashlibZsha256rK���Z hexdigest�re)r`����parts� lastindexZcsumZ allowed_regexr���r���r���r\�������s.���� r\���)Z __future__r���r���Zdnfpluginscorer���r���r���rA���Zdnf.cliZ dnf.pycompZdnf.utilrI���r���rR���r����rX���ZpluginZregister_commandr#���ZCommandr���r_����compilerp���r{���r|���r}���r\���r���r���r���r����<module>���s(����1