Edit File: repomanage.cpython-36.pyc
3 �*�dJ)������������������@���sz���d�dl�mZ�d�dl�mZ�d�dlmZmZ�d�dlZd�dlZd�dlZd�dl Z d�dl Z G�dd��dej�ZG�dd��dej j�ZdS�) �����)�absolute_import)�unicode_literals)�_�loggerNc�������������������s ���e�Zd�ZdZ��fdd�Z���ZS�)� RepoManage� repomanagec����������������s,���t�t|��j||��|d�krd�S�|jt��d�S�)N)�superr����__init__Zregister_command�RepoManageCommand)�self�base�cli)� __class__��� /usr/lib/python3.6/repomanage.pyr ���$���s����zRepoManage.__init__)�__name__� __module__�__qualname__�namer ���� __classcell__r���r���)r���r���r��� ���s���r���c���������������@���s\���e�Zd�ZdZed�Zdd��Zdd��Zdd��Ze d d ���Z e dd���Zd d��Ze dd���Z dS�)r ���r���z"Manage a directory of rpm packagesc�������������C���s,���|�j�j�r(|�j�j�r(|�jjtjtjd��d�S�)N)�stdout�stderr)�opts�verbose�quietr ���Zredirect_logger�loggingZWARNING�INFO)r���r���r���r���� pre_configure/���s����zRepoManageCommand.pre_configurec�������������C���s0���|�j�j�r|�j�j�r|�jj���|�jj}d|_d�S�)NT)r���r���r���r ���Zredirect_repo_progress�demandsZsack_activation)r���r���r���r���r���� configure3���s���� zRepoManageCommand.configurec�������"���������s@����j�jr ��j�jr tjjtd�����j�jr@��j�jr@tjjtd�����j�jr`��j�jr`tjjtd�����j�j�r|��j�j�r|d��j�_i�}i�}i�}t��}t ��j�j �}y�d}��jjj |��jj��j�jgd�}|jj�����jj|��tjj�r>��jj�����jjj��}xH|D�]@} | j��|kr�|j| j����|j| j��i��j| j��g��j| ��q�W�W�n��tjjk �r����g�} ��j��j�jd�} t | �dk�r�tjjtd �����jj!ddd ����jj"ddd��y��jj#| ��jj$j%d ��W�n0�t&k �r����t'j(td�j)dj*| ����Y�nX�Y�nX���jj+j,t-j.d�j/��}dd��|j0|j0|d�d�j/��D��}|j1���x�|D�]~} | j2| j3f}||k�rx| ||�k�r�||�j| ��n | g||<���j4| �}||k�r�||�j��j5| ���n��j5| �g||<��q@W�g�}t��}��j�j�r�xh|j6��D�]\\}}|||f�}||�d���}x6|D�].}��j4|�}x||�D�]}|j|���q W��qW��q�W�xb|j7��D�]V}t8|j6���}||�d���}x4|D�],}x$||�D�]}|jt|j������q|W��qnW��qJW���j�j�r|xh|j6��D�]\\}}|||f�}|d�|���}x6|D�].}��j4|�}x||�D�]}|j|���q�W��q�W��q�W�xb|j7��D�]V}t8|j6���}|d�|���}x4|D�],}x$||�D�]}|jt|j������qTW��qFW��q"W���j�j�r�xh|j6��D�]\\}}|||f�}|d�|���}x6|D�].}��j4|�}x||�D�]}|j|���q�W��q�W��q�W�t��}xb|j7��D�]V}t8|j6���}||�d���}x4|D�],}x$||�D�]}|jt|j������q2W��q$W��q�W�xx|j7��D�]l}t8|j6���}|d�|���}xJ|D�]B}x:||�D�].}x&|j��D�]} | |k�r�|j9| ���q�W��q�W��q�W��qdW���fdd�|j0|j0|d�d�j/��D��}!||!�}|j1�����j�j:�r$t;dj*|���nx|D�]} t;| ���q*W�d�S�)Nz%Pass either --old or --new, not both!z)Pass either --oldonly or --new, not both!z)Pass either --old or --oldonly, not both!TZrepomanage_repo)Zbaseurlz.rpmr���zNo files to process)�sack�reposF)Zload_system_repoZload_available_repos)�progresszCould not open {}z, )�flagsc�������������S���s���g�|�]}|�qS�r���r���)�.0�xr���r���r���� <listcomp>o���s����z)RepoManageCommand.run.<locals>.<listcomp>)Znevra_strict)Zpkg__neqc����������������s���g�|�]}��j�|��qS�r���)�_package_to_path)r$���r%���)r���r���r���r&�������s����)Zpkg__eq� )<r����new�old�dnf� exceptions�Errorr���Zoldonly�set�intZkeepr���r!���Zadd_new_repoZconf�pathZ_repoZexpireZ_add_repo_to_sackZWITH_MODULESZ_setup_modular_excludesZ_moduleContainerZgetModulePackagesZ getRepoID�updateZgetArtifacts� setdefaultZ getNameStreamZ getVersionNum�appendZ RepoError�_get_file_list�len�resetZ fill_sackZadd_remote_rpms�outputr"����IOErrorr���Zwarning�format�joinr ����query�hawkeyZIGNORE_MODULAR_EXCLUDESZ available�filter�sortr����arch�_package_to_nevrar'����keys�values�sorted�addZspace�print)"r���ZverfileZpkgdictZmodule_dictZall_modular_artifactsZkeepnumZREPOMANAGE_REPOIDZ repo_confZmodule_packagesZmodule_packageZrpm_listr;���Zpackages�pkgZnaZnevraZoutputpackagesZkeepnum_latest_stream_artifacts�n�aZevrlistZnewevrs�packageZfpkgZstreams_by_versionZsorted_stream_versionsZnew_sorted_stream_versions�i�streamZoldevrsZold_sorted_stream_versionsZkeepnum_newer_stream_artifactsZartifactZmodular_packagesr���)r���r����run9���s����� &" $ $ $ "& zRepoManageCommand.runc���������� ���C���s����|�j�dddtd�d��|�j�dddtd�d��|�j�d d dtd�d��|�j�dd dtd�d��|�j�ddddtd�dtd��|�j�ddtd�d��d�S�)Nz-oz--old� store_truezPrint the older packages)�action�helpz-Oz --oldonlyz6Print the older packages. Exclude the newest packages.z-nz--newzPrint the newest packagesz-sz--spacez#Space separated output, not newlinez-kz--keepZstoreZKEEPz)Newest N packages to keep - defaults to 1����)rN����metavarrO����default�typer0���zPath to directory)�add_argumentr���r/���)�parserr���r���r���� set_argparser����s���� zRepoManageCommand.set_argparserc�������������C���s`���g�}xVt�j|��D�]H\}}}x<|D�]4}t�jj|�d�j��t|�kr |jt�jj||���q W�qW�|S�)zJReturn all files in path matching ext return list object rP���)�os�walkr0����splitext�lower�strr3���r:���)r0���ZextZfilelist�root�dirs�files�fr���r���r���r4�������s���� z RepoManageCommand._get_file_listc�������������C���s*���t�|�jj�r tjj|�jj|j�S�|jS�d�S�)N)r5���r���r!���rW���r0���r:���r����location)r���rF���r���r���r���r'�������s����z"RepoManageCommand._package_to_pathc�������������C���s���|�j�|�j|�j|�j|�jfS�)N)r���Zepoch�version�releaser?���)rF���r���r���r���r@������s����z#RepoManageCommand._package_to_nevraN)r���)r���r���r����aliasesr���Zsummaryr���r���rL����staticmethodrV���r4���r'���r@���r���r���r���r���r ���+���s����$r ���)Z __future__r���r���Zdnfpluginscorer���r���r+���Zdnf.clir���rW���r<���ZPluginr���r ���ZCommandr ���r���r���r���r����<module>���s���